Skip to content

Regression: Back button breaks app on clearHistory: true (android) #1569

Closed

Description

@Daxito

So seems like if you have this scenario, the back button breaks the App, it can't navigate back any more, and it just crashes.

  1. Create an app using the new version 1.6.0
  2. Create Page1, Page2 and Page3
  3. Make Page1 you initial page, and add a button to navigate to Page2 like:
    var nav = { moduleName: "./Page2", backstackVisible: true, clearHistory: true }; frame.topmost().navigate(nav)
  4. In Page2, add another button to navigate to Page3, like:
    exports.toPage3 = function(){ frame.topmost().navigate("./Page3") }
  5. Once in Page3, try to navigate back using the "Back" button on your device, it just crashes, or you get a blank screen sometimes, I also attached a sample app if you want to use it.
    sampleapp.zip
    .

Activity

  1. Daxito commented on Feb 18, 2016

    @Daxito
    Author

    Wow, so am I the only one with this issue? I attached a sample with the issue, you can just run it and you will see. Using brand new project....

  2. NathanaelA commented on Feb 18, 2016

    @NathanaelA
  3. Daxito commented on Feb 18, 2016

    @Daxito
    Author

    I know, after a release I myself face issues, I was just pinging :-)

  4. NathanaelA commented on Feb 18, 2016

    @NathanaelA
  5. Daxito commented on Feb 18, 2016

    @Daxito
    Author

    Yes, easy to test. I know it is dificult to find and issue without some sample, I try to add a sample when possible.
    Thank you @NathanaelA

  6. NathanaelA commented on Feb 19, 2016

    @NathanaelA
  7. enchev commented on Feb 19, 2016

    @enchev
    Contributor

    Hey @slavchev, @hshristov can you help here?

  8. Louroj commented on Feb 24, 2016

    @Louroj

    I'm also having this issue, any solutions so far?

    I have tried to go back to 1.5.2 but without much success since it now displays some other errors that did not happen before.

  9. added a commit that references this issue on Feb 24, 2016
    cbbde1b
  10. added this to the 1.7.0 milestone on Feb 24, 2016
  11. tiagordc commented on Feb 24, 2016

    @tiagordc

    Can we have this before 1.7.0? I have the same issue

  12. firecube commented on Feb 24, 2016

    @firecube

    +1

    Also affected by this issue. In my app logging out takes you back to the login page and clears history. After logging back and navigating around the first use of the back button crashes the app.

    Would be awesome to have this fixed before 1.7.

  13. 1 remaining item

  14. changed the title [-]Android: Back button breaks App when clearHistory: true using {N} 1.6.0, 1.5.2 was fine[/-] [+]Regression: Back button breaks app on clearHistory: true (android)[/+] on Feb 25, 2016
  15. vjoao commented on Feb 27, 2016

    @vjoao
    Contributor

    I'm also getting this same crash. Thing is I'm not even clearing the back history.
    I think I have a even more weird case:

    I navigate to page2 with

    let navigationEntry = {
            moduleName : "select",
            context : {
                deferred: deferred
            }
    };
    topmost().navigate(navigationEntry);
    

    And on the select page I have a button which calls topmost().goBack();. Sometimes, if I stay long enough on the select page I can't click the button anymore (It doesn't cause the app to go back to home). If I press the physical back button on Android, the app closes (literally and some seconds after it reopens with the error) and the error

    java.lang.RuntimeException: Unable to destroy activity {org.nativescript.quedia/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=-1216981224
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3739)
    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3757)
    at android.app.ActivityThread.access$1500(ActivityThread.java:154)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
    

    appears out of nowhere. Is this somehow related to this bug?

  16. GerjanOnline commented on Mar 11, 2016

    @GerjanOnline

    This bug hits me as well (v1.6.2) which is very annoying, please create a release with the fix asap if you want/can!

  17. NathanaelA commented on Mar 15, 2016

    @NathanaelA
  18. orsag commented on Apr 29, 2016

    @orsag

    I added clearHistory: true to one of my navigations and during navigation app crashed with error

    android.content.res.Resources$NotFoundException: Resource ID #0xffffffec at android.content.res.Resources.getValue(Resources.java:1163) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2349) at android.content.res.Resources.getAnimation(Resources.java:1003) at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:71) at android.app.FragmentManagerImpl.loadAnimator(FragmentManager.java:744) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:959) at android.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1168) at android.app.BackStackRecord.run(BackStackRecord.java:641) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1450) at android.app.FragmentManagerImpl$1.run(FragmentManager.java:444) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5118) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606) at dalvik.system.NativeStart.main(Native Method)

    Crashed on 1.7.1, everything works fine on 2.0.0-2016-04-27-549.

  19. jeremypele commented on Jan 22, 2018

    @jeremypele

    @orsag Did you remember what fixed it? I can't reproduce it on my side but I've got a whole bunch of sentry errors poppin with the very same stack trace on production

  20. john-e-riordan commented on Feb 14, 2018

    @john-e-riordan
    System.err: android.content.res.Resources$NotFoundException: Resource ID #0xffffffec
    System.err:     at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
    System.err:     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2134)
    System.err:     at android.content.res.Resources.getAnimation(Resources.java:1167)
    System.err:     at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:125)
    System.err:     at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:106)
    System.err:     at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:91)
    System.err:     at android.app.FragmentManagerImpl.loadAnimator(FragmentManager.java:1089)
    System.err:     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1368)
    System.err:     at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1557)
    System.err:     at android.app.BackStackRecord.executeOps(BackStackRecord.java:802)
    System.err:     at android.app.FragmentManagerImpl.executeOps(FragmentManager.java:2386)
    System.err:     at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2181)
    System.err:     at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2136)
    System.err:     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2043)
    System.err:     at android.app.FragmentManagerImpl$1.run(FragmentManager.java:719)
    System.err:     at android.os.Handler.handleCallback(Handler.java:790)
    System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
    System.err:     at android.os.Looper.loop(Looper.java:164)
    System.err:     at android.app.ActivityThread.main(ActivityThread.java:6494)
    System.err:     at java.lang.reflect.Method.invoke(Native Method)
    System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    

    @jeremypele - I have same/similar issue in 3.4.1. Happened once randomly while developing, can't reproduce, and it is happening in the wild.

  21. john-e-riordan commented on Feb 14, 2018

    @john-e-riordan

    And this one which has a slightly different trace, but...

    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:4937)
    System.err: 	at android.view.ViewGroup.addView(ViewGroup.java:4768)
    System.err: 	at android.view.ViewGroup.addView(ViewGroup.java:4708)
    System.err: 	at android.view.ViewGroup.addView(ViewGroup.java:4681)
    System.err: 	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1284)
    System.err: 	at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1557)
    System.err: 	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1618)
    System.err: 	at android.app.BackStackRecord.executeOps(BackStackRecord.java:807)
    System.err: 	at android.app.FragmentManagerImpl.executeOps(FragmentManager.java:2386)
    System.err: 	at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2181)
    System.err: 	at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2136)
    System.err: 	at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2043)
    System.err: 	at android.app.FragmentManagerImpl$1.run(FragmentManager.java:719)
    System.err: 	at android.os.Handler.handleCallback(Handler.java:790)
    System.err: 	at android.os.Handler.dispatchMessage(Handler.java:99)
    System.err: 	at android.os.Looper.loop(Looper.java:164)
    System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
    System.err: 	at java.lang.reflect.Method.invoke(Native Method)
    System.err: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    
  22. john-e-riordan commented on Feb 14, 2018

    @john-e-riordan

    @jeremypele

    I believe I’ve tracked this one down after a lot of painful work to reproduce it.

    TLDR; When the ExtendedNavigationOptions transition property is undefined, the crashes do not occur (or at least in that case I have yet to be able to reproduce them).

    On Android as of 3.4.1 there appears to be a bug/issue in NativeScript routing extensions when using a transition. It eventually crashes. The crashes are hard to reproduce. It's not clear to me what the issue is, but perhaps it seems to have something to do with calling navigate() repeatedly (and seems likely related to something down in ui/frame). In my case, I'm calling navigate() repeatedly before a prior call to navigate() resolves, but I'm not sure if that's a requirement to cause a crash.

    Calling navigate() repeatedly is legit and Angular handles it well, but NativeScript provides a custom LocationStrategy to the Angular router and guessing the issue is down in that direction someplace. Like eyeballing the code and using a bit of imagination it doesn't seem far fetched that there is some issue that crops up when calling navigate() repeatedly with transition = { name: "fade" } while there are outstanding calls to navigate() that have not resolved (for what is is worth, I was able to reproduce the crash consistently/eventually (stress eventually) using the "fade" transition but didn't try with any others). Like perhaps it is getting tripped up because NSLocationStrategy is storing a single reference to the current NavigationOptions which is getting over written on each call to navigate() regardless of there being prior calls to navigate() that have yet to be resolved? But not digging into it further, that's pure reckless speculation and I know enough to know I don't know the code involved well enough to have a real clue.

    There doesn't seem to be an issue on iOS, thus the ui/frame speculation.

  23. sserdyuk commented on Feb 19, 2018

    @sserdyuk

    @jeremypele @john-e-riordan I just got a crash report from Filebase production app with a similar stack. I have no idea on what triggered it, as it's a production app, and I only get Java stack, no TS. If you find anything worth trying, please ping me.

    Exception android.content.res.Resources$NotFoundException: Resource ID #0xffffffec android.content.res.ResourcesImpl.getValue (ResourcesImpl.java:202) android.content.res.Resources.loadXmlResourceParser (Resources.java:2968) android.content.res.Resources.getAnimation (Resources.java:2008) android.animation.AnimatorInflater.loadAnimator (AnimatorInflater.java:125) android.animation.AnimatorInflater.loadAnimator (AnimatorInflater.java:106) android.animation.AnimatorInflater.loadAnimator (AnimatorInflater.java:91) android.app.FragmentManagerImpl.loadAnimator (FragmentManager.java:827) android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1065) android.app.FragmentManagerImpl.removeFragment (FragmentManager.java:1280) android.app.BackStackRecord.run (BackStackRecord.java:766) android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1582) android.app.FragmentManagerImpl$1.run (FragmentManager.java:483) android.os.Handler.handleCallback (Handler.java:751) android.os.Handler.dispatchMessage (Handler.java:95) android.os.Looper.loop (Looper.java:154) android.app.ActivityThread.main (ActivityThread.java:6642) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1468) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)

  24. edusperoni commented on May 11, 2018

    @edusperoni
    Contributor

    This issue is still present if you mash the back button. It seems to be happening if you press the back button during a transition.

  25. sserdyuk commented on May 11, 2018

    @sserdyuk

    Might be related to #5657

  26. lock commented on Aug 26, 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.

  27. locked and limited conversation to collaborators on Aug 26, 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