From d57fe41dd0a842b5a9c7f2b4cda35c6f2f5f8416 Mon Sep 17 00:00:00 2001 From: Douglas Machado Date: Fri, 10 Jun 2022 14:45:39 -0300 Subject: [PATCH 1/2] fix(core): iOS app memory leak after using the 'presentViewController' navigation --- packages/core/ui/core/view/index.ios.ts | 5 ++++- packages/core/ui/frame/index.ios.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index d995ab546c..ddf7e9a691 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -517,7 +517,10 @@ export class View extends ViewCommon implements ViewDefinition { parentController.presentViewControllerAnimatedCompletion(controller, animated, null); const transitionCoordinator = parentController.transitionCoordinator; if (transitionCoordinator) { - transitionCoordinator.animateAlongsideTransitionCompletion(null, () => this._raiseShownModallyEvent()); + transitionCoordinator.animateAlongsideTransitionCompletion(null, () => { + this._raiseShownModallyEvent(); + controller = null; + }); } else { // Apparently iOS 9+ stops all transitions and animations upon application suspend and transitionCoordinator becomes null here in this case. // Since we are not waiting for any transition to complete, i.e. transitionCoordinator is null, we can directly raise our shownModally event. diff --git a/packages/core/ui/frame/index.ios.ts b/packages/core/ui/frame/index.ios.ts index 1686f9e777..f18636e6dd 100644 --- a/packages/core/ui/frame/index.ios.ts +++ b/packages/core/ui/frame/index.ios.ts @@ -42,6 +42,8 @@ export class Frame extends FrameBase { this._removeFromFrameStack(); this.viewController = null; this._ios.controller = null; + this._animatedDelegate = null; + this._ios = null; super.disposeNativeView(); } From bee6568176f0b4ef756fd3ad09ddda9e90472962 Mon Sep 17 00:00:00 2001 From: Douglas Machado Date: Fri, 10 Jun 2022 15:56:47 -0300 Subject: [PATCH 2/2] fix(core): iOS app memory leak after using the 'presentViewController' navigation (refactoring) --- packages/core/ui/core/view/index.ios.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index ddf7e9a691..00438af85b 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -517,16 +517,14 @@ export class View extends ViewCommon implements ViewDefinition { parentController.presentViewControllerAnimatedCompletion(controller, animated, null); const transitionCoordinator = parentController.transitionCoordinator; if (transitionCoordinator) { - transitionCoordinator.animateAlongsideTransitionCompletion(null, () => { - this._raiseShownModallyEvent(); - controller = null; - }); + transitionCoordinator.animateAlongsideTransitionCompletion(null, () => this._raiseShownModallyEvent()); } else { // Apparently iOS 9+ stops all transitions and animations upon application suspend and transitionCoordinator becomes null here in this case. // Since we are not waiting for any transition to complete, i.e. transitionCoordinator is null, we can directly raise our shownModally event. // Take a look at https://github.com/NativeScript/NativeScript/issues/2173 for more info and a sample project. this._raiseShownModallyEvent(); } + controller = null; } protected _hideNativeModalView(parent: View, whenClosedCallback: () => void) {