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

Feature Request: Smooth blurring with no popping #161

Open
izackp opened this issue Nov 9, 2021 · 4 comments
Open

Feature Request: Smooth blurring with no popping #161

izackp opened this issue Nov 9, 2021 · 4 comments

Comments

@izackp
Copy link

izackp commented Nov 9, 2021

Let's say you have a blue background with a red rectangle moving. Once the red rectangle reaches the blue view then moves 1 pixel underneath it BAM the whole area is now has a red tint. High contrast elements will flash in and out as the user scrolls which become noticeable.

https://gfycat.com/fatalgroundedjanenschia

@Dimezis
Copy link
Owner

Dimezis commented Nov 10, 2021

How do you imagine this can be fixed?

You have a bitmap with View snapshot, let's say 100x100, pure white.
Blurring it produces a pure white bitmap again.

Next frame, the top 1-2 rows of pixels become red.
You blur this bitmap with a radius of 20 pixels, and the red color spreads down by 20 pixels give or take.

The effect is then exaggerated because of the need to downscale the original bitmap to produce the blur in a reasonable amount of time.
Blurring a full-sized bitmap would help to mitigate this by a large amount, but most of budget+ Android devices would choke on that

@izackp
Copy link
Author

izackp commented Nov 10, 2021

Hmm I thought about two ways but they both seem like a pain

  • Capture a larger bitmap
    lets say its 100x100 and the radius is 20 pixels
    create a blur that's 140x140 then clip the 100x100 image out of that.
    However, I don't really like the idea of having the blur change color before an image gets under it.

  • Weighting the blur radius based on distance from an edge
    Maybe capping the radius blur per pixel based on it's distance from an edge. 1px away = 1 px max radius
    In a 100x100 with a 20 blur radius, all items inside of (20,20 - 60x60) will blur as usually and any outside will be weighted down by radius and perhaps intensity?

Both don't really seem like easy fixes tho, since you're using a built-in algorithm to do the blurring.

@Dimezis
Copy link
Owner

Dimezis commented Nov 10, 2021

However, I don't really like the idea of having the blur change color before an image gets under it.

Yes, it's a fundamental problem of this kind of approach

Weighting the blur radius based on distance from an edge

While it might seem like a remedy for this particular case, it will produce weird/incorrect results in general.

To really fix this the BlurView needs to stop downscaling the view hierarchy to speed up the blur, but with all the limitations Android imposes, that's just not realistic for weaker devices.

Thanks for the suggestions though!

@Dimezis
Copy link
Owner

Dimezis commented Apr 3, 2022

This is somewhat addressed for API >= 31 in version 2.0.0 with the new RenderEffectBlur.
It's still not ideal, also barely tested, but you can try it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants