1. (js 与webview 交互崩溃)-[CFRunLoopTimer release]: message sent to deallocated instance 0x62398f80

I've fixed this, just call a dummy stringByEvaluatingJavaScriptFromString on the UIWebView before invoking a method on the context. I believe the reason this works is the call into javascript is done on the Web Thread and it uses a timer to receive the reply back to the main thread, when calling invoke this timer wasn't created so when the reply comes back from the Web Thread it crashes trying to release a timer that was never created in the first place. By using the proper API stringByEvaluatingJavaScriptFromString in insures the timer is created and then the invokeMethod can make use of the same timer.

方法一:

JSContext* context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
JSValue* value = context[@"Colors"]; // timer CFRelease crash fix
[webView stringByEvaluatingJavaScriptFromString:nil]; [value invokeMethod:@"update" withArguments:@[objectID,modifier]]; 方法二:
NSDictionary *userInfoDic = [self getResponseDicLocationSuccess:isSuccess];
NSString *responseStr = [userInfoDic jsonString];
if (responseStr.length <= 0) {
NSAssert(NO, nil);
return;
}
// [NSThread sleepForTimeInterval:1];
dispatch_async(dispatch_get_main_queue(), ^{
if (self.context && responseStr.length > 0) {
JSValue *callBackValue = self.context[@"mobileCallback"];
if (callBackValue) {
[callBackValue callWithArguments:@[responseStr]];
}
}
});

最新文章

  1. ios crash的原因与抓取crash日志的方法
  2. 【hbase0.96】基于hadoop搭建hbase的心得
  3. C++开发过程多线程同步lock的实现
  4. CSS水平垂直居中的几种方法
  5. 如何在html结构标签中使用js 变量 生成可变化的 title标题?
  6. 804 pretest 解题
  7. js便签笔记(13)——jsonp其实很简单【ajax跨域请求】
  8. Github 终于开始认真考虑开源项目许可证了
  9. 让wordpress投稿作者在后台只看到自己的文章
  10. 移动端调试 weinre
  11. 转载crontab例行工作调度
  12. [PWA] 14. Loop cursor
  13. android基于XMPP的消息推送机制
  14. spring整合redis客户端及缓存接口设计(转)
  15. 认识和选用常用的几种 GPRS 模块(转)
  16. C#进阶--WebApi异常处理机制
  17. Docker 创建ubuntu ,ssh,vnc 可连接
  18. 每次用 selenium 操作浏览器都还原了 (比如没有浏览器历史记录)
  19. hdu2159 FATE----完全背包
  20. linux上apache并发数与服务器内存关系计算!

热门文章

  1. JS调用OC方法并传值,OC调用JS方法并传值////////////////////////zz
  2. Media Queries使用方法
  3. SQL Server 2008连接字符串写法大全
  4. PHP文件操作:遍历文件目录
  5. 写Python脚本语言时,“SyntaxError: Non-ASCII character &#39;\xe6&#39; in file”错误的处理
  6. php常用函数file
  7. Mysql 5.7 Linux安装详细步骤
  8. IOS UITableview代理方法总结
  9. PHP之初识PHP(1)
  10. linux文件基本属性