Skip to content

Commit d44e589

Browse files
committed
Fix empty arView
1 parent a6db92a commit d44e589

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ios/RCTARKit.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,26 @@ @interface RCTARKit () <ARSCNViewDelegate, ARSessionDelegate, UIGestureRecognize
2222
@end
2323

2424

25+
dispatch_block_t block) {
26+
if ([NSThread isMainThread]) {
27+
dispatch_once(predicate, block);
28+
} else {
29+
if (DISPATCH_EXPECT(*predicate == 0L, NO)) {
30+
dispatch_sync(dispatch_get_main_queue(), ^{
31+
dispatch_once(predicate, block);
32+
});
33+
}
34+
}
35+
}
36+
37+
2538
@implementation RCTARKit
2639

2740
+ (instancetype)sharedInstance {
2841
static RCTARKit *instance = nil;
2942
static dispatch_once_t onceToken;
3043

31-
dispatch_once(&onceToken, ^{
44+
dispatch_once_on_main_thread(&onceToken, ^{
3245
if (instance == nil) {
3346
ARSCNView *arView = [[ARSCNView alloc] init];
3447
instance = [[self alloc] initWithARView:arView];
@@ -67,7 +80,6 @@ - (instancetype)initWithARView:(ARSCNView *)arView {
6780
// start ARKit
6881
[self addSubview:arView];
6982
[self resume];
70-
7183
}
7284
return self;
7385
}

0 commit comments

Comments
 (0)