GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(android): keep the root view when an activity replaces another by herefishyfish · Pull Request #11624 · NativeScript/NativeScript

Conversation

@herefishyfish

@herefishyfish herefishyfish commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PR Checklist

  • The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages.
  • There is an issue for the bug/feature this PR is for. [Android] Blank screen when a new activity adopts a shared root view before the old one stops #11615
  • You have signed the CLA.
  • All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#unit-testing. (One CSS tokenizer spec fails on my Windows checkout. It failed the same way on a clean tree at an older base.)
  • Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md.

What is the current behavior?

Android can start a new activity before the old one stops. When both activities use the same root view, the screen goes blank. Android logs this order:

create:NEW start:NEW stop:OLD destroy:OLD

The new activity adopts the root view, and the old activity then unloads it. If the old activity is finishing, it also destroys the view. The view also keeps the old activity's FragmentManager, so the frame does not create a fragment in the new activity.

An app reaches this state when it reuses one root view, for example with Application.run({ create }) returning the same view. Reopening right after leaving with Back triggers it. So does a launch with the multi-task flag. Routing is not required.

What is the new behavior?

The change is 12 added lines in packages/core/ui/frame/index.android.ts:

  • onStop, onDestroy, and onSaveInstanceState act only on a root view that the activity shows.
  • A new activity unloads the root view from the previous activity before it adopts the view. This clears the cached FragmentManager.
  • An activity takes the root view back when it starts again, so returning to an older activity works.

Closes #11615.

I reduced this PR after review. An earlier version also changed startActivity, the back press paths, and apps with no main entry. Those changes are not needed for #11615, so I removed them.

Not covered

  • Apps with no main entry still go blank on a quick reopen. exit has not fired, so launch does not fire, and nothing supplies a root view. [Android] App with no main entry shows a blank screen when reopened right after Back #11631 tracks this. A reopen after exit needs fix(core): fire launch again for the first window after exit #11573.
  • A back press on a window with no root view crashes with a TypeError in onBackPressed. The same crash happens on main without this PR.
  • With two visible activities and one root view, such as split screen, the activity that starts last gets the view.
  • Taking the root view back fires initRootView and contentLoaded again for that view.
  • Embedded mode is not tested.

Verification

Tested on an API 36 emulator with key presses and launch flags, on main at 07e84ec58.

Reused root view, with the main.ts from #11615:

Steps Without this PR With this PR
Back with an immediate reopen Blank in 5 of 5 Page shown in 10 of 10
Second activity with -f 0x08000000 Blank in 5 of 5 Page shown
Back from the second activity to the first Blank Page shown
Second activity, night mode change, Back Not run Page shown
Back, wait 5 seconds, reopen Page shown in 3 of 3 Page shown
Clear-task launch Not run Page shown

The stock toolbox app shows its page on all of these paths with this PR.

An app with no main entry still shows the blank screens and the back press crash listed above. I reproduced the crash on main without this PR.

Unit tests: 650 passed, 1 failed, 1 skipped. The failure is the CSS spec above. Five of the eight new specs fail without the fix.

Not tested: real Angular, Vue, or Solid apps, a physical device, iOS, and TabView roots. The new specs use fake views, so they check the order of calls and not real fragment behavior. There is no apps/automated test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nx-cloud

nx-cloud Bot commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 129b25a

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 4m 7s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 10s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-10 03:55:55 UTC

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pkg-pr-new

pkg-pr-new Bot commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11624
npm i https://pkg.pr.new/@nativescript/vite@11624
npm i https://pkg.pr.new/@nativescript/webpack@11624

commit: 129b25a

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@herefishyfish
herefishyfish marked this pull request as ready for review November 8, 2026 13:16
farfromrefug
farfromrefug reviewed Nov 9, 2026
View reviewed changes
Comment thread packages/core/application/application.android.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

herefishyfish added 2 commits November 10, 2026 11:47
@herefishyfish
test(core): cover a root view shared between Android activities
e1ea59b
Add specs for an activity that no longer shows the root view and for
the activity that shows it. Five specs fail without the next commit.
The other three pin behavior that must not change.
@herefishyfish
fix(android): keep the root view when an activity replaces another
129b25a
Android can start a new activity before the old one stops. When both
activities use one root view, the old activity unloaded and destroyed
the view that the new activity showed. The view also kept the old
FragmentManager, so the screen stayed blank.

onStop, onDestroy, and onSaveInstanceState now act only on a root view
that the activity shows. A new activity unloads the view from the
previous activity before it adopts the view, which clears the cached
FragmentManager. An activity takes the view back when it starts again.

Fixes NativeScript#11615
@herefishyfish
herefishyfish force-pushed the fix/android-blank-screen-on-reopen branch from 0d451fc to 129b25a Compare November 10, 2026 03:48
@herefishyfish herefishyfish mentioned this pull request Nov 10, 2026
[Android] App with no main entry shows a blank screen when reopened right after Back #11631
Open

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@farfromrefug farfromrefug farfromrefug left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Android] Blank screen when a new activity adopts a shared root view before the old one stops

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@herefishyfish @farfromrefug
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.