Skip to content

Commit 120e635

Browse files
authored
fix(ios): prevent gc from collecting current navigation transition (#10967)
1 parent 13a5eaa commit 120e635

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/core/ui/frame/index.ios.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Trace } from '../../trace';
1414
import { SlideTransition } from '../transition/slide-transition';
1515
import { FadeTransition } from '../transition/fade-transition';
1616
import { SharedTransition } from '../transition/shared-transition';
17+
import type { Transition } from '../transition';
1718

1819
export * from './frame-common';
1920

@@ -73,7 +74,11 @@ export class Frame extends FrameBase {
7374
}
7475

7576
this._removeFromFrameStack();
76-
this.viewController = null;
77+
78+
if (this.viewController) {
79+
this.viewController.lastExecutingTransition = null;
80+
this.viewController = null;
81+
}
7782

7883
// This was the last frame so we can get rid of the controller delegate reference
7984
if (this._isFrameStackEmpty()) {
@@ -475,6 +480,9 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
475480
}
476481
}
477482

483+
// Keep a strong reference of the last executing transition to prevent gc from collecting it
484+
navigationController.lastExecutingTransition = transition;
485+
478486
if (transition?.iosNavigatedController) {
479487
return transition.iosNavigatedController(navigationController, operation, fromVC, toVC);
480488
}
@@ -509,6 +517,7 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
509517
@NativeClass
510518
class UINavigationControllerImpl extends UINavigationController {
511519
private _owner: WeakRef<Frame>;
520+
public lastExecutingTransition: Transition;
512521

513522
public static initWithOwner(owner: WeakRef<Frame>): UINavigationControllerImpl {
514523
const navigationBarClass = owner.deref()?.iosNavigationBarClass ?? null;

0 commit comments

Comments
 (0)