首页 > 移动平台 > 详细

iOS 开发之崩溃日志分析

时间:2016-03-07 11:51:41      阅读:223      评论:0      收藏:0      [点我收藏+]

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]];
            }
        }
    });


iOS 开发之崩溃日志分析

原文:http://www.cnblogs.com/muyushifang07/p/5249722.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!