Closed gsmedley closed 6 years ago
@gsmedley logs are all good, but a reproduction repository would be better, as we'd be able to test locally. Otherwise we can mostly just guess what happens and where. Also, you could reduce the monkey arguments to only those which may be causing the crash.
@Pip3r4o - Thanks for the quick reply!
Unfortunately I can't share the app as it relies on a private server to run.
The test parameters just:
I am going to add some logging to see if I can isolate which pages the crashes happen on.
Is there any other internal logging I could enable?
And another one:
I see there is a fix in the works for this one and a workaround:
System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
System.err: at com.tns.gen.java.lang.Object_frnal_ts_helpers_l58_c38__EditTextListenersImpl.onEditorAction(Object_frnal_ts_helpers_l58_c38__EditTextListenersImpl.java:45)
System.err: at android.widget.TextView.onEditorAction(TextView.java:5491)
System.err: at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:139)
System.err: at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:304)
System.err: at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
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)
And yet another one:
See #974
System.err: android.content.res.Resources$NotFoundException: Resource ID #0xffffffec
System.err: at android.content.res.Resources.getValue(Resources.java:2558)
System.err: at android.content.res.Resources.loadXmlResourceParser(Resources.java:4360)
System.err: at android.content.res.Resources.getAnimation(Resources.java:2396)
System.err: at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:122)
System.err: at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:103)
System.err: at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:88)
System.err: at android.app.FragmentManagerImpl.loadAnimator(FragmentManager.java:831)
System.err: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
System.err: at android.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1270)
System.err: at android.app.BackStackRecord.run(BackStackRecord.java:744)
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)
Hi @gsmedley
On your question: "Is there any other internal logging I could enable?"
You can add __enableVerboseLogging()
early in your javascript. If you do, you'll see the android-runtime's debug log.
declare function __enableVerboseLogging()
__enableVerboseLogging()
That's the way you do it in typescript.
Thanks - that worked - seeing some TNS.Java & TNS.Native output.
For completeness, I'm going to add the different stack traces I find
An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: Attempt to use cleared object reference id=129237
at com.tns.Runtime.getJavaObjectByID(Runtime.java:897)
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
at com.tns.Runtime.callJSMethod(Runtime.java:957)
at com.tns.Runtime.callJSMethod(Runtime.java:941)
at com.tns.Runtime.callJSMethod(Runtime.java:933)
at com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
This is somewhat related: https://github.com/NativeScript/android-runtime/issues/887
@gsmedley Any chance the "Attempt to use cleared object reference" errors to have a JavaScript call stack in the log?
@pana-cc I did get a JS stack trace in my most recent test, after setting __enableVerboseLogging()
, perhaps? It pointed toward a page update in a JS setInterval() after the View was gone. I'm clearing the interval in ngOnDestroy(), but maybe that's too late? It happens pretty infrequently so maybe related to memory management having happened at an inopportune time. A lot of conjecture there.
I've added more logging and started another test but It sometimes takes a day or so of robo-testing to make any error happen. I'll keep posting updates to this issue.
By the way, I want express my appreciation to all of the NS folks who've been helping me out with this.
Here is the stack trace with JS:
04-05 16:08:41.614 8007 8007 D TNS.Native: StackTrace:
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 424, column: 49
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 456, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 699, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 455, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 456, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 699, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 455, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 456, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 699, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 455, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 456, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 699, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 455, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 456, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ContentView.eachChildView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 699, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 455, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._addViewCore', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 357, column: 18
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewBase._addView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 346, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'LayoutBaseCommon.addChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 44, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewUtil.insertToLayout', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/view-util.js', line: 92, column: 20
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewUtil.addToVisualTree', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/view-util.js', line: 73, column: 18
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewUtil.insertChild', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/view-util.js', line: 41, column: 18
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'NativeScriptRenderer.insertBefore', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/renderer.js', line: 79, column: 23
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'DebugRenderer2.insertBefore', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 13654, column: 23
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'execRenderNodeAction', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 8930, column: 22
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'visitRenderNode', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 8901, column: 13
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'visitSiblingRenderNodes', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 8832, column: 13
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'visitRootRenderNodes', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 8816, column: 5
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'renderAttachEmbeddedView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 9760, column: 5
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'attachEmbeddedView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 9640, column: 5
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewContainerRef_.insert', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 10106, column: 9
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewContainerRef_.createEmbeddedView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 10074, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/common/bundles/common.umd.js', line: 1740, column: 66
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'DefaultIterableDiffer.forEachOperation', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 6813, column: 17
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'NgForOf._applyChanges', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/common/bundles/common.umd.js', line: 1738, column: 17
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'NgForOf.ngDoCheck', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/common/bundles/common.umd.js', line: 1728, column: 22
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'checkAndUpdateDirectiveInline', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 10878, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'checkAndUpdateNodeInline', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 12373, column: 20
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'checkAndUpdateNode', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 12316, column: 16
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'debugCheckAndUpdateNode', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 13173, column: 59
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'debugCheckDirectivesFn', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 13114, column: 13
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'View_ScheduleGroupPartial_0._co', file:'', line: 29, column: 5
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'debugUpdateDirectives', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 13099, column: 21
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'checkAndUpdateView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 12283, column: 14
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'callViewAction', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 12631, column: 21
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'execComponentViewsAction', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 12563, column: 13
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'checkAndUpdateView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 12289, column: 5
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'callWithDebugContext', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 13499, column: 42
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'debugCheckAndUpdateView', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 13039, column: 12
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ViewRef_.detectChanges', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/@angular/core/bundles/core.umd.js', line: 10206, column: 18
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'PlanComponent.refreshSchedule', file:'file:///data/data/com.kanayo.mymobilenative/files/app/pages/plan/plan.component.js', line: 74, column: 24
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/pages/plan/plan.component.js', line: 64, column: 19
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ZoneDelegate.invokeTask', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 398, column: 31
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'Zone.runTask', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 165, column: 47
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ZoneTask.invoke', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 460, column: 38
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'timer', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 1634, column: 29
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'invoke', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 52, column: 48
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'ZoneDelegate.invoke', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 365, column: 26
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'Zone.runGuarded', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 138, column: 47
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js', line: 116, column: 29
04-05 16:08:41.614 8007 8007 D TNS.Native: Frame: function:'run', file:'file:///data/data/com.kanayo.mymobilenative/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 56, column: 13
04-05 16:08:41.614 8007 8007 D TNS.Java: Platform.getJavaObjectByID:40995
04-05 16:08:41.614 8007 8007 D AndroidRuntime: Shutting down VM
04-05 16:08:41.624 8007 8007 W System.err: com.tns.NativeScriptException: Attempt to use cleared object reference id=38608
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.getJavaObjectByID(Runtime.java:897)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:957)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:941)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:933)
04-05 16:08:41.624 8007 8007 W System.err: at com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
04-05 16:08:41.624 8007 8007 W System.err: at android.os.Handler.handleCallback(Handler.java:739)
04-05 16:08:41.624 8007 8007 W System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
04-05 16:08:41.624 8007 8007 W System.err: at android.os.Looper.loop(Looper.java:158)
04-05 16:08:41.624 8007 8007 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7224)
04-05 16:08:41.624 8007 8007 W System.err: at java.lang.reflect.Method.invoke(Native Method)
04-05 16:08:41.624 8007 8007 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
04-05 16:08:41.624 8007 8007 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
04-05 16:08:41.624 8007 8007 D TNS.Java: Uncaught Exception Message=An uncaught Exception occurred on "main" thread.
04-05 16:08:41.624 8007 8007 D TNS.Java: com.tns.NativeScriptException: Attempt to use cleared object reference id=38608
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.getJavaObjectByID(Runtime.java:897)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.callJSMethodNative(Native Method)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.callJSMethod(Runtime.java:957)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.callJSMethod(Runtime.java:941)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.Runtime.callJSMethod(Runtime.java:933)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
04-05 16:08:41.624 8007 8007 D TNS.Java: at android.os.Handler.handleCallback(Handler.java:739)
04-05 16:08:41.624 8007 8007 D TNS.Java: at android.os.Handler.dispatchMessage(Handler.java:95)
04-05 16:08:41.624 8007 8007 D TNS.Java: at android.os.Looper.loop(Looper.java:158)
04-05 16:08:41.624 8007 8007 D TNS.Java: at android.app.ActivityThread.main(ActivityThread.java:7224)
04-05 16:08:41.624 8007 8007 D TNS.Java: at java.lang.reflect.Method.invoke(Native Method)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
04-05 16:08:41.624 8007 8007 D TNS.Java: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
The intervals create java.lang.Runnable objects, that are stored in the timer module in the timeoutCallbacks
, they are kept there until intervals are cleared or until timeouts tick:
https://github.com/NativeScript/NativeScript/blob/a316e53d547b1de797e6b7cd36fb07d1f37d2482/tns-core-modules/timer/timer.android.ts#L65
I am not sure how exactly the timer may glitch.
Also you said the view is removed, and perhaps later added by the timer? When is the view removed? What events or triggers cause it to be removed? I wonder if it is possible to have the view removed from the visual tree and kept in another handler's closure, one that is not strongly referenced and later from its callback the view to be handed over to the timer but has its Java instance already collected, so when the timer adds it to a visual tree it is already in incorrect state?
It would be very helpful for us to collect as much as possible JavaScript stacks with these "Attempt to use cleared object reference". Also what is the severity of these crashes? You mentioned the last one may run for a day before it crashes? Are there other crashes that are not caused by the "Attempt to use cleared object reference"? Have you tried to run the app without "markingMode: none" and check if it will produce other errors?
From the timer I'm forcing a page to redraw like this.
doDetectChanges(cdRef: ChangeDetectorRef){
if (!cdRef['destroyed']) {
cdRef.detectChanges();
}
}
So there is no manipulation of the view objects from code. The timer is cleared when a page is unloaded, but maybe there is a race condition, or I'm using detectChanges();
incorrectly.
Sometimes it's a day before a crash, sometimes it's an hour. The unpredictability makes it severe.
We do get other crashes, in the Graphing code and the Drawer code, that are also hard to reproduce. We've drawn/redrawn graphs thousands of times without a problem, then during one test, there will be a crash. We're following up on those in separate issues.
Good idea about running with "markingMode: none" off. That could help isolate the problems. I'll set up a test for that and let you know what happens.
Just wanted to post an update on our robo-testing efforts. We have now been running without a crash for 3 days, which is a record.
We currently have one blocker, graphs will crash after drawing about 3000 of them. This has been reported before, see issue 618 We're currently leaving graphs out of the testing so we can make sure the rest of the app is working.
We also see this one very rarely, System.err: TypeError: Cannot read property 'delete' of undefined. Seems to be related to Drawer control animations.
Here is how we solved the issues we were seeing:
TypeError: Cannot read property 'key' of undefined
This happens sometimes when you go back after using clearHistory. We added a canGoBack()
check before calling back()
, and that seems to have solved it.
com.tns.NativeScriptException: Attempt to use cleared object reference id=
This happened when calling cdRef.detectChanges();
from a timer. Put a try/catch around it so we could continue after this.
com.tns.NativeScriptException: Attempt to use cleared object reference id=
This also happened when using our own plugins, which we have made markingMode: none
safe. See the discussion in the comments of https://panayotcankov.github.io/nativescript-3.2.0-memory-management/
System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference This was related to text fields, used the fix posted in #5130
The solution 2 is weak. You can not simply try/catch these errors, perhaps the execution of the program continued, but the native views setup is done recursively and once it throws there would be a big chunk of the visual tree in a wrong state (texts not updated, missing views, white screen etc.) This error is either due to the timer not preserving properly the native callback object (although we've gone a few times through it and it seems fine) or due to the views are handled in other callback that are eligible for collection, it is also possible that after the fix 3 the problem in 2 may be less severe. Did you apply 2 before 3 and if so, could you run the tests without the try/catch in 2 while waiting for the charts issue?
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
System.err: TypeError: Cannot read property 'delete' of undefined.
Seems to be fixed with the following commit: https://github.com/NativeScript/NativeScript/commit/cf950e1ebbf4fd388cd44ff4527c77c11c024525
@gsmedley do you still have problems with your project or it is OK to close the issue?
@vtrifonov -
I think you can close it. The remaining problems are with the graphs and there are separate issues for those. Excluding those we've been able to run continuous monkey tests for over 10 days without a crash. Thanks again for all the help with this!
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:
Please provide the following version numbers that your issue occurs with:
tns 3.4.2
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