iOS:fix sync in main thread

This commit is contained in:
pengfei.zhou 2020-02-27 14:50:26 +08:00 committed by osborn
parent c0c9252fc1
commit 03e5376909

View File

@ -38,18 +38,16 @@ - (instancetype)init {
if (self = [super init]) { if (self = [super init]) {
_jsQueue = dispatch_queue_create("doric.jsengine", DISPATCH_QUEUE_SERIAL); _jsQueue = dispatch_queue_create("doric.jsengine", DISPATCH_QUEUE_SERIAL);
_bridgeExtension = [[DoricBridgeExtension alloc] init]; _bridgeExtension = [[DoricBridgeExtension alloc] init];
dispatch_sync(dispatch_get_main_queue(), ^{ NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; _innerEnvironmentDictionary = @{
_innerEnvironmentDictionary = @{ @"platform": @"iOS",
@"platform": @"iOS", @"platformVersion": [[UIDevice currentDevice] systemVersion],
@"platformVersion": [[UIDevice currentDevice] systemVersion], @"appName": infoDictionary[@"CFBundleName"],
@"appName": infoDictionary[@"CFBundleName"], @"appVersion": infoDictionary[@"CFBundleShortVersionString"],
@"appVersion": infoDictionary[@"CFBundleShortVersionString"], @"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width), @"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height), @"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height), };
};
});
dispatch_async(_jsQueue, ^() { dispatch_async(_jsQueue, ^() {
self.timers = [[NSMutableDictionary alloc] init]; self.timers = [[NSMutableDictionary alloc] init];
[self initJSEngine]; [self initJSEngine];