【问题标题】:Debug objc_msgSend crash I cant reproduce调试 objc_msgSend 崩溃我无法重现
【发布时间】:2013-04-29 13:38:43
【问题描述】:

我的 iOS 应用程序的 bugsense 收到了一些崩溃报告,我无法重现,因此无法调试。一天发生 200 多次,所以我想这很严重。

我读过一些关于 NSZombie 的文章,但我无法重现崩溃,所以我猜它没用。 这是一个崩溃报告:

SIGSEGV
0 libobjc.A.dylib 0x3aa515b0 objc_msgSend + 15
1 UIKit 0x34d493df + 294
2 UIKit 0x34cae469 + 52
3 QuartzCore 0x34926099 + 160
4 QuartzCore 0x34925ff1 + 64
5 IOMobileFramebuffer 0x36ba1fd7 + 154
6 IOKit 0x33920449 IODispatchCalloutFromCFMessage + 192
7 CoreFoundation 0x32d035db + 118
8 CoreFoundation 0x32d0e173 + 34
9 CoreFoundation 0x32d0e117 + 138
10 CoreFoundation 0x32d0cf99 + 1384
11 CoreFoundation 0x32c7febd CFRunLoopRunSpecific + 356
12 CoreFoundation 0x32c7fd49 CFRunLoopRunInMode + 104
13 GraphicsServices 0x368562eb GSEventRunModal + 74
14 UIKit 0x34b95301 UIApplicationMain + 1120
15 My Bet main (main.m:16) Live 0x000705e7 0x6d000 + 13799

在一些类似的线程上,他们认为问题可能出在 UIAlertView 中,所以这里有一个关于我如何使用它们的示例: 在文件.h

UIAlertView *alertView;

在文件.m中

-(void)wait{
UIActivityIndicatorView * activityView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityView.frame = CGRectMake(121.0f, 50.0f, 37.0f, 37.0f);
[activityView startAnimating];
alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Searching...", @"") message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alertView addSubview:activityView];
[alertView show];
[NSThread detachNewThreadSelector:@selector(function) toTarget:self withObject:nil];
}
-(void)function{
// Do some web request
[alertView dismissWithClickedButtonIndex:0 animated:NO];
if(response == nil){
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Timeout", @"") message:NSLocalizedString(@"Connection timeout", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"Close", @"") otherButtonTitles:nil ];
    [alert show];
}
}

关于我如何着手解决这个问题的任何提示? 谢谢

【问题讨论】:

    标签: ios multithreading uialertview segmentation-fault objc-message-send


    【解决方案1】:

    崩溃可能是由于从其他线程中解散并显示UIAlertView

    永远不要在其他线程中执行UI 任务。 UI 任务应该在主线程中完成。

    更改function 喜欢:

    -(void)function
    {
     // Do some web request
    
     dispatch_async(dispatch_get_main_queue(), ^{
        [alertView dismissWithClickedButtonIndex:0 animated:NO];
        if(response == nil)
        {
           UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Timeout", @"") message:NSLocalizedString(@"Connection timeout", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"Close", @"") otherButtonTitles:nil ];
        [alert show];
        }
      });
    }
    

    【讨论】:

    • dispatch_async(dispatch_get_main_queue(), ^{[alertViewdismissWithClickedButtonIndex:0 animated:NO];});然后使用另一个 dispatch_async 显示第二个警报?
    • @user1187692:P 不需要这样做 :) 你已经在主线程中使用了dispatch_get_main_queue,那么就不需要再次使用 GCD 和dispatch_get_main_queue。您可以将这些行写在一个 dispatch_get_main_queue GCD 中。
    猜你喜欢
    • 2011-05-29
    • 1970-01-01
    • 2010-11-22
    • 2016-06-20
    • 2019-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多