@@ -264,13 +264,13 @@ export class Frame extends FrameBase {
264264 ! this . _currentEntry . fragment . isAdded ( ) ) {
265265 return ;
266266 }
267+ const fragment : androidx . fragment . app . Fragment = this . _currentEntry . fragment ;
268+ const fragmentManager : androidx . fragment . app . FragmentManager = fragment . getFragmentManager ( ) ;
267269
268- const manager : androidx . fragment . app . FragmentManager = this . _getFragmentManager ( ) ;
269- const transaction = manager . beginTransaction ( ) ;
270- const fragment = this . _currentEntry . fragment ;
270+ const transaction = fragmentManager . beginTransaction ( ) ;
271271 const fragmentExitTransition = fragment . getExitTransition ( ) ;
272272
273- // Reset animation to its initial state to prevent mirrorered effect when restore current fragment transitions
273+ // Reset animation to its initial state to prevent mirrored effect when restore current fragment transitions
274274 if ( fragmentExitTransition && fragmentExitTransition instanceof org . nativescript . widgets . CustomTransition ) {
275275 fragmentExitTransition . setResetOnTransitionEnd ( true ) ;
276276 }
@@ -637,7 +637,7 @@ function clearEntry(entry: BackstackEntry): void {
637637 entry . recreated = false ;
638638 entry . fragment = null ;
639639 const page = entry . resolvedPage ;
640- if ( page . _context ) {
640+ if ( page && page . _context ) {
641641 entry . resolvedPage . _tearDownUI ( true ) ;
642642 }
643643}
@@ -1032,6 +1032,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
10321032 }
10331033
10341034 private loadBitmapFromView ( view : android . view . View ) : android . graphics . Bitmap {
1035+ // Don't try to creat bitmaps with no dimensions as this causes a crash
1036+ // This might happen when showing and closing dialogs fast.
1037+ if ( ! ( view && view . getWidth ( ) > 0 && view . getHeight ( ) > 0 ) ) {
1038+ return undefined ;
1039+ }
1040+
10351041 // Another way to get view bitmap. Test performance vs setDrawingCacheEnabled
10361042 // const width = view.getWidth();
10371043 // const height = view.getHeight();
@@ -1041,7 +1047,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
10411047 // view.draw(canvas);
10421048
10431049 view . setDrawingCacheEnabled ( true ) ;
1044- const bitmap = android . graphics . Bitmap . createBitmap ( view . getDrawingCache ( ) ) ;
1050+ const drawCache = view . getDrawingCache ( ) ;
1051+ const bitmap = android . graphics . Bitmap . createBitmap ( drawCache ) ;
10451052 view . setDrawingCacheEnabled ( false ) ;
10461053
10471054 return bitmap ;
0 commit comments