Repository navigation
fix(android): keep the root view when an activity replaces another - #11624
Open
herefishyfish wants to merge 2 commits into
Open
herefishyfish wants to merge 2 commits into
herefishyfish wants to merge 2 commits into
Conversation
|
View your CI Pipeline Execution ↗ for commit 129b25a
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
herefishyfish
marked this pull request as ready for review
November 8, 2026 13:16
farfromrefug
reviewed
Nov 9, 2026
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.
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
force-pushed
the
fix/android-blank-screen-on-reopen
branch
from
November 10, 2026 03:48
0d451fc to
129b25a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
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:
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, andonSaveInstanceStateact only on a root view that the activity shows.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
exithas not fired, solaunchdoes 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 afterexitneeds fix(core): fire launch again for the first window after exit #11573.onBackPressed. The same crash happens onmainwithout this PR.initRootViewandcontentLoadedagain for that view.Verification
Tested on an API 36 emulator with key presses and launch flags, on
mainat07e84ec58.Reused root view, with the
main.tsfrom #11615:-f 0x08000000The 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
mainwithout 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/automatedtest.