Skip to content

App crashes after a while leaving it open and re-selecting it, using android #1614

Closed

Description

@rosen-vladimirov

From @Daxito on February 19, 2016 4:4

So I just open a NS app and then I switch to other apps, then leave my cellphone alone for a while, then when I come back and try to "bring to the front" my App, it crashes with this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yyy.yy/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed

TypeError: Cannot read property '_onAttached' of null
File: "/data/data/com.yyy.yy/files/app/tns_modules/ui/frame/frame.js, line: 414, column: 16

StackTrace:
Frame: function:'NativeActivity.onCreate', file:'/data/data/com.yyy.yy/files/app/tns_modules/ui/frame/frame.js', line: 414, column: 17

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2661)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5835)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Caused by: com.tns.NativeScriptException:
Calling js method onCreate failed

TypeError: Cannot read property '_onAttached' of null
File: "/data/data/com.yyy.yy/files/app/tns_modules/ui/frame/frame.js, line: 414, column: 16

StackTrace:
Frame: function:'NativeActivity.onCreate', file:'/data/data/com.yyy.yy/files/app/tns_modules/ui/frame/frame.js', line: 414, column: 17

at com.tns.Platform.callJSMethodNative(Native Method)
at com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
at com.tns.Platform.callJSMethod(Platform.java:711)
at com.tns.Platform.callJSMethod(Platform.java:690)
at com.tns.Platform.callJSMethod(Platform.java:680)
at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:1574)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2614)
... 10 more

Copied from original issue: NativeScript/nativescript-cli#1512

Activity

  1. self-assigned this
    on Feb 23, 2016
  2. mikeres0 commented on Feb 25, 2016

    @mikeres0

    +1, any news on this?

  3. hshristov commented on Mar 2, 2016

    @hshristov
    Contributor

    @Daxito, @mikeres0 We fixed crash with application suspend resume but by the callstack I see that this might be different problem. Could you please attach sample project and steps to reproduce it?

  4. Daxito commented on Mar 3, 2016

    @Daxito

    I have clear history false and it still crashes, I just got it right now.

  5. Daxito commented on Mar 3, 2016

    @Daxito

    OK, Here is a demo with the issue, this demo was created just running "tns create sample" and that's it, run this on a real device, android of course, make sure you have many Apps already open, after opening the App, go to different Apps, then come back to this one, it should fail, I had like 17 Apps "Open", or at least were opened at some point. Let me know if you need more info.

    SampleApp.zip

  6. orsag commented on Mar 11, 2016

    @orsag

    Any progress on this issue? We cannot publish to play store with this bug.

  7. ErjanGavalji commented on Mar 15, 2016

    @ErjanGavalji
    Contributor

    We tested @Daxito's package with the latest build (1.7), which is about to be released and were not able to reproduce the problem. Can you check with it and let us know the state?

    Cheers,
    Erjan

  8. Daxito commented on Mar 15, 2016

    @Daxito

    Will do asap.

  9. ErjanGavalji commented on Mar 16, 2016

    @ErjanGavalji
    Contributor

    Just to let you know guys, 1.7 is being released now, binaries are out on npmjs.com already.

  10. Daxito commented on Mar 16, 2016

    @Daxito

    @ErjanGavalji This is still an issue but just with a little different effects, attached is the sample app I used and this is the error I get along with the steps to reproduce it:

    Steps to reproduce

    1. Deploy the sample app to any android real device.
    2. Open a bunch of other apps, like 15.
    3. "Bring to the front/select" like 5 or 6 of those others apps before coming back to the SampleApp, the idea is to make SampleApp to be inactivated by the device.
    4. Select the SampleApp, now very "inactive", you should see these error in the log, and the app just opens a white window:

    D/TNS.JAVA.JsDebugger(14910): Sending console message to inspector: {"seq":0,"type":"event","event":"messageAdded","success":true,"body":{"message":{"source":"console-api","type":"log","level":"error","line":0,"column":0,"url":"","groupLevel":7,"repeatCount":1,"text":"The application crashed because of an uncaught exception. You can look at \"stackTrace\" or \"nativeException\" for more detailed information about the exception.\njava.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.SampleApp\/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: \nCalling js method onCreate failed\n\nTypeError: Cannot read property '_onAttached' of null\nFile: \"\/data\/data\/org.nativescript.SampleApp\/files\/app\/tns_modules\/ui\/frame\/frame.js, line: 613, column: 16\n\nStackTrace: \n\tFrame: function:'NativeScriptActivity.onCreate', file:'\/data\/data\/org.nativescript.SampleApp\/files\/app\/tns_modules\/ui\/frame\/frame.js', line: 613, column: 17\n\n\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2661)\n\tat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)\n\tat android.app.ActivityThread.access$900(ActivityThread.java:172)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)\n\tat android.os.Handler.dispatchMessage(Handler.java:102)\n\tat android.os.Looper.loop(Looper.java:145)\n\tat android.app.ActivityThread.main(ActivityThread.java:5835)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java:372)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)\nCaused by: com.tns.NativeScriptException: \nCalling js method onCreate failed\n\nTypeError: Cannot read property '_onAttached' of null\nFile: \"\/data\/data\/org.nativescript.SampleApp\/files\/app\/tns_modules\/ui\/frame\/frame.js, line: 613, column: 16\n\nStackTrace: \n\tFrame: function:'NativeScriptActivity.onCreate', file:'\/data\/data\/org.nativescript.SampleApp\/files\/app\/tns_modules\/ui\/frame\/frame.js', line: 613, column: 17\n\n\n\tat com.tns.Platform.callJSMethodNative(Native Method)\n\tat com.tns.Platform.dispatchCallJSMethodNative(Platform.java:816)\n\tat com.tns.Platform.callJSMethod(Platform.java:715)\n\tat com.tns.Platform.callJSMethod(Platform.java:694)\n\tat com.tns.Platform.callJSMethod(Platform.java:684)\n\tat com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:14)\n\tat android.app.Activity.performCreate(Activity.java:6221)\n\tat android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2614)\n\t... 10 more\n"}}}

    1. After that error, your app is now dead, it is on the list of "opened" apps but you cannot select it, and even if you tap on the icon itself it just opens a black window (not white anymore), at this point all you can do is "force close" the app.

    Please let me know if you need more info, I can provide screenshots if needed.

    SampleApp.zip

  11. 4 remaining items

  12. enchev commented on Mar 19, 2016

    @enchev
    Contributor

    Thank you very much @Daxito! We will verify this before releasing the official version next week.

  13. added a commit that references this issue on Mar 19, 2016
  14. Daxito commented on Mar 19, 2016

    @Daxito

    @slavchev Seems like your change indeed fixes the issue! I just tried it out and no more crashing!
    Thank you very much guys!!!

  15. added 2 commits that reference this issue on Mar 21, 2016
  16. added this to the 1.7.1 milestone on Mar 21, 2016
  17. added
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    and removed on Mar 21, 2016
  18. added and removed
    ready for testTSC needs to test this and confirm against live production apps and automated test suites
    on Mar 22, 2016
  19. lock commented on Aug 30, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  20. locked and limited conversation to collaborators on Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions