Blur disappears when navigating away from and back to view in 1.6.3
See original GitHub issuePlease include:
- Library version: 1.6.3. Issue not present in 1.6.2.
- Device and OS version: Android Oreo
- Detailed steps to reproduce the issue: Create a BlurView, navigate away from the screen and back to it again, blur disappears.
Hi, this lib is still unmatched imo so thank you. I just thought you’d like to know, I have a very basic implementation of a BlurView that mistakenly clears itself if you navigate away from the screen with the view and come back to it. The issue is not there in 1.6.2 and below:
binding.welcomeTitleBlurView.setupWith(binding.welcomeBlurContainer)
.setBlurAlgorithm(RenderScriptBlur(activity))
.setBlurRadius(2F)
.setHasFixedTransformationMatrix(true)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
binding.welcomeTitleBlurView.outlineProvider = ViewOutlineProvider.BACKGROUND
binding.welcomeTitleBlurView.clipToOutline = true
}
I am blurring in a Fragment’s onCreateView. I noticed if I add a delay of 100ms it successfully blurs when it navigates back, and just in case I made sure to try and perform the blur after it has been laid out using:
inline fun View.afterMeasured(crossinline f: View.() -> Unit) {
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
if (measuredWidth > 0 && measuredHeight > 0) {
viewTreeObserver.removeOnGlobalLayoutListener(this)
f()
}
}
})
}
So something has changed regarding lifecycle callbacks, or threading or something, not sure which.
Also, I noticed the blurring algorithm seems to stretch or magnify the blurred image differently in the setup I have in 1.6.2 / 1.6.3, whereas from 1.5.0->1.6.1 it is different. My view happens to be a relatively narrow, long view on a 7 inch landscape screen. I think 1.6.1 looks more accurate and doesn’t exhibit the disappearing blur behavior in 1.6.3, so will stick with that for the moment.
Here is 1.6.1 with a blur radius of 2:
Here is 1.6.2 with a blur radius of 2:
1.6.2 with an increased blur radius of 8 is better:
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
Honestly, I got too lazy to get it fixed without any hacks, so if that’s working for you, let it stay for now 😃
Thank you for the detailed report. As for the disappearing blur, I guess it’s related to this https://github.com/Dimezis/BlurView/issues/89. There was a small change, posting of some callbacks was removed, and seems like it introduced this bug instead. That’s why your postponing workaround seems to fix it.
Regarding the stretching, I believe it’s related to a change in https://github.com/Dimezis/BlurView/releases/tag/version-1.6.2, I’ve increased the rounding value to 64 to significantly improve the performance on Samsung devices. But apparently I forgot to scale the Y dimension accordingly.
Both should be fixable, but can’t say for sure when I’ll be able to do it