From 9be73858e43e6acd2ad48ab2f1acd483d4243023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20B=C3=BCrger?= Date: Wed, 9 Mar 2022 15:12:48 +0100 Subject: [PATCH] Start surface after setting the delegate 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. --- .../SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm | 8 +------- .../Surface/SurfaceHostingView/RCTSurfaceHostingView.mm | 6 ++++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm index 626a47ed057c..58cb87ea98ee 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm @@ -73,13 +73,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge // `RCTRootViewSizeFlexibilityNone` is the RCTRootView's default. RCTSurfaceSizeMeasureMode sizeMeasureMode = convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibilityNone); - id surface = [[self class] createSurfaceWithBridge:bridge - moduleName:moduleName - initialProperties:initialProperties]; - [surface start]; - if (self = [super initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) { - // Nothing specific to do. - } + self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties sizeMeasureMode:sizeMeasureMode]; RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm index f271bb769571..9dbfad6548dc 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm @@ -46,8 +46,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge id 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)surface