@@ -7,7 +7,6 @@ import {View} from "ui/core/view";
77import { Observable } from "data/observable" ;
88import * as application from "application" ;
99import * as types from "utils/types" ;
10- import * as utils from "utils/utils" ;
1110
1211global . moduleMerge ( frameCommon , exports ) ;
1312
@@ -19,6 +18,7 @@ var IS_BACK = "_isBack";
1918var NAV_DEPTH = "_navDepth" ;
2019var CLEARING_HISTORY = "_clearingHistory" ;
2120var FRAMEID = "_frameId" ;
21+ var FRAGMENT = "_FRAGMENT" ;
2222
2323var 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