diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm index 3f72b057d..539e236bb 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm @@ -69,6 +69,7 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz if (self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties sizeMeasureMode:sizeMeasureMode]) { self.backgroundColor = [UIColor whiteColor]; + [super.surface start]; } RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm index 9f55e6351..7e4284abe 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm @@ -51,7 +51,6 @@ RCT_NOT_IMPLEMENTED(- (nullable instancetype)initWithCoder:(NSCoder *)coder) { if (self = [super initWithFrame:CGRectZero]) { _surface = surface; - [_surface start]; _sizeMeasureMode = sizeMeasureMode; _surface.delegate = self; diff --git a/React/Fabric/RCTSurfacePresenter.h b/React/Fabric/RCTSurfacePresenter.h index 0e01623b7..c4f1f98fb 100644 --- a/React/Fabric/RCTSurfacePresenter.h +++ b/React/Fabric/RCTSurfacePresenter.h @@ -38,10 +38,14 @@ NS_ASSUME_NONNULL_BEGIN @interface RCTSurfacePresenter (Surface) /** - * Surface uses those methods to register itself in the Presenter. - * Registering initiates running, rendering and mounting processes. + * Surface uses these methods to register itself in the Presenter. */ - (void)registerSurface:(RCTFabricSurface *)surface; +/** + * Starting initiates running, rendering and mounting processes. + * Should be called after registerSurface and any other surface-specific setup is done + */ +- (void)startSurface:(RCTFabricSurface *)surface; - (void)unregisterSurface:(RCTFabricSurface *)surface; - (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface; diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index d7f56e3fb..9685f6c78 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -99,6 +99,10 @@ using namespace facebook::react; - (void)registerSurface:(RCTFabricSurface *)surface { [_surfaceRegistry registerSurface:surface]; +} + +- (void)startSurface:(RCTFabricSurface *)surface +{ [self _startSurface:surface]; } diff --git a/React/Fabric/Surface/RCTFabricSurface.mm b/React/Fabric/Surface/RCTFabricSurface.mm index ddc187568..f5f55cf8e 100644 --- a/React/Fabric/Surface/RCTFabricSurface.mm +++ b/React/Fabric/Surface/RCTFabricSurface.mm @@ -55,6 +55,8 @@ _touchHandler = [RCTSurfaceTouchHandler new]; _stage = RCTSurfaceStageSurfaceDidInitialize; + + [_surfacePresenter registerSurface:self]; } return self; @@ -66,7 +68,8 @@ return NO; } - [_surfacePresenter registerSurface:self]; + [_surfacePresenter startSurface:self]; + return YES; }