@@ -43,8 +43,7 @@ + (void)setView:(RCTBridge*)bridge jsRunLoop:(NSRunLoop*)jsRunLoop mktView:(MTKV
43
43
44
44
[jsRunLoop performBlock: ^{
45
45
if (bridge != currentBridge) {
46
- currentBridge = bridge;
47
- [BabylonNativeInterop setCurrentNativeInstance: mtkView width: width height: height];
46
+ [BabylonNativeInterop setCurrentNativeInstance: bridge mtkView: mtkView width: width height: height];
48
47
} else if (currentNativeInstance) {
49
48
if (mtkView != currentView) {
50
49
[BabylonNativeInterop setCurrentView: mtkView];
@@ -104,6 +103,7 @@ + (void)reportTouchEvent:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event {
104
103
}
105
104
106
105
+ (void )whenInitialized : (RCTBridge*)bridge resolve : (RCTPromiseResolveBlock)resolve {
106
+ const std::lock_guard<std::mutex> lock (mapMutex);
107
107
if (bridge == currentBridge) {
108
108
resolve ([NSNumber numberWithUnsignedLong: reinterpret_cast <uintptr_t >(currentNativeInstance.get ())]);
109
109
} else {
@@ -116,16 +116,20 @@ + (void)setCurrentView:(MTKView*)mtkView {
116
116
activeTouches = [NSMutableArray new ];
117
117
}
118
118
119
- + (void )setCurrentNativeInstance : (MTKView *)mtkView width : (int )width height : (int )height {
119
+ + (void )setCurrentNativeInstance : (RCTBridge*) bridge mtkView : ( MTKView *)mtkView width : (int )width height : (int )height {
120
120
[BabylonNativeInterop setCurrentView: mtkView];
121
121
122
- const std::lock_guard<std::mutex> lock (mapMutex);
122
+ {
123
+ const std::lock_guard<std::mutex> lock (mapMutex);
123
124
124
- currentNativeInstance. reset () ;
125
+ currentBridge = bridge ;
125
126
126
- jsi::Runtime* jsiRuntime = GetJSIRuntime (currentBridge);
127
- if (jsiRuntime) {
128
- currentNativeInstance = std::make_unique<Babylon::Native>(GetJSIRuntime (currentBridge), (__bridge void *)mtkView, width, height);
127
+ currentNativeInstance.reset ();
128
+
129
+ jsi::Runtime* jsiRuntime = GetJSIRuntime (currentBridge);
130
+ if (jsiRuntime) {
131
+ currentNativeInstance = std::make_unique<Babylon::Native>(GetJSIRuntime (currentBridge), (__bridge void *)mtkView, width, height);
132
+ }
129
133
}
130
134
131
135
auto initializationPromisesIterator = initializationPromises.find ((__bridge void *)currentBridge);
0 commit comments