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

Blur frozen on Android API 31 #77

Open
jakobulbrich opened this issue Jan 4, 2024 · 9 comments · May be fixed by #146
Open

Blur frozen on Android API 31 #77

jakobulbrich opened this issue Jan 4, 2024 · 9 comments · May be fixed by #146
Labels
android bug Something isn't working

Comments

@jakobulbrich
Copy link

On Android 12 (API 31) the blur is frozen while scrolling.
Only when the bottom navigation appears or disappears the blur quickly updates and is then frozen again.

Seems like HazeNode31.onObservedReadsChanged() is not called. Probably a bug in Compose or can we do something about it?

See attached video of the android-jetpack sample on API 31. It is working as expected on API 32.

haze-api31.mp4
@chrisbanes
Copy link
Owner

So it seems that the draw() function isn't being called consistently on API 31, but is on API 32+. I'll raise on the Compose Issue Tracker.

@chrisbanes
Copy link
Owner

https://issuetracker.google.com/issues/318679450

@chrisbanes
Copy link
Owner

I'll have another play tomorrow and see if I can get something working. If not I'll probably have to bump up the min SDK level for the blur impl to 32 for now.

@chrisbanes chrisbanes added the bug Something isn't working label Jan 5, 2024
@gleb-skobinsky
Copy link

I hope I can add some context as to the origins and the reason why this bug happens. It appears that everything is okay on the Compose side. The issue here is with the RenderNode. My hypothesis is that on API 31, it fails to refresh on the JNI side if its position has not updated since the latest draw call. More specifically, in this part of the code:

private fun Effect.updateRenderNodePosition() {
    renderNode.setPosition(0, 0, bounds.width.toInt(), bounds.height.toInt())
    renderNode.translationX = bounds.left
    renderNode.translationY = bounds.top
    renderNodeDirty = false
  }

If we feed different positions at each call, the RenderNode is updated successfully. It is not acceptable to use in the library, of course, but I wrote a little dirty hack to reproduce this behavour: https://github.com/gleb-skobinsky/haze/blob/main/haze/src/androidMain/kotlin/dev/chrisbanes/haze/AndroidHazeNode.kt

2024-02-29.21.47.15.mov

@gleb-skobinsky
Copy link

The video is so short because github does not accept long screen recordings :)

@gleb-skobinsky
Copy link

UPD: I managed to remove the freeze on SDK level 31 without the hacks! Just applied the translation to the setPosition method instead of translation in the record lambda. Check out the source code

@gleb-skobinsky
Copy link

It took hours to debug this...

@chrisbanes
Copy link
Owner

Great detective work @gleb-skobinsky! Send a PR over?

@gleb-skobinsky
Copy link

Yes, I will create a PR today

@gleb-skobinsky gleb-skobinsky linked a pull request Mar 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants