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