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)

Most upvoted comments

@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:

Can confirm tns platform update android@rc fixed the issue here. Thanks all!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/android-runtime/issues/1075#issuecomment-395138550, or mute the thread https://github.com/notifications/unsubscribe-auth/AgM3s4MfOU7F2suTQ4t2Em8A20Uoks7Sks5t6Ai6gaJpZM4UYkzZ .

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…

  • Installing tns-android Could not update the project!

On Tue, Jun 5, 2018 at 5:28 PM, Vasil Trifonov notifications@github.com wrote:

Can you try with ā€˜tns add android@rc’?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/android-runtime/issues/1075#issuecomment-394866400, or mute the thread https://github.com/notifications/unsubscribe-auth/AgM3s7V2a3CY8fOmvr__fhdK7eVgANBPks5t5vf_gaJpZM4UYkzZ .

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 runtns update rc or tns 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 either tns platform add android@rc or tns platform update android@rc. It was my mistake that at first I wrote you the wrong command tns 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:

Dear NS,

How about this…this bug is breaking production software. The solution has been posted by the OP.

Incorporate that fix and release 4.1.2.

With all due respect.

Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/android-runtime/issues/1075#issuecomment-394896296, or mute the thread https://github.com/notifications/unsubscribe-auth/AgM3s_yJEZHLm3vtjD_OWvnSpEbYiTV9ks5t5xmHgaJpZM4UYkzZ .

@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.