Chrome web view doesn't render after navigation
Reported by
ste...@selessia.com,
Mar 22 2017
|
||||||||
Issue descriptionNot sure if the Chrome web view bugs should be reported here. If not feel free to point so out. Device name: Nexus 9 Android version: Android 7.1.1, March 5, 2017 security patch level. WebView version (from system settings -> Apps -> Android System WebView): "Chrome stable" Application: https://github.com/stnor/android-webview-poc Steps to reproduce: (1) Open application, click on any link. Expected result: The page should render after navigation. (The same code works fine with Android 6 and lower). Actual result: Need to rotate device to have web view re-render, unless hardware-acceleration is changed to false in the manifest.
,
Mar 22 2017
thanks this is the correct location.
,
Mar 22 2017
attached the apk, haven't tried a nexus 9 yet, but nexus 5 running M on my desk doesn't show any issues, which matches report
,
Mar 22 2017
Thanks. I got an error report from a user that ran a different device, so I would guess any Nougat version would show the issue.
,
Mar 22 2017
I also reproduced the issue on 7.0
,
Mar 23 2017
Bo, I'm getting a crash on startup when opening the compiled app. The crash happens on n5x, n5, & n9, as well as across Android M and N with various WebView versions.
03-23 15:09:37.442 30251 30251 E AndroidRuntime: FATAL EXCEPTION: main
03-23 15:09:37.442 30251 30251 E AndroidRuntime: Process: se.nomp, PID: 30251
03-23 15:09:37.442 30251 30251 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{se.nomp/com.selessia.nomp.web.WebViewActivity}: java.lang.ClassNotFoundException: Didn't find class "com.selessia.nomp.web.WebViewActivity" on path: DexPathList[[zip file "/data/app/se.nomp-1/base.apk"],nativeLibraryDirectories=[/data/app/se.nomp-1/lib/arm64, /vendor/lib64, /system/lib64]]
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.selessia.nomp.web.WebViewActivity" on path: DexPathList[[zip file "/data/app/se.nomp-1/base.apk"],nativeLibraryDirectories=[/data/app/se.nomp-1/lib/arm64, /vendor/lib64, /system/lib64]]
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: ... 9 more
03-23 15:09:37.442 30251 30251 E AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: com.selessia.nomp.web.WebViewActivity
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.Class.classForName(Native Method)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
03-23 15:09:37.442 30251 30251 E AndroidRuntime: ... 12 more
03-23 15:09:37.442 30251 30251 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Am I missing something here? Or do you see the same crash?
,
Mar 23 2017
The crash should not happen. Probably apk related. I can build another apk if that helps. /Stefan
,
Mar 23 2017
I've deployed the attached apk build to my device successfully. ./platform-tools/adb install /Users/stnor/AndroidStudioProjects/webview-issue-poc/nomp/build/outputs/apk/nomp-debug.apk Success And it runs fint without crashing.
,
Mar 23 2017
I notice its almost twice the size of boliu's build so maybe there is an issue with that apk. This should work fine though.
,
Mar 24 2017
oh, I think the one I uploaded is a multi-apk and I uploaded only one.. Anyway. This is really odd. Seems like only the act of scrolling is updating the content of the page. Page works fine in chrome, and comparing trace of chrome and webview, both produces a single frame after clicking button to change language. Odd..
,
Mar 24 2017
I'm happy you we're able to reproduce. Weirder still is that disabling HW-accel makes the code run just fine.
,
Mar 24 2017
nah, that's not weird at all, they go in completely different paths
,
Mar 24 2017
..on Nougat, albeit slow. I would love to have some better workaround. Any ideas on how to proceed?
,
Mar 24 2017
given this is N and hardware only, I'm guessing this is somehow related to lifetime stuff. can't think of anything else that's like N-specific > I would love to have some better workaround. Any ideas on how to proceed? This is a webview bug. I guess use that workaround until there's a fix
,
Mar 24 2017
+toby for the functor stuff. can't think of anything else that's N-specific..
,
Mar 24 2017
oh, if you want to limit the workaround to N, then you can set the window flags at run time I think: https://developer.android.com/guide/topics/graphics/hardware-accel.html#controlling
,
Mar 24 2017
Ok, thanks! I'll take a look at that.
,
Mar 24 2017
This worked great:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Log.d("NompWebView", "Android 7: Disabling hardware acceleration");
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
Thanks.
,
Mar 24 2017
huh, this only happens in your app, and not in our shell, and looking at your source code, I can't explain why... so odd
,
Mar 24 2017
systrace shows android didn't call eglSwap o_O, maybe this is an android bug, not webview..
,
Mar 24 2017
+jreck: under what circumstance would hwui call functor with kModeDraw, but not call eglSwapBuffers afterward that? Trivial to reproduce this on N with apk in #8 above. Attached systrace. This would be the first DrawFrame on render thread. Note this is a public bug.
,
Mar 24 2017
The only reason we wouldn't call eglSwapBuffers after a kModeDraw is if we think nothing in the frame actually drew, which would be weird. Looking at HWUI's source, though, it looks like mHasDrawn doesn't get marked true when we hit webview's GL functor (oops). Skimming through the app's source if you remove the android:windowBackground="@null" from the FullscreenTheme does it then work fine? Or if instead of setLayerType(LAYER_TYPE_SOFTWARE) you do setLayerType(LAYER_TYPE_HARDWARE), does that work? If my theory is correct you just need to draw a single thing in the activity that's not a webview and then everything should work fine on N. A 1x1 rectangle at 0,0 would even work I think. If so the best workaround would be to either add a view that draws a dummy 1x1 rect to the base of your activity or subclass from webview, override onDraw() and draw a 1x1 rect before calling super.onDraw() for webview to cover it up with the actual contents.
,
Mar 25 2017
I removed "<item name="android:windowBackground">@null</item>" and that make it work fine!
,
Mar 25 2017
Setting LAYER_TYPE_HARDWARE on the webview also solves the problem independently. I wasn't expecting the layer type to be LAYER_TYPE_NONE since the android:hardwareAccelerated="true"...
,
Mar 25 2017
I'd recommend going with just removing the setting of windowBackground to @null, then. @null window backgrounds in the theme cause other subtle issues so it's better to just eliminate that. You don't want to use LAYER_TYPE_HARDWARE or LAYER_TYPE_SOFTWARE as a workaround usually, it hurts performance too much.
,
Mar 25 2017
Ok, will do. Thanks.
,
Mar 27 2017
John, is the mHasDrawn issue with the GL functor a bug we need to fix on the android side?
,
Mar 27 2017
Proper fix will in be android (b/36602041). But we'll land a workaround in webview for N
,
Mar 27 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/340c180766d2857dab1a5a8a15df5c8e0c054f43 commit 340c180766d2857dab1a5a8a15df5c8e0c054f43 Author: boliu <boliu@chromium.org> Date: Mon Mar 27 22:22:21 2017 android: Workaround libhwui N bug Bug is that if functor is the only operation in a canvas, then that draw will not swap. Workaround it by always painting a 1x1 pixel. BUG= 704212 Review-Url: https://codereview.chromium.org/2779773002 Cr-Commit-Position: refs/heads/master@{#459906} [modify] https://crrev.com/340c180766d2857dab1a5a8a15df5c8e0c054f43/android_webview/java/src/org/chromium/android_webview/AwContents.java
,
Apr 1 2017
,
Apr 1 2017
Your change meets the bar and is auto-approved for M58. Please go ahead and merge the CL to branch 3029 manually. Please contact milestone owner if you have questions. Owners: amineer@(Android), cmasso@(iOS), bhthompson@(ChromeOS), govind@(Desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 3 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/451519fbb93ebf4c995e0fe0eb46890ff8252b5d commit 451519fbb93ebf4c995e0fe0eb46890ff8252b5d Author: Bo Liu <boliu@chromium.org> Date: Mon Apr 03 13:16:49 2017 [Merge m58] android: Workaround libhwui N bug Bug is that if functor is the only operation in a canvas, then that draw will not swap. Workaround it by always painting a 1x1 pixel. BUG= 704212 Review-Url: https://codereview.chromium.org/2779773002 Cr-Commit-Position: refs/heads/master@{#459906} (cherry picked from commit 340c180766d2857dab1a5a8a15df5c8e0c054f43) Review-Url: https://codereview.chromium.org/2790123002 . Cr-Commit-Position: refs/branch-heads/3029@{#542} Cr-Branched-From: 939b32ee5ba05c396eef3fd992822fcca9a2e262-refs/heads/master@{#454471} [modify] https://crrev.com/451519fbb93ebf4c995e0fe0eb46890ff8252b5d/android_webview/java/src/org/chromium/android_webview/AwContents.java
,
Apr 3 2017
,
Apr 4 2017
Fix verified on Nexus6P/Android 7.1.2, Monochrome: 59.0.3062.3.
,
Apr 5 2017
Verified on devices Nexus 9(MOB31V), Nexus 6(N2G47S)and LG V20(NRD90M) with 58.0.3029.54 , issue mentioned no longer reproducible.Thanks |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by ste...@selessia.com
, Mar 22 2017