Skip to content

Crash on navigate on app resume: The specified child already has a parent #6708

Description

@manoldonev

Environment

  • CLI: 5.1.0
  • Cross-platform modules: 5.1.0
  • Android Runtime: 5.1.0

Describe the bug
Navigating to a page when app resumes from background causes the app to crash with the following exception:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to resume activity {org.nativescript.bl32/com.tns.NativeScriptActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5417)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

To Reproduce

  1. Create app from blank template
  2. Add new Page second-page.xml
  3. Add the following application.resumeEvent handler to app.ts:
import * as application from "tns-core-modules/application";
import { topmost } from "tns-core-modules/ui/frame";

application.on(application.resumeEvent, (context) => {
    topmost().navigate("home/second-page");
});

application.run({ moduleName: "app-root" });
  1. Start app
  2. Suspend app
  3. Resume app -- app crashes

Originally reported by @nudiref here: #6201

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions