From e6debfe1ddbdd2cbcbc4430702c793b0cdb34c14 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 12 Aug 2019 10:48:53 -0700 Subject: [PATCH] Fix crash during reload on Marketplace Home Summary: # What's the problem? `RCTSurfacePresenter._scheduler` is deallocated in `RCTSurfacePresenter.handleBridgeWillReloadNotification`. It shouldn't be used before `RCTSurfacePresenter.handleJavaScriptDidLoadNotification` is called because that's when new `RCTSurfacePresenter._batchedBridge` is created, scheduler depends on this new `RCTSurfacePresenter._batchedBridge`. But it is, it means that it is created with the old bridge, this means that it gets deallocated right away. First access point of old bridge is in `RCTSurfacePresenter.setMinimumSize`. # What's the fix? Make sure surface has correct stage before calling layout methods. The other idea was to return early in `RCTSurfacePresenter.setMinimumSize` in case bridge isn't setup. # Problems? 1. Following error still appears after reload {F176556210} 2. There is a white space for a while. By white space a mean the screen stays white for a short period of time before displaying content. Reviewed By: fkgozali, JoshuaGross Differential Revision: D16762443 fbshipit-source-id: 5a2a880b0f5345f268291c86811264f42f6058b3 --- .../Surface/SurfaceHostingView/RCTSurfaceHostingView.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm index c7ed41971ae..9afbaad0ff2 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm @@ -80,8 +80,10 @@ RCT_NOT_IMPLEMENTED(- (nullable instancetype)initWithCoder:(NSCoder *)coder) &maximumSize ); - [_surface setMinimumSize:minimumSize - maximumSize:maximumSize]; + if (RCTSurfaceStageIsRunning(_stage)) { + [_surface setMinimumSize:minimumSize + maximumSize:maximumSize]; + } } - (CGSize)intrinsicContentSize