Skip to content

Crashes when navigating fast between tabs #6199

Closed

Description

@shiv19

Please consider this sample:
https://play.nativescript.org/?template=play-js&id=3gxfjn&v=2

If you navigate between tabs fast enough you run into this problem:

An uncaught Exception occurred on "main" thread.
android.content.res.Resources$NotFoundException: Resource ID #0xffffffec
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2134)
    at android.content.res.Resources.getAnimation(Resources.java:1167)
    at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:125)
    at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:106)
    at android.animation.AnimatorInflater.loadAnimator(AnimatorInflater.java:91)
    at android.app.FragmentManagerImpl.loadAnimator(FragmentManager.java:1089)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1368)
    at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1557)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1630)
    at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2196)
    at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2142)
    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2043)
    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:719)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6753)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

And consider this one: https://play.nativescript.org/?template=play-js&id=3gxfjn&v=3

If you navigate fast between tabs, then you run into this crash:

An uncaught Exception occurred on "main" thread.
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
    at android.view.ViewGroup.addViewInner(ViewGroup.java:4941)
    at android.view.ViewGroup.addView(ViewGroup.java:4772)
    at android.view.ViewGroup.addView(ViewGroup.java:4712)
    at android.view.ViewGroup.addView(ViewGroup.java:4685)
    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1284)
    at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2407)
    at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2186)
    at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2142)
    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2043)
    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:719)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6753)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Activity

  1. vahidvdn commented on Aug 20, 2018

    @vahidvdn

    @shiv19 That's because it uses routing in the tab component. See this issue for more details.

  2. shiv19 commented on Aug 20, 2018

    @shiv19
    MemberAuthor

    @vahidvdn
    I'm not using a TabView here, this is a different issue :)

  3. self-assigned this
    on Aug 21, 2018
  4. tsonevn commented on Aug 21, 2018

    @tsonevn
    Contributor

    HI @shiv19,
    Thank you for the attached sample projects.
    I was able to recreate the issue on my side and will mark this as a bug.
    Regarding your case, I would suggest using the TabView provided by tns-core-modules instead of creating a custom one.

  5. shiv19 commented on Aug 21, 2018

    @shiv19
    MemberAuthor

    @tsonevn
    The main goal of this custom implementation
    Was to make that animation of the "tab highlight"

    When you jump from tab 1 to say tab 4,
    You can see the "tab highlight" travel across tabs 2 and 3 and stop at tab 4.

  6. added this to the 4.3 (TBD) milestone on Aug 21, 2018
  7. DickSmith commented on Sep 8, 2018

    @DickSmith
    Contributor

    I've been experiencing this issue randomly for a number of months on Firebase/Crashlytics (partial data for the last 3 weeks):

    File Method Users Events
    Resources.java – line 1233 android.content.res.Resources.getValue 1 1
    Resources.java – line 1266 android.content.res.Resources.getValue 4 2
    Resources.java – line 1269 android.content.res.Resources.getValue 1 1
    Resources.java – line 1278 android.content.res.Resources.getValue 1 1
    Resources.java – line 1281 android.content.res.Resources.getValue 1 1
    Resources.java – line 1316 android.content.res.Resources.getValue 4 1
    Resources.java – line 1359 android.content.res.Resources.getValue 1 1
    Resources.java – line 1384 android.content.res.Resources.getValue 2 1
    Resources.java – line 1397 android.content.res.Resources.getValue 1 1
    Resources.java – line 1416 android.content.res.Resources.getValue 2 1
    Resources.java – line 1457 android.content.res.Resources.getValue 3 2
    Resources.java – line 1499 android.content.res.Resources.getValue 5 1
    Resources.java – line 1524 android.content.res.Resources.getValue 1 1
    Resources.java – line 1542 android.content.res.Resources.getValue 1 1
    Resources.java – line 1544 android.content.res.Resources.getValue 10 9
    Resources.java – line 1551 android.content.res.Resources.getValue 1 1
    Resources.java – line 1577 android.content.res.Resources.getValue 1 1
    Resources.java – line 2345 android.content.res.Resources.getValue 3 3
    Resources.java – line 2495 android.content.res.Resources.getValue 3 3
    Resources.java – line 2558 android.content.res.Resources.getValue 2 2
    ResourcesImpl.java – line 190 android.content.res.ResourcesImpl.getValue 21 17
    ResourcesImpl.java – line 198 android.content.res.ResourcesImpl.getValue 3 3
    ResourcesImpl.java – line 201 android.content.res.ResourcesImpl.getValue 2 2
    ResourcesImpl.java – line 202 android.content.res.ResourcesImpl.getValue 47 40
    ResourcesImpl.java – line 204 android.content.res.ResourcesImpl.getValue 1 1
    ResourcesImpl.java – line 207 android.content.res.ResourcesImpl.getValue 1 1
    ResourcesImpl.java – line 208 android.content.res.ResourcesImpl.getValue 1 1
    ResourcesImpl.java – line 210 android.content.res.ResourcesImpl.getValue 1 1
    ResourcesImpl.java – line 216 android.content.res.ResourcesImpl.getValue 6 5
    ResourcesImpl.java – line 255 android.content.res.ResourcesImpl.getValue 4 4
    ResourcesImpl.java – line 279 android.content.res.ResourcesImpl.getValue 2 2
    Fatal Exception: android.content.res.Resources$NotFoundException
    Resource ID #0xffffffec
    android.content.res.Resources.getValue (Resources.java:1544)
    android.content.res.Resources.loadXmlResourceParser (Resources.java:3012)
    android.content.res.Resources.getAnimation (Resources.java:1352)
    android.animation.AnimatorInflater.loadAnimator (AnimatorInflater.java:122)
    android.animation.AnimatorInflater.loadAnimator (AnimatorInflater.java:103)
    android.animation.AnimatorInflater.loadAnimator (AnimatorInflater.java:88)
    android.app.FragmentManagerImpl.loadAnimator (FragmentManager.java:831)
    android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1047)
    android.app.FragmentManagerImpl.removeFragment (FragmentManager.java:1258)
    android.app.BackStackRecord.run (BackStackRecord.java:751)
    android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1562)
    android.app.FragmentManagerImpl$1.run (FragmentManager.java:487)
    android.os.Handler.handleCallback (Handler.java:815)
    android.os.Handler.dispatchMessage (Handler.java:104)
    android.os.Looper.loop (Looper.java:207)
    android.app.ActivityThread.main (ActivityThread.java:5728)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)
    

    The line number and Resources/ResourcesImpl probably comes down to exactly which version of Android is being run, but the commonality is that it is always that it's an animation on a FragmentManager and the Resource ID #0xffffffec.

    With some help from @NathanaelA , we realized that this number is -20 and after searching the code base I found this:
    https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/frame/fragment.transitions.d.ts#L13

    It appears there is a possible chance of a race condition on the animations resulting in the fake resource being used.

    Searching for Nativescript #0xffffffec I find these related tickets:
    #1569 (2016)
    #5549 -> NativeScript/android#974 -> #5657

  8. NathanaelA commented on Sep 8, 2018

    @NathanaelA
  9. NathanaelA commented on Sep 8, 2018

    @NathanaelA
  10. removed their assignment
    on Sep 10, 2018
  11. ghost removed on Sep 18, 2018
  12. lock commented on Sep 18, 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.

  13. locked and limited conversation to collaborators on Sep 18, 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