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 disappears when navigating away from and back to view in 1.6.3 #117

Closed
danielwilson1702 opened this issue Jul 6, 2020 · 10 comments
Closed

Comments

@danielwilson1702
Copy link
Contributor

Please include:

  1. Library version: 1.6.3. Issue not present in 1.6.2.
  2. Device and OS version: Android Oreo
  3. 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:
image

Here is 1.6.2 with a blur radius of 2:
image

1.6.2 with an increased blur radius of 8 is better:
image

@Dimezis
Copy link
Owner

Dimezis commented Jul 6, 2020

Thank you for the detailed report.
As for the disappearing blur, I guess it's related to this #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

@danielwilson1702
Copy link
Contributor Author

Nice one thank you yes it took me a little while to figure out the issue was the version change. I think 1.6.1 will be fine for me for the moment and will keep an eye out for any updates if you or anyone else has time so thanks!

@Dimezis
Copy link
Owner

Dimezis commented Aug 8, 2020

@danielwilson1702 hey, could you please check if these issues are fixed for you on this branch?
https://github.com/Dimezis/BlurView/tree/scaling_refactoring

@Dimezis
Copy link
Owner

Dimezis commented Aug 18, 2020

I released 1.6.4 with a fix, please check if it works for you

@danielwilson1702
Copy link
Contributor Author

danielwilson1702 commented Aug 21, 2020

Hi @Dimezis sorry for the delay, I tried 1.6.4 and now no blur 😕 (at all I mean, even when first drawing the fragment)

@Dimezis
Copy link
Owner

Dimezis commented Aug 21, 2020

Maybe you could make a repo with a simple setup to replicate it?
I'll take this version down later today

@Dimezis
Copy link
Owner

Dimezis commented Aug 22, 2020

Alright, nvm, managed to reproduce it. Will make a fix soon'ish

@Dimezis
Copy link
Owner

Dimezis commented Sep 2, 2020

@danielwilson1702 by the way, does the blur appear if you manually call setBlurAutoUpdate(true) during the setup?

@danielwilson1702
Copy link
Contributor Author

Sorry I forget to come back to you, setBlurAutoUpdate(true) does indeed fix 1.6.4, so I guess it's not a problem any longer then?

@Dimezis
Copy link
Owner

Dimezis commented Nov 2, 2020

Honestly, I got too lazy to get it fixed without any hacks, so if that's working for you, let it stay for now :)

@Dimezis Dimezis closed this as completed Jan 26, 2021
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