Skip to content

fix(android): Added missing nested frame restoration step#11226

Merged
NathanWalker merged 4 commits into
NativeScript:mainfrom
CatchABus:fix/android-nested-frames
May 23, 2026
Merged

fix(android): Added missing nested frame restoration step#11226
NathanWalker merged 4 commits into
NativeScript:mainfrom
CatchABus:fix/android-nested-frames

Conversation

@CatchABus
Copy link
Copy Markdown
Contributor

@CatchABus CatchABus commented May 23, 2026

PR Checklist

What is the current behavior?

Right now, the nested frame first simulated navigation does not work if already done once.
That usually occurs because the cached transition state is not unset after the simulated navigation.

What is the new behavior?

This PR is a continuation of #9725 & #10713 and contains the following:

  • Added missing transition restoration step for nested frames to fragment onResume lifecycle
  • Avoid unsetting the entry fragment during onDestroy lifecycle of the old fragment if entry doesn't own it anymore
  • Removed frame create timeout workaround from view loaded lifecycle (this used to help solve the problem before fix(android): Better handling for nested frames #10713 which broke it)
  • Added handling to unload root view during resetRootView in case flavors reuse the same root view
  • Corrected AndroidFrame types that were broken during NS9 refactoring

Fixes issues mentioned in PR #11214.

Just a few notes about the transition restore change.
In the future, we could keep a reference of the last executed context at all times and set it as executing to simulate that navigation. This way, the simulated navigations will always reach setCurrent call.
Right now, this isn't possible as it's breaking current TabView functionality and automated tests fail.
Also, there are checks that proceed to actions based on whether a context is executing or not so it will need extended testing.
The first step to leaning to that direction is to take care of the fragment manager mess on TabView elements. Then, we can think about it.

Luckily, this PR keeps the simulated navigation workaround as is more or less and solves the apparent problem.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 23, 2026

View your CI Pipeline Execution ↗ for commit 04b3e45

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

☁️ Nx Cloud last updated this comment at 2026-05-23 15:08:51 UTC

@CatchABus CatchABus marked this pull request as ready for review May 23, 2026 14:00
@CatchABus CatchABus requested a review from NathanWalker May 23, 2026 14:01
@CatchABus CatchABus marked this pull request as draft May 23, 2026 14:04
@CatchABus CatchABus marked this pull request as ready for review May 23, 2026 14:27
@NathanWalker
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Android frame lifecycle and transition handling is refactored to decouple AndroidFrame ownership typing from the Frame concrete class, use FrameDefinition as the abstract contract, extract transition state restoration into a dedicated method, and simplify fragment detach cleanup by removing pending-detach deferral logic.

Changes

Android Frame Lifecycle Refactor

Layer / File(s) Summary
Type contract updates
packages/core/ui/frame/fragment.transitions.android.ts, packages/core/ui/frame/frame-common.ts, packages/core/ui/frame/index.d.ts, packages/core/ui/frame/index.ios.ts
ExpandedEntry interface fields (transition listeners, animators, state properties) become optional; FrameBase explicitly implements FrameDefinition; Frame iOS navbar/toolbar customization properties become optional; _restoreTransitionState?() method added to type.
AndroidFrame ownership decoupling
packages/core/ui/frame/index.android.ts, packages/core/ui/frame/index.d.ts
AndroidFrame constructor and owner getter are typed to use FrameDefinition instead of Frame; frameId becomes required readonly number; internal "common properties" declarations removed from AndroidFrame interface.
Fragment lifecycle type integration
packages/core/ui/frame/frame-helper-for-android.ts, packages/core/ui/frame/index.android.ts
Frame-helper imports are updated to wire AndroidFrame and ExpandedEntry types; framesCache is typed as Array<WeakRef<AndroidFrame>>; FragmentCallbacksImplementation.entry is typed as ExpandedEntry; fragment identity check added in onDestroy before clearing fragment reference; onResume conditionally restores transition state via _restoreTransitionState?.() when animation is not running; cache iteration optimized.
Transition state restoration refactor
packages/core/ui/frame/index.android.ts
Inline cached-transition restoration logic in setCurrent is replaced with dedicated Frame._restoreTransitionState() method; simulated-first-navigation flow is adjusted to use this new method.
Entry fragment and detach lifecycle cleanup
packages/core/ui/frame/index.android.ts
_frameCreateTimeout and _ensureEntryFragment entry-recreation mechanism removed; isPendingDetachSymbol and pending-detach deferral logic eliminated; disposeNativeView now directly invokes _onDetachedFromWindow for still-attached views; resetActivityContent calls callUnloaded() before performing root view reset; _navigateCore uses local currentEntry variable for transition selection.

Possibly related PRs

  • NativeScript/NativeScript#10713: Android/nested-frame transition-state refactor, including ExpandedEntry typing and Fragment.transitions snapshot/restore mechanics feeding into this PR's frame integration and _restoreTransitionState behavior.

Suggested labels

♥ community PR

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: adding missing nested frame restoration step for Android frame handling.
Description check ✅ Passed The description clearly relates to the changeset, detailing the nested frame restoration fix and all related changes made across the affected files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e31b07ac-6d47-41c5-a4a9-7685730d7780

📥 Commits

Reviewing files that changed from the base of the PR and between a723a01 and 113be35.

📒 Files selected for processing (6)
  • packages/core/ui/frame/fragment.transitions.android.ts
  • packages/core/ui/frame/frame-common.ts
  • packages/core/ui/frame/frame-helper-for-android.ts
  • packages/core/ui/frame/index.android.ts
  • packages/core/ui/frame/index.d.ts
  • packages/core/ui/frame/index.ios.ts

Comment thread packages/core/ui/frame/index.d.ts Outdated
@NathanWalker NathanWalker merged commit 0a190f1 into NativeScript:main May 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants