【问题标题】:ASIHTTPRequest crashing in performInvocationASIHTTPRequest 在 performInvocation 中崩溃
【发布时间】:2011-09-23 20:11:33
【问题描述】:

我在 performInvocation: 方法的 ASIHTTPRequest 中遇到了崩溃。

堆栈是:

ASIHTTPRequest performInvocation:onTarget:releasingObject: 1877
ASIHTTPRequest performSelector:onTarget:withObject:amount:callerToRetain: 1870
ASIHTTPRequest updateProgressIndicator:withProgress:ofTotal: 1903
ASINetworkQueue request:didReceiveBytes: 240
ASIHTTPRequest performInvocation:onTarget:releasingObject: 1877

这是发生崩溃的方法:

+ (void)performInvocation:(NSInvocation *)invocation onTarget:(id *)target releasingObject:(id)objectToRelease
{
  if (*target && [*target respondsToSelector:[invocation selector]]) {
    [invocation invokeWithTarget:*target];
  }
    CFRelease(invocation);
    if (objectToRelease) {
        CFRelease(objectToRelease);
    }
}

我相信它发生在 invokeWithTarget 调用上。

这种情况很少发生,但在大规模部署中却经常发生。

四处搜索,我发现一个模糊的添加参考:

[cbInvocation 保留参数];

返回 performSelector:... 就在 [cbInvocation performSelectorOnMainThread:...] 调用之前。但这似乎并不具有权威性,而且我不确定我是否理解那里发生的事情足以做出和/或信任这种改变。我无法在本地重现该问题,但我从现场收到了大量带有此堆栈跟踪的崩溃报告。

顺便说一句,这是在 iOS 代码上。

有人知道这可能是什么吗?

【问题讨论】:

    标签: objective-c ios4 asihttprequest


    【解决方案1】:

    您的 downloadProgressDelegate 已被释放,但并未先将其从 ASIHTTPRequest 的 downloadProgressDelegate 中删除。

    在您的下载进度委托的 dealloc 实现中,调用:

    [request setDownloadProgressDelegate:nil];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多