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


  • 相关阅读:
    【转载】$.ajax()方法详解
    【转载】"从客户端中检测到有潜在危险的 Request.Form 值"的解决方案汇总
    jQuery获取select的选中项value和text
    AIDL
    SAX
    AsyncTask
    Handler
    ViewSwitch
    TabActivity
    AlarmManager
  • 原文地址:https://www.cnblogs.com/muyushifang07/p/5249722.html
Copyright © 2020-2023  润新知