CameraKit / blurkit-android

The missing Android blurring library. Fast blur-behind layout that parallels iOS.
MIT License
3.72k stars 309 forks source link

BlurLayout seems to cause fragment transition animations to stop working #6

Closed bensandee closed 5 years ago

bensandee commented 7 years ago

I discovered a problem where if I use this layout in a fragment's layout, after the BlurLayout is first shown, future fragment manager transition animations no longer are shown. Simply commenting out the BlurLayout component causes transitions again function as expected. I will try to put this into a sample project and attach here to demonstrate when I have time.

dwillmc commented 7 years ago

I'll look into this asap. If make a fork that demonstrates the issue that'll definitely help.

bensandee commented 7 years ago

Check out this commit for a quickly hacked together sample. On my device (Nvidia Shield, 6.0.1), the fragment's slide-in animation only plays once or twice and then starts to fail. For some reason the slide out works, for awhile anyways. In my larger app test all animations for all fragments stop working.

https://github.com/tbsandee/blurkit-android/commit/dfec2ff8423d64e53045edb5d7f45dfd0c37d3ac

bensandee commented 7 years ago

One red flag that didn't pan out was possibly the activity/view context leaking into the Renderscript init method. I cleaned that up a bit here https://github.com/tbsandee/blurkit-android/commit/0bbe9e2c420a0573c4a414d74937c564b91323e4 but it didn't fix the issue.

bensandee commented 7 years ago

FWIW, I merged up to your master branch and tried it on my Nexus 5x (7.1.1 dev preview 2) and saw the same behavior. Nothing in the adb log that indicates anything is going wrong. I really do dislike fragments.

dwillmc commented 7 years ago

@tbsandee lol same but they're necessary so this is pretty high priority. In master I've added some useful new methods:

lockView(), unlockView() - Stops re-retrieving the view bitmap each time when locked and will re-use, unlocking will start regenerating again

lockPosition(), unlockPosition() - Stops re-retrieving the view relative point each time when locked and will re-use, unlocking will start regenerating again

And another contributor added the startBlur() and pauseBlur() methods which are pretty self explanatory.

It's a shot in the dark, but playing with locking/unlocking and starting/pausing before and after the fragment transition might reveal something.

I'll have a chance to look into this in-depth on Thursday.

bensandee commented 7 years ago

Thanks for looking into this.

I've updated the sample in my fork. I'm animating the fragment in by sliding it up from the bottom; the fragment has the BlurLayout in it's layout and it's blurring the activity code underneath.

Within the fragment, I call pauseBlur() in onViewCreated(), then in onResume() I make a delayed call to startBlur() after I know the transition animation is complete. Immediately following that call I post a call to lockView(). Following these steps I haven't seen the fragment animations break. However, the slide in from the bottom doesn't have a blurred state until it's started after the animation completes. I could maybe simulate a temporary blurred look with some semi-transparent background and it might not look that bad.

I think you're onto the root cause -- the simultaneous nature of the fragment transitions and the blurring renderscript seem to conflict somehow.

amanzan commented 7 years ago

I think I'm having a similar issue. I have a fragment with a blurred toolbar. When I switch to a different fragment (with no blur effect) my toolbar disappear when scrolling (as intended) but then it does not come back as it should. The blur library causes the issue because I removed it and the problem is gone. In both I have CoordinatorLayout + AppBarLayout + Toolbar with app:layout_scrollFlags="scroll|enterAlways"

If I can do anything to help fixing this issue, please let me know!

amanzan commented 7 years ago

Just as a comment, I fixed my issue with the method pauseBlur() in this closed PR:

https://github.com/flurgle/BlurKit-Android/pull/2

emersoncloud commented 5 years ago

Closing ticket. If fragmentation issues remain we will be sure to revisit this.