Skip to content

[Next] Back Navigation crashing the app w/ The specified child already has a parent #6312

Closed

Description

@NickIliev

From @NickIliev on September 14, 2018 14:5

Working with next of tns-core-modules and nativescript-angular and navigating withnsRouterLink and then back with the hardware button is causing a crash.

Steps to reproduce:

JS: NavigationEnd(id: 4, url: '/info', urlAfterRedirects: '/info/app-info')
JS: NavigationEnd(id: 4, url: '/info', urlAfterRedirects: '/info/app-info')
JS: Router Event: Scroll
JS: Scroll(anchor: 'null', position: 'null')
JS: Scroll(anchor: 'null', position: 'null')
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:5122)
System.err:     at android.view.ViewGroup.addView(ViewGroup.java:4953)
System.err:     at android.view.ViewGroup.addView(ViewGroup.java:4893)
System.err:     at android.view.ViewGroup.addView(ViewGroup.java:4866)
System.err:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1425)
System.err:     at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
System.err:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
System.err:     at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
System.err:     at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2590)
System.err:     at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2377)
System.err:     at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332)
System.err:     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2239)
System.err:     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
...

package.json content using next

  "dependencies": {
    "@angular/common": "~6.1.0",
    "@angular/compiler": "~6.1.0",
    "@angular/core": "~6.1.0",
    "@angular/forms": "~6.1.0",
    "@angular/http": "~6.1.0",
    "@angular/platform-browser": "~6.1.0",
    "@angular/platform-browser-dynamic": "~6.1.0",
    "@angular/router": "~6.1.0",
    "nativescript-angular": "^6.2.0-2018-09-14-01",
    "nativescript-app-center": "^1.0.3",
    "nativescript-cardview": "^3.1.1",
    "nativescript-permissions": "^1.2.3",
    "nativescript-plugin-firebase": "^6.8.1",
    "nativescript-social-share": "^1.5.1",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-ui-sidedrawer": "^4.3.0",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^6.0.0",
    "tns-core-modules": "^4.3.0-2018-09-14-01",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~6.1.0",
    "@ngtools/webpack": "~6.2.0",
    "nativescript-dev-typescript": "~0.7.3",
    "nativescript-dev-webpack": "^0.17.0-2018-09-14-01",
    "tns-platform-declarations": "^4.2.0",
    "typescript": "~2.7.2"
  },

The above case is working as expected with official versions of nativescript-angular and tns-core-modules. The navigation also works when routerExtensions is used ins tead of nsRouterLink

Workaround

this._routerExtensions.navigate(
                [path], {
                transition: {
                    name: "fade",
                    duration: 300,
                }
            }
        )

Copied from original issue: NativeScript/nativescript-angular#1516

Activity

  1. NickIliev commented on Sep 27, 2018

    @NickIliev
    ContributorAuthor

    Issue reproducible only on Android (works as expected on iOS).

    A simplified scenario to reproduce the case in this branch.

    Steps to reproduce:

    • clone the branch
    • start the app
    tns run android --bundle
    
    • tap the image to navigate using nsRouterLink
    • go back using the hardware button and the app will throw with the error above.
  2. NickIliev commented on Sep 27, 2018

    @NickIliev
    ContributorAuthor

    Reported here as well.

  3. NickIliev commented on Sep 27, 2018

    @NickIliev
    ContributorAuthor

    Possibly related to the usage of the Android Fragment Manager as the issue is now reproducible with Core projects

  4. ghost removed on Oct 4, 2018
  5. locked and limited conversation to collaborators on Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions