Skip to content

Commit

Permalink
Start surface after setting the delegate (facebook#33402)
Browse files Browse the repository at this point in the history
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.

[iOS] [Fixed] - Post RCTContentDidAppearNotification with new arch

Pull Request resolved: facebook#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
  • Loading branch information
danilobuerger authored and Saadnajmi committed Jan 14, 2023
1 parent 2ec6548 commit 756067a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Expand Up @@ -73,14 +73,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
// `RCTRootViewSizeFlexibilityNone` is the RCTRootView's default.
RCTSurfaceSizeMeasureMode sizeMeasureMode = convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibilityNone);

id<RCTSurfaceProtocol> surface = [[self class] createSurfaceWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
[surface start];
if (self = [super initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) {
self.backgroundColor = [RCTUIColor whiteColor]; // [macOS]
// Nothing specific to do.
}
self = [super initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties
sizeMeasureMode:sizeMeasureMode];

RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");

Expand Down
Expand Up @@ -45,8 +45,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
id<RCTSurfaceProtocol> surface = [[self class] createSurfaceWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
[surface start];
return [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode];
if (self = [self initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) {
[surface start];
}
return self;
}

- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
Expand Down

0 comments on commit 756067a

Please sign in to comment.