NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
525 stars 135 forks source link

Error (native) com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=-732891536 #720

Closed NathanaelA closed 7 years ago

NathanaelA commented 7 years ago

This error comes up infrequently in a TNS app.

Please, provide the details below:

Did you verify this is a real problem by searching [Stack Overflow]

Several closed issues like this; none remain open.

Tell us about the problem

I am getting this via a crash recorder:

Error: The application crashed because of an uncaught exception. You can look at \"stackTrace\" or \"nativeException\" for more detailed information about the exception. Error: The application crashed because of an uncaught exception. You can look at \"stackTrace\" or \"nativeException\" for more detailed information about the exception.\n at Error (native) com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=-732891536"

Please provide the following version numbers that your issue occurs with:

Android Runtime: 2.4.1 Core Modules: 2.4.4 No Snapshot (Snapshot was disabled do to issues) Release Mode

Please tell us how to recreate the issue in as much detail as possible.

I am unable to duplicate it in house; but I see one of these error messages in my log at least twice a week for the last couple months.

If you have some way to determine what that object id is at crash time; that would be great to be able to see what is being cleaned up and removed improperly.

petekanev commented 7 years ago

Related to https://github.com/NativeScript/android-runtime/issues/466

NathanaelA commented 7 years ago

466 is Closed and has been closed since mid-last year.

Any idea how we can track this down; the call stack from the uncaught error handler is pretty pointless (what you see is what I got).

Plamen5kov commented 7 years ago

@NathanaelA truth is there's no easy way of tracking this issue down:

Any idea how we can track this down;

Well __enableVerboseLogging() and send us the logcat of the crash, this way, we'll be able to see, at least, the id of the problematic object and it would be some kind of a start.

NathanaelA commented 7 years ago

I wish I could duplicate it also; this is occurring in the wild. The stack trace I provided is all the info I have, as the uncaught error isn't providing a stack trace beyond the error. ;-(

Can we add some code (maybe optional switch) to the runtime that will allow us to use __enableVerboseLogging but instead of to the log, we send it to a disk file. It would be very useful to be able to log the allocations when they are occurring so that at the point that the app crashes; we can back trace it to the source object. At this point because we can't duplicate it locally, having the ability to remotely log this to disk would be very useful.... Each time the app starts; the file could be cleared, and as long as I know the name of the file I can easily read it in and http it up to my error tracking server when this crash occurs.

Plamen5kov commented 7 years ago

It's a great idea, we can do a logcat dump to file when an application crash, which can later be handled as you said.

nirsalon commented 7 years ago

Just happened here on release mode as well:

tns-android: 2.4.1 tns-core-modules: 2.4.4 API Level 23 Phone: XT1580

Exception com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=1057 com.tns.Runtime.getJavaObjectByID (Runtime.java:971) com.tns.Runtime.callJSMethodNative (Runtime.java) com.tns.Runtime.dispatchCallJSMethodNative (Runtime.java:1197) com.tns.Runtime.callJSMethodImpl (Runtime.java:1061) com.tns.Runtime.callJSMethod (Runtime.java:1047) com.tns.Runtime.callJSMethod (Runtime.java:1028) com.tns.Runtime.callJSMethod (Runtime.java:1018) com.tns.gen.android.view.View_OnTouchListener.onTouch (android.view.View$OnTouchListener.java) android.view.View.dispatchTouchEvent (View.java:9293) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2549) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2240) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2254) com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent (PhoneWindow.java:2403) com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1737) android.app.Activity.dispatchTouchEvent (Activity.java:2769) com.appsee.f.dispatchTouchEvent (e:625) com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent (PhoneWindow.java:2364) android.view.View.dispatchPointerEvent (View.java:9517) android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4242) android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4108) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3654) android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3707) android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3673) android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:3799) android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3681) android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:3856) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3654) android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3707) android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3673) android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3681) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3654) android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:5969) android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:5908) android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:5869) android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6072) android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:192) android.os.MessageQueue.nativePollOnce (MessageQueue.java) android.os.MessageQueue.next (MessageQueue.java:323) android.os.Looper.loop (Looper.java:135) android.app.ActivityThread.main (ActivityThread.java:5443) java.lang.reflect.Method.invoke (Method.java)

NathanaelA commented 7 years ago

@Plamen5kov - Can we get a 2.5.x android release with this tracing functionality. My remote trace logging has shown this error now is up to at least once a day in the wild. This looks bad when the app just crashes, w/o any error messages.


I actually finally saw this error myself locally today: It was in the middle of a navigation, when it crashed.

03-17 19:43:24.346  5196  5196 E art     : invalid stream - problem with parameter iterator in /data/app/com.mastertechapps.abtmobile-1/base.apk for method void com.tns.gen.android.transition.Transition_TransitionListener.onTransitionEnd(android.transition.Transition)
03-17 19:43:24.349  5196  5196 D AndroidRuntime: Shutting down VM
03-17 19:43:24.350  5196  5196 W System.err: com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=-634236592
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.getJavaObjectByID(Runtime.java:971)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.callJSMethodNative(Native Method)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:1047)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:1028)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:1018)
03-17 19:43:24.350  5196  5196 W System.err:    at com.tns.gen.android.transition.Transition_TransitionListener.onTransitionEnd(android.transition.Transition$TransitionListener.java)
03-17 19:43:24.350  5196  5196 W System.err:    at android.transition.Transition.end(Transition.java:1924)
03-17 19:43:24.350  5196  5196 W System.err:    at android.transition.Transition$3.onAnimationEnd(Transition.java:1875)
03-17 19:43:24.350  5196  5196 W System.err:    at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1239)
03-17 19:43:24.350  5196  5196 W System.err:    at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:766)
03-17 19:43:24.350  5196  5196 W System.err:    at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801)
03-17 19:43:24.350  5196  5196 W System.err:    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
03-17 19:43:24.350  5196  5196 W System.err:    at android.view.Choreographer.doCallbacks(Choreographer.java:670)
03-17 19:43:24.350  5196  5196 W System.err:    at android.view.Choreographer.doFrame(Choreographer.java:603)
03-17 19:43:24.350  5196  5196 W System.err:    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
03-17 19:43:24.350  5196  5196 W System.err:    at android.os.Handler.handleCallback(Handler.java:739)
03-17 19:43:24.350  5196  5196 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:95)
03-17 19:43:24.350  5196  5196 W System.err:    at android.os.Looper.loop(Looper.java:148)
03-17 19:43:24.350  5196  5196 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:5417)
Plamen5kov commented 7 years ago

@NathanaelA we'll consider it, thank you for your feedback.

SBD580 commented 7 years ago

+1 same thing here

Plamen5kov commented 7 years ago

@SBD580 do you by any chance have steps to reproduce?

SBD580 commented 7 years ago

I'm afraid not

NathanaelA commented 7 years ago

@Plamen5kov -- I'm not sure you will ever get "easy" steps to reproduce; the vast majority of the call stacks I've seen (actually have crashed it a couple times now attempting to get better call stacks for Peter) the issue appears from to be timing related during navigation. Basically mid-navigation while transitioning the GC has to run, if it runs it crashes.

Plamen5kov commented 7 years ago

@NathanaelA, thank you, that's useful information to me.

petekanev commented 7 years ago

@NathanaelA @SBD580 PR Merged. The fix will be available in release 3.0.0

jeffswitzer commented 6 years ago

Recently opened up an app for coworkers to test and one of them reported the following runtime error on android. This is with tns --verision = 4.0.0-2018-03-30-11339. Also for this release I have the following settings, I was curious if markingMode has something to do with this - sometime ago I had set it to none to greatly app boost performance.

"android": {
        "v8Flags": "--expose_gc",
        "gcThrottleTime": 9995000,
        "memoryCheckInterval": 0,
        "freeMemoryRatio": 0.0,
        "markingMode": "none"
    }
An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=26391
    at com.tns.Runtime.getJavaObjectByID(Runtime.java:892)
    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.android.app.DialogFragment_frnal_ts_helpers_l58_c38__DialogFragmentImpl.onCreateView(DialogFragment_frnal_ts_helpers_l58_c38__DialogFragmentImpl.java:20)
    at android.app.Fragment.performCreateView(Fragment.java:2353)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
    at android.app.BackStackRecord.run(BackStackRecord.java:816)
    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1580)
    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:483)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6196)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)