diff --git a/package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h b/package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h index 1723ec0dac..2982d80a0f 100644 --- a/package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +++ b/package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h @@ -2,7 +2,6 @@ #import #import -#import #include #include @@ -30,8 +29,10 @@ static void handleNotification(CFNotificationCenterRef center, void *observer, class RNSkiOSPlatformContext : public RNSkPlatformContext { public: - RNSkiOSPlatformContext(jsi::Runtime *runtime, RCTBridge *bridge) - : RNSkPlatformContext(runtime, bridge.jsCallInvoker, + RNSkiOSPlatformContext( + jsi::Runtime *runtime, RCTBridge *bridge, + std::shared_ptr jsCallInvoker) + : RNSkPlatformContext(runtime, jsCallInvoker, [[UIScreen mainScreen] scale]) { // We need to make sure we invalidate when modules are freed diff --git a/package/ios/RNSkia-iOS/SkiaManager.h b/package/ios/RNSkia-iOS/SkiaManager.h index b559eb6ef4..a87a43a2dd 100644 --- a/package/ios/RNSkia-iOS/SkiaManager.h +++ b/package/ios/RNSkia-iOS/SkiaManager.h @@ -12,6 +12,8 @@ - (void)invalidate; -- (instancetype)initWithBridge:(RCTBridge *)bridge; +- (instancetype)initWithBridge:(RCTBridge *)bridge + jsInvoker:(std::shared_ptr) + jsInvoker; @end diff --git a/package/ios/RNSkia-iOS/SkiaManager.mm b/package/ios/RNSkia-iOS/SkiaManager.mm index 8c3d291dc7..7d3cf594d5 100644 --- a/package/ios/RNSkia-iOS/SkiaManager.mm +++ b/package/ios/RNSkia-iOS/SkiaManager.mm @@ -6,8 +6,6 @@ #import #import -#import - #import "RNSkiOSPlatformContext.h" @implementation SkiaManager { @@ -26,7 +24,9 @@ - (void)invalidate { _skManager = nullptr; } -- (instancetype)initWithBridge:(RCTBridge *)bridge { +- (instancetype)initWithBridge:(RCTBridge *)bridge + jsInvoker:(std::shared_ptr) + jsInvoker { self = [super init]; if (self) { RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge; @@ -37,8 +37,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge { // Create the RNSkiaManager (cross platform) _skManager = std::make_shared( - jsRuntime, bridge.jsCallInvoker, - std::make_shared(jsRuntime, bridge)); + jsRuntime, jsInvoker, + std::make_shared(jsRuntime, bridge, + jsInvoker)); } } return self; diff --git a/package/ios/RNSkiaModule.mm b/package/ios/RNSkiaModule.mm index fe7f2a4eb4..591439f87b 100644 --- a/package/ios/RNSkiaModule.mm +++ b/package/ios/RNSkiaModule.mm @@ -1,9 +1,11 @@ #import "RNSkiaModule.h" #import +#import @implementation RNSkiaModule { SkiaManager *skiaManager; + std::shared_ptr jsInvoker; } RCT_EXPORT_MODULE() @@ -33,13 +35,17 @@ - (void)invalidate { return @true; } RCTBridge *bridge = [RCTBridge currentBridge]; - skiaManager = [[SkiaManager alloc] initWithBridge:bridge]; + if (!jsInvoker) { + jsInvoker = bridge.jsCallInvoker; + } + skiaManager = [[SkiaManager alloc] initWithBridge:bridge jsInvoker:jsInvoker]; return @true; } #ifdef RCT_NEW_ARCH_ENABLED - (std::shared_ptr)getTurboModule: (const facebook::react::ObjCTurboModule::InitParams &)params { + jsInvoker = params.jsInvoker; return std::make_shared(params); } #endif