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,13 +229,15 @@ 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];
} else { } else {
[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,11 +304,12 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
@synchronized(self) { @synchronized(self) {
active_ = false; active_ = false;
NSError* err = nil; }
EbitenmobileviewSuspend(&err);
if (err != nil) { NSError* err = nil;
[self onErrorOnGameUpdate:err]; EbitenmobileviewSuspend(&err);
} if (err != nil) {
[self onErrorOnGameUpdate:err];
} }
} }
@ -316,11 +318,12 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
@synchronized(self) { @synchronized(self) {
active_ = true; active_ = true;
NSError* err = nil; }
EbitenmobileviewResume(&err);
if (err != nil) { NSError* err = nil;
[self onErrorOnGameUpdate:err]; EbitenmobileviewResume(&err);
} if (err != nil) {
[self onErrorOnGameUpdate:err];
} }
} }