diff --git a/dsbridge/DWKWebView.m b/dsbridge/DWKWebView.m index 2e54d3c..2e48e74 100644 --- a/dsbridge/DWKWebView.m +++ b/dsbridge/DWKWebView.m @@ -294,20 +294,26 @@ -(NSString *)call:(NSString*) method :(NSString*) argStr del=[@"delete window." stringByAppendingString:cb]; } NSString*js=[NSString stringWithFormat:@"try {%@(JSON.parse(decodeURIComponent(\"%@\")).data);%@; } catch(e){};",cb,(value == nil) ? @"" : value,del]; - __strong typeof(self) strongSelf = weakSelf; - @synchronized(self) - { - UInt64 t=[[NSDate date] timeIntervalSince1970]*1000; - jsCache=[jsCache stringByAppendingString:js]; - if(t-lastCallTime<50){ - if(!isPending){ - [strongSelf evalJavascript:50]; - isPending=true; + dispatch_async(dispatch_get_main_queue(), ^{ + //__strong typeof(self) strongSelf = weakSelf; + if (weakSelf != nil) { + NSLog(@"evaluateJavaScript%@",js); + @synchronized(weakSelf) + { + // UInt64 t=[[NSDate date] timeIntervalSince1970]*1000; + // jsCache=[jsCache stringByAppendingString:js]; + // if(t-lastCallTime<50){ + // if(!isPending){ + // [strongSelf evalJavascript:50]; + // isPending=true; + // } + // }else{ + // [strongSelf evalJavascript:0]; + // } + [weakSelf evaluateJavaScript:js completionHandler:nil]; } - }else{ - [strongSelf evalJavascript:0]; } - } + }); };