@dolami-inc/react-native-expo-unity 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ExpoUnityView.swift +9 -0
- package/ios/UnityBridge.mm +7 -1
- package/package.json +1 -1
package/ios/ExpoUnityView.swift
CHANGED
|
@@ -72,6 +72,13 @@ class ExpoUnityView: ExpoView {
|
|
|
72
72
|
return
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Wrap window manipulation in an explicit CA transaction to ensure all
|
|
76
|
+
// layer tree changes from the window swap are committed atomically.
|
|
77
|
+
// Without this, pending SDWebImage callbacks in the same main queue
|
|
78
|
+
// drain cycle can trigger CA::Transaction::commit() on a stale context,
|
|
79
|
+
// crashing in _dispatch_async_f_slow.
|
|
80
|
+
CATransaction.begin()
|
|
81
|
+
|
|
75
82
|
if let unityWindow = UnityBridge.shared().unityWindow() {
|
|
76
83
|
if let myWindow = self.window, unityWindow != myWindow {
|
|
77
84
|
unityWindow.isHidden = true
|
|
@@ -84,6 +91,8 @@ class ExpoUnityView: ExpoView {
|
|
|
84
91
|
if unityView.superview != self {
|
|
85
92
|
self.addSubview(unityView)
|
|
86
93
|
}
|
|
94
|
+
|
|
95
|
+
CATransaction.commit()
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
override func layoutSubviews() {
|
package/ios/UnityBridge.mm
CHANGED
|
@@ -40,6 +40,7 @@ static UnityBridge *_shared = nil;
|
|
|
40
40
|
|
|
41
41
|
#import <UnityFramework/UnityFramework.h>
|
|
42
42
|
#import <UnityFramework/NativeCallProxy.h>
|
|
43
|
+
#import <QuartzCore/CATransaction.h>
|
|
43
44
|
|
|
44
45
|
#ifdef DEBUG
|
|
45
46
|
#include <mach-o/ldsyms.h>
|
|
@@ -105,12 +106,17 @@ static UnityBridge *_shared = nil;
|
|
|
105
106
|
|
|
106
107
|
self.ufwInternal = ufw;
|
|
107
108
|
|
|
108
|
-
// Hide Unity's window — we embed its rootView in our own view
|
|
109
|
+
// Hide Unity's window — we embed its rootView in our own view.
|
|
110
|
+
// Wrap in CATransaction to commit layer tree changes atomically
|
|
111
|
+
// before other main queue callbacks (e.g. SDWebImage) can fire
|
|
112
|
+
// and attempt CA commits on a stale rendering context.
|
|
113
|
+
[CATransaction begin];
|
|
109
114
|
UIWindow *unityWindow = [ufw appController].window;
|
|
110
115
|
if (unityWindow) {
|
|
111
116
|
unityWindow.hidden = YES;
|
|
112
117
|
unityWindow.userInteractionEnabled = NO;
|
|
113
118
|
}
|
|
119
|
+
[CATransaction commit];
|
|
114
120
|
|
|
115
121
|
NSLog(@"[ExpoUnity] Unity initialized");
|
|
116
122
|
}
|