Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NickIliev opened this issue Sep 14, 2018 · 4 comments

Comments

@NickIliev
Copy link

NickIliev commented Sep 14, 2018

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,
                }
            }
        )
@NickIliev NickIliev changed the title Navigation via nsRouterLink and back crashing the native back navigation [Next] Navigation via nsRouterLink and back crashing the native back navigation Sep 14, 2018
@NickIliev
Copy link
Author

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.

@NickIliev NickIliev removed their assignment Sep 25, 2018
@NickIliev
Copy link
Author

Reported here as well.

@NickIliev
Copy link
Author

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

@NickIliev NickIliev changed the title [Next] Navigation via nsRouterLink and back crashing the native back navigation [Next] Back Navigation crashing the app w/ The specified child already has a parent Sep 27, 2018
@NickIliev
Copy link
Author

This issue was moved to NativeScript/NativeScript#6312

@ghost ghost removed the bug label Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant