Fix Runtime Issues:

ScratchJr.m: runtime: UI API called from background thread: -[UIView removeFromSuperview] must be used from main thread only
IO.m: runtime: UI API called from background thread: -[UIWebView stringByEvaluatingJavaScriptFromString:] must be used from main thread only
This commit is contained in:
Donald 2018-09-11 09:32:02 +08:00
parent 6f59d224e7
commit 2da2fad26c
2 changed files with 10 additions and 6 deletions

View file

@ -280,12 +280,14 @@ NSMutableDictionary *soundtimers;
}
+ (void)soundEnded:(NSTimer*)timer {
NSString *soundName = [[timer userInfo] objectForKey:@"soundName"];
if (sounds[soundName] == nil) return;
NSString *callback = [NSString stringWithFormat:@"iOS.soundDone('%@');", soundName];
UIWebView *webview = [ViewController webview];
NSString *soundName = [[timer userInfo] objectForKey:@"soundName"];
if (sounds[soundName] == nil) return;
NSString *callback = [NSString stringWithFormat:@"iOS.soundDone('%@');", soundName];
UIWebView *webview = [ViewController webview];
dispatch_async(dispatch_get_main_queue(), ^{
[webview stringByEvaluatingJavaScriptFromString:callback];
}
});
}
+ (NSString *)stopSound :(NSString*)name {
AVAudioPlayer *snd = sounds[name];

View file

@ -19,7 +19,9 @@ NSString *oncomplete;
+ (NSString *) hideSplash :(NSString *)body{
UIImageView* splashScreen = [ViewController splashScreen];
[splashScreen removeFromSuperview];
dispatch_async(dispatch_get_main_queue(), ^{
[splashScreen removeFromSuperview];
});
return @"1";
}