Skip to content

Commit 4febe2a

Browse files
author
Hristo Hristov
committed
FragmentClass instance is cached so that JS part does not die before …
* FragmentClass instance is cached so that JS part does not die before native counter part. * Fix tslint error.
1 parent 768516f commit 4febe2a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ui/frame/frame.android.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {View} from "ui/core/view";
77
import {Observable} from "data/observable";
88
import * as application from "application";
99
import * as types from "utils/types";
10-
import * as utils from "utils/utils";
1110

1211
global.moduleMerge(frameCommon, exports);
1312

@@ -19,6 +18,7 @@ var IS_BACK = "_isBack";
1918
var NAV_DEPTH = "_navDepth";
2019
var CLEARING_HISTORY = "_clearingHistory";
2120
var FRAMEID = "_frameId";
21+
var FRAGMENT = "_FRAGMENT";
2222

2323
var navDepth = -1;
2424

@@ -197,6 +197,9 @@ export class Frame extends frameCommon.Frame {
197197
newFragment.frame = this;
198198
newFragment.entry = backstackEntry;
199199

200+
// Cahce newFragment at backstackEntry instance so that it cannot die while backstackEntry is alive.
201+
backstackEntry[FRAGMENT] = newFragment;
202+
200203
backstackEntry[BACKSTACK_TAG] = newFragmentTag;
201204
backstackEntry[NAV_DEPTH] = navDepth;
202205

@@ -664,7 +667,7 @@ class FragmentClass extends android.app.Fragment {
664667
public onDestroy(): void {
665668
trace.write(`${this.getTag()}.onDestroy()`, trace.categories.NativeLifecycle);
666669
super.onDestroy();
667-
utils.GC();
670+
this.entry[FRAGMENT] = undefined;
668671
}
669672
}
670673

0 commit comments

Comments
 (0)