cmd/ebitenmobile: bug fix: dead lock due to @synchronized

Closes #2407
This commit is contained in:
Hajime Hoshi 2022-10-25 13:36:54 +09:00
parent 2cf651bed8
commit 62cbe99a27

View File

@ -229,6 +229,7 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
if (!active_) { if (!active_) {
return; return;
} }
}
if (EbitenmobileviewIsGL()) { if (EbitenmobileviewIsGL()) {
[[self glkView] setNeedsDisplay]; [[self glkView] setNeedsDisplay];
@ -236,6 +237,7 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
[self updateEbiten]; [self updateEbiten];
} }
@synchronized(self) {
if (explicitRendering_) { if (explicitRendering_) {
[displayLink_ setPaused:YES]; [displayLink_ setPaused:YES];
} }
@ -243,15 +245,14 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
} }
- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect { - (void)glkView:(GLKView*)view drawInRect:(CGRect)rect {
@synchronized(self) {
[self updateEbiten]; [self updateEbiten];
} }
}
- (void)updateEbiten { - (void)updateEbiten {
if (error_) { if (error_) {
return; return;
} }
NSError* err = nil; NSError* err = nil;
EbitenmobileviewUpdate(&err); EbitenmobileviewUpdate(&err);
if (err != nil) { if (err != nil) {
@ -303,26 +304,28 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
@synchronized(self) { @synchronized(self) {
active_ = false; active_ = false;
}
NSError* err = nil; NSError* err = nil;
EbitenmobileviewSuspend(&err); EbitenmobileviewSuspend(&err);
if (err != nil) { if (err != nil) {
[self onErrorOnGameUpdate:err]; [self onErrorOnGameUpdate:err];
} }
} }
}
- (void)resumeGame { - (void)resumeGame {
NSAssert(started_, @"resumeGame must not be called before viewDidLoad is called"); NSAssert(started_, @"resumeGame must not be called before viewDidLoad is called");
@synchronized(self) { @synchronized(self) {
active_ = true; active_ = true;
}
NSError* err = nil; NSError* err = nil;
EbitenmobileviewResume(&err); EbitenmobileviewResume(&err);
if (err != nil) { if (err != nil) {
[self onErrorOnGameUpdate:err]; [self onErrorOnGameUpdate:err];
} }
} }
}
- (void)setExplicitRenderingMode:(BOOL)explicitRendering { - (void)setExplicitRenderingMode:(BOOL)explicitRendering {
@synchronized(self) { @synchronized(self) {