Closed saschaarthur closed 6 months ago
anyone? :(
Those crashes are still happening randomly. It is the most frequent crash we can obersve both in the Google Play Console and Crashlytics.
Can anybody provide any insights or clues on how to address the issue?
Current environment:
node: 16.15.0
npm: 8.13.1
nativescript: 8.2.3
# android
java: 11.0.14.1
ndk: Not Found
apis: 29, 30, 31, 32
build_tools: 29.0.2, 30.0.3, 31.0.0
system_images:
- android-29 | Google APIs Intel x86 Atom
- android-29 | Google Play Intel x86 Atom
- android-30 | Google APIs Intel x86 Atom
- android-30 | Google Play Intel x86 Atom
- android-31 | Google APIs Intel x86 Atom_64
- android-32 | Google Play Intel x86 Atom_64
"dependencies": {
"@angular/animations": "~13.3.11",
"@angular/common": "~13.3.11",
"@angular/compiler": "~13.3.11",
"@angular/core": "~13.3.11",
"@angular/forms": "~13.3.11",
"@angular/platform-browser": "~13.3.11",
"@angular/platform-browser-dynamic": "~13.3.11",
"@angular/router": "~13.3.11",
"@nativescript-community/ui-collectionview": "~4.0.52",
"@nativescript-community/ui-material-activityindicator": "6.2.14",
"@nativescript-community/ui-material-bottomsheet": "6.2.14",
"@nativescript-community/ui-material-tabs": "6.2.14",
"@nativescript-community/ui-pulltorefresh": "~2.5.1",
"@nativescript/angular": "13.0.4",
"@nativescript/core": "~8.2.5",
"@nativescript/firebase-core": "~2.1.0",
"@nativescript/firebase-crashlytics": "~2.1.0",
"@nativescript/firebase-messaging": "~2.1.0",
"@nativescript/iqkeyboardmanager": "~2.0.0",
"@nativescript/local-notifications": "~6.0.0",
"@nativescript/secure-storage": "~3.0.0",
"@nativescript/theme": "~3.0.2",
"@nota/nativescript-webview-ext": "~8.0.2",
"@nstudio/nativescript-barcodescanner": "~5.0.1",
"@nstudio/nativescript-snackbar": "~2.1.0",
"@triniwiz/nativescript-image-cache-it": "~7.0.15",
"nativescript-clipboard": "~2.1.1",
"nativescript-ui-listview": "~10.1.1",
"rxjs": "~7.5.4",
"zone.js": "0.11.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.8",
"@angular/cli": "~13.3.8",
"@angular/compiler-cli": "~13.3.11",
[...]
"@nativescript/android": "~8.2.4",
"@nativescript/ios": "~6.5.5",
"@nativescript/types": "~8.2.0",
"@nativescript/unit-test-runner": "~3.0.4",
"@nativescript/webpack": "~5.0.6",
"@ngtools/webpack": "~13.3.8",
[...]
"patch-package": "~6.4.7",
"typescript": "~4.6.4"
}
@jessorlisa this is a gc issue, seems like the java ref is still around but the runtime already removed the instance kept. I believe updating the plugin to keep instances around & proper usage of WeakRef
will fix this issue
@triniwiz thanks for the insights. Thats what i guessed as well.
I would have a deeper look. But sadly its unclear for me where to start.. this code seems to be platform/sdk dependend generated code and not "simple" source code, which would be easy to fix.
Any hints where we could start digging deeper?
I also can see quite a high number of crashes in Google Play Console, that look similar to this:
Cannot find runtime for instance=android.net.ConnectivityManager_NetworkCallback_vendor_38342_42_NetworkCallbackImpl@6a3a5a9 at com.tns.Runtime.callJSMethodImpl (Runtime.java:1181) at com.tns.Runtime.callJSMethod (Runtime.java:1175) at com.tns.Runtime.callJSMethod (Runtime.java:1153) at com.tns.Runtime.callJSMethod (Runtime.java:1149) at android.net.ConnectivityManager_NetworkCallback_vendor_38342_42_NetworkCallbackImpl.onAvailable at android.net.ConnectivityManager$NetworkCallback.onAvailable (ConnectivityManager.java:3725) at android.net.ConnectivityManager$NetworkCallback.onAvailable (ConnectivityManager.java:3707) at android.net.ConnectivityManager$CallbackHandler.handleMessage (ConnectivityManager.java:4031) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loopOnce (Looper.java:226) at android.os.Looper.loop (Looper.java:313) at android.os.HandlerThread.run (HandlerThread.java:67)
See https://github.com/NativeScript/NativeScript/issues/10002
@jessorlisa @felixkrautschuk I think your errors are not related (not directly). I think they both comes from unreleased objects but not the same.
@felixkrautschuk i commented on your error. @jessorlisa i think your error comes from the fact that setWebViewClient
is not called with null
on disposeNativeView
. Is there any chance you can try ?
EDIT: you can try the change i applied in my fork here https://github.com/Akylas/NativeScript/commit/dad92a4d7e713ab6a79229b4c7f65d1d9508f0a0. If someone can confirm it fixes it i'll create a PR
@farfromrefug We also see this in our app, but we use the ui-webview module (version 1.3.5). We get the following traceback:
com.tns.NativeScriptException: Cannot find runtime for instance=com.tns.gen.android.webkit.WebViewClient_vendor_2_84540_WebViewExtClientImpl@95626cb
at com.tns.Runtime.callJSMethod(Runtime.java:1172)
at com.tns.Runtime.callJSMethod(Runtime.java:1153)
at com.tns.Runtime.callJSMethod(Runtime.java:1149)
at com.tns.gen.android.webkit.WebViewClient_vendor_2_84540_WebViewExtClientImpl.shouldInterceptRequest(WebViewClient_vendor_2_84540_WebViewExtClientImpl.java:67)
at Ba.a(chromium-TrichromeWebViewGoogle.aab-stable-511209733:223)
at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative(chromium-TrichromeWebViewGoogle.aab-stable-511209733:34)
I believe that ui-webview already calls setWebviewClient(null)
. Do you still think that your fix might also fix our issue? I would try it in a new app release then.
@cdroege not good. is there any chance you can reproduce the bug with N Trace.enable()
with all catégories?
I could not reproduce this problem on my own devices yet. I see that about 2-4% of our Android user base had this problem once in about 2 weeks, so it could take a while until I see this issue myself.
When I look at the breadcrumbs and the other data from Sentry, there is also no obvious condition that triggers this issue. Sometimes the current activity in our app is resumed and the issue is triggered directly, but sometimes this issue also happens during the usage of the webview (a user scrolls down, scrolls then up and after a few seconds interacts with the webview again and the app crashes). It also happens with a lot of different Android versions (9-12).
It's a tough one to recreate, but it's usually a gc issue. Proper use of weakrefs for callbacks/listeners can help prevent these kind of issues
@jessorlisa i think your error comes from the fact that
setWebViewClient
is not called withnull
ondisposeNativeView
. Is there any chance you can try ?
@farfromrefug I will try your suggestion immediately and keep you posted! Sorry for the late reply, I was on vacation 🤷🏻♀️.
@farfromrefug Unfortunately the error is still occuring, despite the suggested patch (I also patched our version of @nota/nativescript-webview-ext accordingly).
Sorry for my late feedback, Google's review process is taking forever this days.
@jessorlisa do you have logs (like logcat) of whats happening before that? If google does not provide them maybe it would be agood idea to integrate sentry. With it you would have a crash with logs of what happened before the crash (like app closing or in background for example). Sorry it is a tough one to debug
do you have logs (like logcat) of whats happening before that?
I am afraid no. I will give it a try and see if I can reproduce it locally. Sentry is not an option right now.
Seen this today for first time. Might be related or the same issue:
chromium: [WARNING:spdy_session.cc(3484)] Received HEADERS for invalid stream 1
System.err: An uncaught Exception occurred on "main" thread.
System.err: Cannot find object id for instance=com.tns.gen.android.webkit.WebViewClient_vendor_4531_26_WebViewExtClientImpl@8c285fa
System.err:
System.err: StackTrace:
System.err: com.tns.NativeScriptException: Cannot find object id for instance=com.tns.gen.android.webkit.WebViewClient_vendor_4531_26_WebViewExtClientImpl@8c285fa
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1181)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149)
System.err: at com.tns.gen.android.webkit.WebViewClient_vendor_4531_26_WebViewExtClientImpl.shouldInterceptRequest(WebViewClient_vendor_4531_26_WebViewExtClientImpl.java:67)
System.err: at Z9.a(chromium-TrichromeWebViewGoogle.aab-stable-556311633:80)
System.err: at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative(chromium-TrichromeWebViewGoogle.aab-stable-556311633:15)
device: galaxyS9+, Android 10
package.json:
"@nativescript-community/ui-webview": "^1.4.3",
"@nativescript/angular": "^14.0.0",
"@nativescript/core": "~8.4.7",
"@nativescript/android": "~8.4.0",
cannot reproduce though.
Receiving this same error, when uploading a test build to google play it highlights the issue for this specific device on SDK 31... not sure if helps, not sure where to start...
Exception com.tns.NativeScriptException: Cannot find runtime for instance=com.tns.gen.android.webkit.WebViewClient_vendor_2_782072_WebViewExtClientImpl@c809ccc
at com.tns.Runtime.callJSMethod (Runtime.java:1172)
at com.tns.Runtime.callJSMethod (Runtime.java:1153)
at com.tns.Runtime.callJSMethod (Runtime.java:1149)
at com.tns.gen.android.webkit.WebViewClient_vendor_2_782072_WebViewExtClientImpl.shouldInterceptRequest (WebViewClient_vendor_2_782072_WebViewExtClientImpl.java:67)
at A8.a (chromium-TrichromeWebViewGoogle.apk-stable-447211483:15)
at org.chromium.android_webview.AwContentsBackgroundThreadClient.shouldInterceptRequestFromNative (chromium-TrichromeWebViewGoogle.apk-stable-447211483:2)
We've been encountering these crash reports for years now, yet we've never been able to pinpoint the root cause for the missing runtime. Any tips would be greatly appreciated.
As a test, I've removed the shouldInterceptRequest
overwrite in the WebView plugins (we've since switched to @nativescript-community/ui-webview). As far as I understand, we don't need this as long as we're not loading local CSS/HTML/JS files for our WebView. Since then, the crashes haven't occurred, and there have been no user complaints (so far). Let's hope for the best. ;)
Therefore, we are closing the ticket—although it would still be interesting to know what caused the crashes.
@jessorlisa very interesting ! you removed it from @nativescript-community/ui-webview ?
@farfromrefug Exactly.
seems solved, thanks to @jessorlisa !
Environment Ubuntu 20.04 LTS Node.js v14.17.0 Nativescript CLI 7.2.1 Android SDK 30.0.3
package.json
MinSDK 23
To Reproduce Not possible
Expected behavior Should not crash
Sample project Not possible
Describe the bug Started to use the beatiful webview with @nota for more and more things. Sadly im currently fighting with crashes reaching firebase:
Looking at the stack, it seems that the android application is crashing cause of a missing java/script reference.
Sadly im not even sure whos responsible for the crash, thats why i created it here. Is the bug in chromium,@nota or in tns-core?
I tried to look deeper into the cause of this problem. Looking at https://developer.android.com/reference/android/webkit/ServiceWorkerClient i saw plenty of changes in SDK 24, so i tried to raise minSDK to 24, which sadly didnt solve the issue.
Also i dont completly understand exactly when and how this "com.tns.gen.android.webkit.WebViewClient_vendor" is generated. Sometimes (at least on my windows machine) theres multiple of this classes in platforms\android\app\src\main\java\com\tns\gen\android\webkit even with different (version=$1? and sdk=$2?) WebViewClientvendor$1_$2 parameters.
Anyone can point me in the right direction what could cause this crashes and how to patch them?