From 620f83aae50f00e3e21987d73b2d42768ebe8bea Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 11 Nov 2019 02:59:37 -0800 Subject: [PATCH] Fix crash when accessing _viewRegistry Summary: Changelog: [internal] Fixes fabric specific crash `_viewRegistry` is not thread safe and accessing it on another thread can cause a crash. Calling it inside `RCTUnsafeExecuteOnMainQueueSync` shouldn't degrade performance because it is only used as a fallback. Changelog: [Internal] Reviewed By: rickhanlonii Differential Revision: D18421789 fbshipit-source-id: 2adff434afe0a3c19318c95b051ee91ccf6293e5 --- React/Modules/RCTUIManager.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 53af9041faf..7b969de9327 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -335,7 +335,10 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation) return name; } - UIView *view = _viewRegistry[reactTag]; + __block UIView *view; + RCTUnsafeExecuteOnMainQueueSync(^{ + view = self->_viewRegistry[reactTag]; + }); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundeclared-selector"