Skip to content

Commit 75105e6

Browse files
danilobuergerfacebook-github-bot
authored andcommitted
Start surface after setting the delegate (#33402)
Summary: When starting the surface, _propagateStageChange is called. This checks the delegate to call surface:didChangeStage: on it. When initWithSurface:sizeMeasureMode: is called after start, then the delegate will be nil and thus not be called. This turns it around so a delegate is present for the surface to propagate its state to. This fixes RCTContentDidAppearNotification not getting posted otherwise. ## Changelog [iOS] [Fixed] - Post RCTContentDidAppearNotification with new arch Pull Request resolved: #33402 Test Plan: I found it best to set a breakpoint in XCode to where RCTContentDidAppearNotification is being posted. Prior to the patch that breakpoint will not be called. After applying the patch, it will be called. Reviewed By: philIip Differential Revision: D34753329 Pulled By: ShikaSD fbshipit-source-id: cc44a4c3a787d49e22e9d0c3a82c0f11ed281a0a
1 parent ae75664 commit 75105e6

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm

+4-7
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
7373
// `RCTRootViewSizeFlexibilityNone` is the RCTRootView's default.
7474
RCTSurfaceSizeMeasureMode sizeMeasureMode = convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibilityNone);
7575

76-
id<RCTSurfaceProtocol> surface = [[self class] createSurfaceWithBridge:bridge
77-
moduleName:moduleName
78-
initialProperties:initialProperties];
79-
[surface start];
80-
if (self = [super initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) {
81-
// Nothing specific to do.
82-
}
76+
self = [super initWithBridge:bridge
77+
moduleName:moduleName
78+
initialProperties:initialProperties
79+
sizeMeasureMode:sizeMeasureMode];
8380

8481
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
8582

React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
4646
id<RCTSurfaceProtocol> surface = [[self class] createSurfaceWithBridge:bridge
4747
moduleName:moduleName
4848
initialProperties:initialProperties];
49-
[surface start];
50-
return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
49+
if (self = [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) {
50+
[surface start];
51+
}
52+
return self;
5153
}
5254

5355
- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface

0 commit comments

Comments
 (0)