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


  • 相关阅读:
    Java之抽象类,多态,接口
    Java之抽象类,多态
    Java之类。实例初始化
    Java基础之继承
    java面向对象之工具类
    Java基础面向对象封装
    Python入门学习资料推荐
    内网安全「攻防」学习指南
    windows文件扩展名
    java 的包命名规范
  • 原文地址:https://www.cnblogs.com/muyushifang07/p/5249722.html
Copyright © 2011-2022 走看看