android: Webview Crash With Android 8.1.0 / Chromium 67.0.3396.68
Did you verify this is a real problem by searching the NativeScript Forum https://discourse.nativescript.org/t/webview-causes-app-crash-on-android-with-chrome-67-release/6202
Tell us about the problem With the latest chrome (67.0.3396.68) update on Android 8.1.0 webview is crashing.
Please provide the following version numbers that your issue occurs with:
- CLI: 3.4.2
- tns-android: 3.4.2
- Android: 8.1.0
- Chromium: 67.0.3396.68
After further debugging, Invoking of onReceivedError on webviewclient is causing the null pointer exception in Runtime.java (https://github.com/NativeScript/android-runtime/blob/v3.4.2/test-app/runtime/src/main/java/com/tns/Runtime.java), Line number 682: (String pname = p.getName()š
After the chrome update on the device, the 2nd(android.webkit.WebResourceRequest) and 3rd (android.webkit.WebResourceError) parameters of function onReceivedError of WebViewClient received object whose class is having empty package. This causes line 679 of https://github.com/NativeScript/android-runtime/blob/v3.4.2/test-app/runtime/src/main/java/com/tns/Runtime.java [clazz.getPackage();] to return null. And subsequently this causes null pointer exception on line 682 of same file [ String pname = p.getName(); ] .
Printing the class names inside the function getTypeMetadata, with latest chrome as webview, gives class vS, class vR.
But in the device if I select to use android webview instead of chrome webview, it gives class as com.android.webview.chromium.xz, com.android.webview.chromium.WL.
So essentially the function getTypeMetadata is not handling classes with empty packages. So instaed of:
Package p = (mostOuterClass != null)
? mostOuterClass.getPackage()
: clazz.getPackage();
int packageCount = 1;
String pname = p.getName();
changing to:
Package p = (mostOuterClass != null)
? mostOuterClass.getPackage()
: clazz.getPackage();
int packageCount = p != null ? 1 : 0;
String pname = p != null ? p.getName() : "";
This seems to be fixing the issue.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 51 (11 by maintainers)
@vtrifonov Will you apply the fix to NS 3.4.2 as well? How can we get this fix and apply this patch? We have several thousand users unable to use our apps due to this issue.
If {N} wants to be used for enterprise level applications issues like these need to be prevented in the future. When issues like these arise it makes me reconsider the choice of {N} vs. pure native development.
I enjoy working with {N} so I hope that {N} team will learn from this and prevent issues like these in the future from occurring.
@lsowmya you need to upgrade either to tns-android 3.4.3 or tns-android 4.1.3 or later where the issue is fixed.
@vtrifonov @vhristov5555 It will be helpful if you can create a patch release for 3.4.2 as well.
No need to do: tns platform update android@rc
Just run:
tns update
as new version 4.1.2 has been released early this morning
On Wed, Jun 6, 2018 at 12:52 PM, Jeff Switzer notifications@github.com wrote:
The issue is fixed and released in tns-android@4.1.2 version.
I tried:
tns add android@rc Unknown command āaddā. Use ātns helpā for help. Did you mean? update
then I ran:
tns update android@rc Gradle build⦠Platform android successfully removed. Successfully removed plugin tns-core-modules Successfully removed plugin tns-core-modules-widgets Copying template filesā¦
On Tue, Jun 5, 2018 at 5:28 PM, Vasil Trifonov notifications@github.com wrote:
+1
Also would like to thank @sud80 for migrating our forum concern into a github issue with much more detail. Weāre new to this platform and appreciate the support.
@mspusta78 Did you run
tns update rcortns update @rc. The second one should have thrown an error and no changes will be made in you project. If you want to update just the android runtime to its latest version you need to run eithertns platform add android@rcortns platform update android@rc. It was my mistake that at first I wrote you the wrong commandtns add android@rc, but Iāve updated it to the right command 2 minutes after that so maybe you were looking at my original post. However we are going to release official version in a while and you will be able to update to the latest official 4.1.2 version.I agree. The solution to this issue was posted within hours of discovery and now we are 3 days into this and still no fix. {N} team, you need to understand that this impacts production software. Our clients are being impacted and revenue is being lost.
If {N} wants to survive and claim to be an enterprise level software solution issues like these must be considered as PRIORITY #1.
Please post the fix.
Thanks,
Martin
On Tue, Jun 5, 2018 at 7:51 PM, erjdriver notifications@github.com wrote:
@vtrifonov correct. Iāll be upgrading all my projects to 4.1 today
Thanks for reporting and looking into this @sud80. Iāve applied the proposed changes and itās now on PR. Weāll create a patch for this as long as itās ready.
Meanwhile hereās how you can easily debug the android runtime in your own project.
You can āuninstallā Chrome to fix the issue. It will downgrade Chrome to the factory version, but it fixes the problem until we have the NS fix.
@mspusta78, only unsafe methods as far as I know, you have to get the old APK and manually install it.