Skip to content

[Android] After exiting with Back, reopening the app in the same process never fires launch again (9.1 regression, Angular apps stay dead and unstyled) #11572

Open

Description

@anjak03

Issue Description

[Android] After exiting with Back, reopening the app in the same process never fires launch again (9.1 regression, Angular apps stay dead and unstyled)

Environment

  • CLI: 9.1.1
  • @nativescript/core: 9.1.2 (also checked in 9.1.3)
  • @nativescript/android: 9.1.1
  • @nativescript/angular: 18.0.1 (21.2.0 relies on the same launch / exit events)
  • Device: Android 11 (any Android 10 or 11 device, where Back on the root activity finishes it)
  • Works in: @nativescript/core 9.0.17 + @nativescript/android 9.0.2

If the user leaves the app with the Back button and reopens it while the process is still alive, the Angular app never starts again. The last screen stays visible but has lost all component styles, and taps do nothing. Only killing the process brings it back.

What happens in core:

  1. Back on the root activity finishes it. Since this is the last window, exit fires (application.android.js, activity destroyed callback).
  2. @nativescript/angular handles exit by destroying the app module. During teardown it calls removeTaggedAdditionalCSS(styleTag), which removes every component style.
  3. On reopen, a new activity is created and setActivityContent resolves content through Application._resolveWindowContent → resolveWindowContent.
  4. resolveWindowContent only fires the legacy launch event while _launchBridgeConsumed is false. That flag is set to true the first time (and in notifyLaunch) and never reset, so launch doesn't fire again in this process.
  5. @nativescript/angular only bootstraps in its launch handler, so the app is never bootstrapped again.

In 9.0.x, every new activity created without saved state fired launch again (createRootView(rootView, fireLaunchEvent)), so Angular bootstrapped again after exit.

Android 12 and newer don't finish the root activity on Back, so this is easiest to see on 10 or 11. Any path that finishes the last activity without killing the process should trigger it too.

Reproduction

  1. Run the app on an Android 10 or 11 device or emulator.
  2. Press Back on the first screen until the app closes. Don't swipe it away from recents, so the process stays alive.
  3. Open the app again from the launcher.

Result: the screen is unstyled and unresponsive.

Relevant log output (if applicable)

Environment

No response

Please accept these terms

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