From 6ba2aeefa8dfe031bf1dc46dbea29235aec31d61 Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Tue, 11 Feb 2020 06:55:58 -0800 Subject: [PATCH] LogBox - Deallocate _rootViewController to release surface reference and break cycle Summary: This def breaks a reference cycle in logbox causing a memory leak in development. Changelog: [iOS] [Fix] LogBox - Fix dependency cycle Reviewed By: PeteTheHeat Differential Revision: D19768068 fbshipit-source-id: 518b9c66499aa092465a9213f955965bffeebd88 --- React/CoreModules/RCTLogBox.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/React/CoreModules/RCTLogBox.mm b/React/CoreModules/RCTLogBox.mm index d224052696cef2..4faa4a2db84cea 100644 --- a/React/CoreModules/RCTLogBox.mm +++ b/React/CoreModules/RCTLogBox.mm @@ -70,8 +70,12 @@ - (void)dealloc - (void)show { + __weak __typeof(self) weakSelf = self; [RCTSharedApplication().delegate.window.rootViewController presentViewController:_rootViewController animated:NO completion:^{ - [self->_rootViewController.view becomeFirstResponder]; + __strong __typeof(self) strongSelf = weakSelf; + if (strongSelf) { + [strongSelf->_rootViewController.view becomeFirstResponder]; + } }]; }