Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting for users to lower the threshold for HW bitmaps #1486

Closed
wants to merge 4 commits into from

Conversation

Raikuha
Copy link

@Raikuha Raikuha commented Nov 15, 2024

Allow users to configure a new value that will override maxTextureSize when deciding if a software bitmap should be replaced by a hardware one after being decoded, to prevent textures from failing on older devices. Default is maxTextureSize since that works for most people.

Fix #1436 with a better approach than #1440 since it's all up to the user. It references the way the user-agent setting is set, so if there's anything that should be changed or streamlined in the code I'm all ears.

The issue of blanks and flickering:

Screen_recording_20241115_094748.mp4

What the setting looks like and how it works:

Screen_recording_20241115_095003.mp4

Comment on lines 353 to 374
Preference.PreferenceItem.EditTextPreference(
pref = maxBitmapSize,
title = stringResource(MR.strings.pref_max_bitmap_size),
subtitle = stringResource(MR.strings.pref_max_bitmap_size_summary),
onValueChanged = {
if (it.isDigitsOnly() && it <= maxBitmapSize.defaultValue()) {
context.toast(MR.strings.pref_max_bitmap_size_success)
} else {
context.toast(MR.strings.pref_max_bitmap_size_error)
return@EditTextPreference false
}
true
},
),
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_max_bitmap_size_reset),
enabled = remember(maxBitmap) { maxBitmap != maxBitmapSize.defaultValue() },
onClick = {
maxBitmapSize.delete()
context.toast(MR.strings.pref_max_bitmap_size_success)
},
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how i feel about an arbitrary value

Copy link
Author

@Raikuha Raikuha Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntsyLich Which arbitrary value are you referring to? The default value is set as GLUtil.maxTextureSize when declaring the function in BasePreferences, to mantain the way it currently works for non-affected users (which are the majority of the userbase).

I took this approach precisely because I don't want to be hardcoding a value that might not cover all cases or that might cover more than needed. This would only allow the user to lower the threshold to "reject" a hardware bitmap in the event that maxTextureSize turns out to be too permissive in practice, so unless someone changes this value, the decoder will work just as it does currently. It doesn't scale or affect the images in the slightest either, simply bypasses the hwBitmap creation if the image is taller than the device can handle (as defined by the user).

Edit: As for the user-defined value, it shouldn't be arbitrary either, but rather based on the pages that fail for them. They should check the height of the images and adjust the setting to "filter" anything equal or higher than that. If they overdo it and performance takes a hit because most pages are filtered, then that's on them.

Though I'm honestly not sure how much of a performance hit there would be since the decoding is already over by the time a hardware bitmap is created or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant letting the user set an arbitrary value

Copy link
Author

@Raikuha Raikuha Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine since it's only a value that limits which images are shown as hardware bitmaps or left as they were. Same results as having a lower SDK from the start, but limited to certain pages or chapters rather than all of them. The setting also checks to ensure the value can't be higher than maxTextureSize and that it can only be a numerical value.

The user still has other options like downloading the pages while splitting them, or simply changing sources. This PR is just a more user-friendly method with less steps. A cleaner alternative like splitting the vertical splits on the fly before displaying each half in the reader seemed like too much work just to deal with a few edge cases so I gave up on that.

Anyway, since this PR worked for my needs, I brought it up, but in the end it is just a suggestion so don't feel pressured if it doesn't convince you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say use a slider with limited values, like 4k, 8k, 16k, etc.

Copy link
Author

@Raikuha Raikuha Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a neat approach, but most webtoons are already above 8k so just one step would mean filtering out pages that would normally work in the device. It seems rather overkill.

In my video, the issue disappeared after changing the default 16k to just 15500, so if the slider starts from maxTextureSize as the highest point and goes down in 4 or 6 steps of 500 px, it should be enough to handle the issue without being too drastic. I doubt the breakpoint for a device can be more than 3k pixels below maxTextureSize.

Edit: A quick test using max = maxTextureSize, min = (maxTextureSize/2), steps = 10 as arguments for the Slider preference seems to work fine. Should give enough flexibility and uses only device related values. 5 steps is also fine

Debugging shows images may have bigger dimensions than expected. To avoid exceeding maxTextureSize, a second optional check is added, controlled by a toggle under Advanced Settings.
Some pages present flickering due to having dimensions that surpass those calculated in SubsamplingScaleImageView.
Rather than a toggle and test-based guesses, now the fix relies on user input to handle the images that don't work normally
Range is maxTextureSize/2 .. maxTextureSize, set to 5 steps in SettingsAdvancedScreen
@AntsyLich AntsyLich closed this in dcddac5 Nov 20, 2024
@Raikuha Raikuha deleted the custom_max_texture branch November 20, 2024 21:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Long strip sometime showing blank image
3 participants