Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.51k stars 333 forks source link

[Crash] Overscroll the BG content #223

Open Sagar0-0 opened 1 day ago

Sagar0-0 commented 1 day ago

Please include: 1) Library version: version-2.0.5 2) Device and OS version: Pixel 8 Pro API 34 Emulator 3) Detailed steps to reproduce the issue

4) XML layout and code for BlurView setup

Sagar0-0 commented 1 day ago

Screen_recording_20241019_124506.webm

Dimezis commented 1 day ago

This library does not support Compose. While I could work around this particular crash by just try-catching the view snapshotting, it would most likely result in a missing blur for the time of the overscroll (or other event that can cause the same problem)

Sagar0-0 commented 23 hours ago

I know this library does not directly support Compose, that's why I am creating a Compose Library(wrapper around your BlurView) to support compose.

Dimezis commented 23 hours ago

that's why I am creating a Compose Library(wrapper around your BlurView) to support compose.

This isn't going to work well. Compose rendering relies on hardware acceleration in too many places. BlurView uses software rendering to snapshot the Compose hierarchy, and you'll just have an endless pile of bugs cropping up, even if you aren't stumbling on them now.

Sagar0-0 commented 22 hours ago

You might be right here, and because of this Rendering difference, I am getting lag/desync with GIF backgrounds. Do you have any resources that I can follow to dive deeper into Rendering and maybe achieve this in Compose?

Dimezis commented 22 hours ago

There's already a good Compose lib for that - Haze It works starting with API 31, but you won't be able to get around that anyway, because you need the RenderNode API.

Sagar0-0 commented 22 hours ago

I know about Haze but I need more supported versions below, there can be some ways, afaik Compose does use Software rendering in some cases.

Do you know, if we can make something with the existing API? or this isn't the right place for this...

Dimezis commented 22 hours ago

🙂 That link proves nothing, it's just a random person spreading some BS. Text rendering has been hardware accelerated for a long while.

Also, it doesn't matter whether Compose falls back to software rendering in some cases.

Long story short, with the current state of Compose, you won't be able to pull this off reliably using software snapshotting. With hardware snapshotting, your only reasonable option is either RenderNode API, or TextureView/SurfaceView in combination with [lockHardwareCanvas](https://developer.android.com/reference/android/view/SurfaceHolder#lockHardwareCanvas()) to obtain a hardware canvas. The latter would require OpenGL/Vulkan to perform blur efficiently, and it's a significantly different approach overall.