Webview glitches in shared element transition on lollipop
S

2

5

I've just started to rebuild my app for Android 5.0, using the appcompat support library. I've just finished implementing a transition featuring shared elements. It seems to work well, untill I add a webview.

I've made a video to demonstrate the glitch. https://www.youtube.com/watch?v=MuuGZc0Vwow

As you can see, all's fine when I open the activity. When I close it, the glitch occurs. As you can see all elements fade out like they should, except for the webview. Which just hangs there until the animation is over, kinda ruining the entire smoothness of the animation.

How do I fix this? If it could be related to the way I've set things up I'd be happy to share some code.

Thanks in advance.

Sear answered 5/12, 2014 at 13:32 Comment(7)
This is only a guess, but try calling webview.setTransitionGroup(true) in your second activity's onCreate() method.Romano
That causes a crash :( 12-05 23:47:42.372: E/AndroidRuntime(9599): java.lang.IllegalStateException: Unable to create layer for WebViewSear
Can you post the full stack trace?Romano
To be honest, I'm a little confused, since it seems to be behaving really inconsistently right now. Anyways, here's the stacktrace: pastebin.com/viv5nsgvSear
Does it happen as a result of calling setTransitionGroup()? Or does it happen when you start the activity transition?Romano
Here's another error I get. I have no clue what decides when this happens or the previous one: pastebin.com/qkkgPdM7 When I remove the setTransitionGroup(), there's no crash.Sear
Hopefully George Mount will see this question and give some insight on why the crash occurs... it seems like a problem with Android's internal graphics pipeline though, not Android's transition framework.Romano
R
7

The reason why this glitch occurs is because WebView extends AbsoluteLayout. By default ViewGroups that are not "transition group"s and that have no background drawable will not be animated by the activity's window content transition. In order to fix the glitch with the WebView, you will need to call webView.setTransitionGroup(true) (or set the attribute in XML using android:transitionGroup="true"). This should cause the WebView to fade away as part of the activity transition instead of simply sitting there until being abruptly removed at the end of the transition.

As for the "Unable to create layer for WebView" error you are receiving, I imagine that is because the transition framework automatically creates a hardware layer for the WebView during the transition and for some reason the framework is crashing when it is trying to create the layer. This sounds like a totally separate issue related to Android's internal graphic pipeline though... I'm not sure I can give you a good answer about why the crash occurs without more information.

This issue is also discussed in the bottom of this blog post.

Romano answered 5/12, 2014 at 23:15 Comment(2)
Ok, thanks for taking the time to explain things. The XML attribute and the java statement both result in the same crash. But like I said, it's inconsistent and I don't get it. At one point, I've seen it work, but 9/10 times it's a random crash. A video to further illustrate: youtube.com/watch?v=HLfgwaeJXDcSear
By moving the android:transitionGroup from the WebView to it's parent element the crash and the glitch are now both gone. I am still not 100% sure what happened, but thanks for taking the time to explain and point me in the right direction!Sear
E
0

I have facing exactly this kind of random crash problem in webview in Marshmallow version. I have add attribute android:transitionGroup="true". but crash is happening, after that i have added android:hardwareAccelerated="false" in manifest where that activity is declared. After that random crash has solved in Marshmallow version and lower version too.

Elwandaelwee answered 14/2, 2017 at 12:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.