Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/core/ui/frame/frame-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ export class FrameBase extends CustomLayoutView {
removed.resolvedPage = null;
}

protected _disposeBackstackEntry(entry: BackstackEntry): void {
const page = entry.resolvedPage;
if (page) {
page._tearDownUI(true);
}
}

public navigate(param: any) {
if (Trace.isEnabled()) {
Trace.write(`NAVIGATE`, Trace.categories.Navigation);
Expand Down
32 changes: 15 additions & 17 deletions packages/core/ui/frame/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ export class Frame extends FrameBase {
if (this._tearDownPending) {
this._tearDownPending = false;
if (!entry.recreated) {
clearEntry(entry);
this._disposeBackstackEntry(entry);
}

if (current && !current.recreated) {
clearEntry(current);
this._disposeBackstackEntry(current);
}

// If we have context activity was recreated. Create new fragment
Expand Down Expand Up @@ -493,6 +493,17 @@ export class Frame extends FrameBase {
removed.viewSavedState = null;
}

protected _disposeBackstackEntry(entry: BackstackEntry): void {
if (entry.fragment) {
_clearFragment(entry);
}

entry.recreated = false;
entry.fragment = null;

super._disposeBackstackEntry(entry);
}

public createNativeView() {
// Create native view with available _currentEntry occur in Don't Keep Activities
// scenario when Activity is recreated on app suspend/resume. Push frame back in frame stack
Expand Down Expand Up @@ -527,12 +538,12 @@ export class Frame extends FrameBase {
// Don't destroy current and executing entries or UI will look blank.
// We will do it in setCurrent.
if (entry !== executingEntry) {
clearEntry(entry);
this._disposeBackstackEntry(entry);
}
});

if (current && !executingEntry) {
clearEntry(current);
this._disposeBackstackEntry(current);
}

this._android.rootViewGroup = null;
Expand Down Expand Up @@ -641,19 +652,6 @@ function restoreTransitionState(entry: BackstackEntry, snapshot: TransitionState
expandedEntry.transitionName = snapshot.transitionName;
}

function clearEntry(entry: BackstackEntry): void {
if (entry.fragment) {
_clearFragment(entry);
}

entry.recreated = false;
entry.fragment = null;
const page = entry.resolvedPage;
if (page && page._context) {
entry.resolvedPage._tearDownUI(true);
}
}

let framesCounter = 0;
const framesCache = new Array<WeakRef<AndroidFrame>>();

Expand Down
17 changes: 17 additions & 0 deletions packages/core/ui/frame/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ export class Frame extends FrameBase {
}

public disposeNativeView() {
const current = this._currentEntry;
const executingEntry = this._executingContext ? this._executingContext.entry : null;

if (executingEntry) {
this._disposeBackstackEntry(executingEntry);
}

this.backStack.forEach((entry) => {
if (entry !== executingEntry) {
this._disposeBackstackEntry(entry);
}
});

if (current) {
this._disposeBackstackEntry(current);
}

this._removeFromFrameStack();
this.viewController = null;
this._animatedDelegate = null;
Expand Down
Loading