android: NS app crashes regularly in several different ways
Getting a few different crashes running “adb monkey” tests on my NS application
Did you verify this is a real problem by searching the [NativeScript Forum]
Yes.
Tell us about the problem
After an hour or so of running the tests I get a one of the following crashes:
System.err: com.tns.NativeScriptException: Attempt to use cleared object reference id=116786
System.err: at com.tns.Runtime.getJavaObjectByID(Runtime.java:897)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err: at com.tns.FragmentClass.onCreateView(FragmentClass.java:40)
System.err: at android.app.Fragment.performCreateView(Fragment.java:2281)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:983)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1163)
System.err: at android.app.BackStackRecord.run(BackStackRecord.java:793)
System.err: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1552)
System.err: at android.app.FragmentManagerImpl$1.run(FragmentManager.java:487)
System.err: at android.os.Handler.handleCallback(Handler.java:739)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:158)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7224)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
System.err: com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=22033
System.err: at com.tns.Runtime.getJavaObjectByID(Runtime.java:892)
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err: at com.tns.FragmentClass.onCreateView(FragmentClass.java:40)
System.err: at android.app.Fragment.performCreateView(Fragment.java:2281)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:983)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1163)
System.err: at android.app.BackStackRecord.run(BackStackRecord.java:793)
System.err: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1552)
System.err: at android.app.FragmentManagerImpl$1.run(FragmentManager.java:487)
System.err: at android.os.Handler.handleCallback(Handler.java:739)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:158)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7224)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
ActivityManager: Process com.kanayo.mymobilenative (pid 8808)(adj 0) has died(221,529)
System.err: TypeError: Cannot read property 'delete' of undefined
System.err: File: "file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/frame/fragment.transitions.js, line: 553, column: 11
System.err: StackTrace:
System.err: Frame: function:'transitionOrAnimationCompleted', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/frame/fragment.transitions.js', line: 553, column: 12
System.err: Frame: function:'TransitionListenerImpl.onTransitionEnd', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/frame/fragment.transitions.js', line: 220, column: 17
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err: at com.tns.gen.java.lang.Object_frnal_ts_helpers_l58_c38__TransitionListenerImpl.onTransitionEnd(Object_frnal_ts_helpers_l58_c38__TransitionListenerImpl.java:18)
System.err: at android.transition.Transition.end(Transition.java:1924)
System.err: at android.transition.Transition$3.onAnimationEnd(Transition.java:1875)
System.err: at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1239)
System.err: at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:766)
System.err: at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801)
System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:695)
System.err: at android.view.Choreographer.doFrame(Choreographer.java:628)
System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
System.err: at android.os.Handler.handleCallback(Handler.java:739)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:158)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7224)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
// java.lang.RuntimeException: Unable to instantiate activity java.lang.NullPointerException: Attempt to read from field 'int com.tns.Runtime.currentObjectId' on a null object reference
// at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3093)
// at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
// at android.app.ActivityThread.access$1100(ActivityThread.java:221)
// at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
// at android.os.Handler.dispatchMessage(Handler.java:102)
// at android.os.Looper.loop(Looper.java:158)
// at android.app.ActivityThread.main(ActivityThread.java:7224)
// at java.lang.reflect.Method.invoke(Native Method)
// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
// Caused by: java.lang.NullPointerException: Attempt to read from field 'int com.tns.Runtime.currentObjectId' on a null object reference
// at com.tns.Runtime.initInstance(Runtime.java:601)
// at com.tns.NativeScriptActivity.<init>(NativeScriptActivity.java:7)
// at java.lang.Class.newInstance(Native Method)
// at android.app.Instrumentation.newActivity(Instrumentation.java:1095)
// at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3083)
System.err: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
System.err: at android.view.ViewGroup.addViewInner(ViewGroup.java:4656)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4492)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4433)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4406)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1163)
System.err: at android.app.BackStackRecord.run(BackStackRecord.java:793)
System.err: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1552)
System.err: at android.app.FragmentManagerImpl$1.run(FragmentManager.java:487)
System.err: at android.os.Handler.handleCallback(Handler.java:739)
System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: at android.os.Looper.loop(Looper.java:158)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7224)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
TypeError: Cannot read property 'key' of undefined
at NSRouteReuseStrategy.shouldAttach (file:///data/data/[appname]/files/app/tns_modules/nativescript-angular/router/ns-route-reuse-strategy.js:64:55)
at ActivateRoutes.activateRoutes (file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4743:45)
at file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4715:58
at Array.forEach (native)
at ActivateRoutes.activateChildRoutes (file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4715:29)
at ActivateRoutes.activateRoutes (file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4736:22)
at file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4715:58
at Array.forEach (native)
at ActivateRoutes.activateChildRoutes (file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4715:29)
at ActivateRoutes.activate (file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4608:14)
at file:///data/data/[appname]/files/app/tns_modules/@angular/router/bundles/router.umd.js:4185:22
at SafeSubscriber._next (file:///data/data/[appname]/files/app/tns_modules/rxjs/Observable.js:224:21)
at SafeSubscriber.__tryOrSetError (file:///data/data/[appname]/files/app/tns_modules/rxjs/Subscriber.js:247:16)
at SafeSubscriber.next (file:///data/data/[appname]/files/app/tns_modules/rxjs/Subscriber.js:187:27)
at Subscriber._next (file:///data/data/[appname]/files/app/tns_modules/rxjs/Subscriber.js:125:26)
Please provide the following version numbers that your issue occurs with:
tns 3.4.2
"dependencies": {
"@angular/common": "^4.4.5",
"@angular/compiler": "^4.4.5",
"@angular/core": "^4.4.5",
"@angular/forms": "^4.4.5",
"@angular/http": "^4.4.5",
"@angular/platform-browser": "^4.4.5",
"@angular/router": "^4.4.5",
"@types/i18next": "^8.4.2",
"angular": "^1.6.6",
"bigdecimal": "^0.6.1",
"i18next": "^9.1.0",
"jsrsasign": "^8.0.4",
"moment": "2.19.1",
"nativescript-angular": "^4.4.0",
"nativescript-bcryptjs": "^1.0.1",
"nativescript-cardview": "^2.0.5",
"nativescript-checkbox": "https://github.com/gsmedley/nativescript-checkbox-dist/tarball/master",
"nativescript-floatingactionbutton": "^4.1.3",
"nativescript-local-notifications": "https://github.com/kanayo/nativescript-local-notifications/tarball/master",
"nativescript-ng2-fonticon": "^1.3.4",
"nativescript-numeric-keyboard": "^3.0.3",
"nativescript-permissions": "^1.2.3",
"nativescript-secure-storage": "2.2.1",
"nativescript-textinputlayout": "^2.0.2",
"nativescript-texttospeech": "^2.0.1",
"nativescript-theme-core": "~1.0.4",
"nativescript-toast": "1.4.6",
"nativescript-ui-chart": "^3.5.0",
"nativescript-ui-listview": "^3.5.0",
"nativescript-ui-sidedrawer": "^3.5.0",
"nativescript-unit-test-runner": "^0.3.4",
"nativescript-urlhandler": "^1.2.1",
"nativescript-uuid": "0.0.1",
"npm": "^5.7.1",
"object-assign-deep": "^0.3.1",
"reflect-metadata": "~0.1.8",
"rxjs": "~5.4.2",
"semver": "^5.5.0",
"tns-core-modules": "^3.4.0",
"tns-platform-declarations": "^3.3.0",
"zone.js": "^0.8.18"
Did the error happen while the app was executing? (runtime error)
Yes
Please tell us how to recreate the issue in as much detail as possible.
Here is the adb command I am using:
adb shell monkey -p com.kanayo.mymobilenative -c android.intent.category.LAUNCHER -v --ignore-security-exceptions --pct-touch 99 --pct-motion 0 --pct-trackball 0 --pct-syskeys 0 --pct-nav 0 --pct-majornav 0 --pct-appswitch 0 --pct-flip 0 --pct-anyevent 1 --pct-pinchzoom 0 --pct-permission 0 --throttle 2000 5000000
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (5 by maintainers)
I wasn’t happy with that try/catch either, but I think we’ve found what caused #2. The timeouts are used to update pages that show a schedule and need to be regularly updated. setInterval is called on a navigatedToEvent and cleared on a navigatedFromEvent or in ngOnDestroy, whichever comes first. There was a mistake in the clear code so some of the the timeouts kept running after the page was gone.
Since making this fix we are down to 618 as our only blocker.
@gsmedley the issues with
Seems to be fixed with the following commit: https://github.com/NativeScript/NativeScript/commit/cf950e1ebbf4fd388cd44ff4527c77c11c024525
Thanks - that worked - seeing some TNS.Java & TNS.Native output.