zoukankan      html  css  js  c++  java
  • iOS 开发之崩溃日志分析

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


  • 相关阅读:
    grafana邮箱配置
    grafana集群配置
    CentOS7 配置OOM监控报警
    Mycat使用配置实践
    CentOS7安装JAVA环境
    CentOS7安装MYCAT中间件
    CentOS7安装MySQL5.6
    Mockingbird
    堆的建立与功能实现
    Matlab解决线性规划问题
  • 原文地址:https://www.cnblogs.com/muyushifang07/p/5249722.html
Copyright © 2011-2022 走看看