【问题标题】:xcode report "libsystem_kernel.dylib __abort_with_payload" SIGABRT when call drawrect调用drawrect时xcode报告“libsystem_kernel.dylib __abort_with_payload”SIGABRT
【发布时间】:2019-07-23 09:36:59
【问题描述】:

iOS 应用在调用 drawRect 时触发了 SIGABRT 事件,


libsystem_kernel.dylib`__abort_with_payload:
    0x197660dc8 <+0>:  mov    x16, #0x209
    0x197660dcc <+4>:  svc    #0x80
->  0x197660dd0 <+8>:  b.lo   0x197660de8               ; <+32>
    0x197660dd4 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x197660dd8 <+16>: mov    x29, sp
    0x197660ddc <+20>: bl     0x197657a3c               ; cerror_nocancel
    0x197660de0 <+24>: mov    sp, x29
    0x197660de4 <+28>: ldp    x29, x30, [sp], #0x10
    0x197660de8 <+32>: ret    

在执行 [self drawInRect:CGRectMake(0, 0, w, h)] 时被触发;在下面的代码中,

    NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
    paragraph.alignment = NSTextAlignmentRight;

    NSInteger length;
    if ((date.length + desc.length + name.length) - address.length > 0) {
        length = (date.length + desc.length + name.length);
    } else {
        length = address.length;
    }
    NSDictionary * textAttributes = @{NSForegroundColorAttributeName:WT_WhiteColor,
                                      NSFontAttributeName:[UIFont boldSystemFontOfSize:self.size.width / length],
                                      NSParagraphStyleAttributeName:paragraph,
                                      NSShadowAttributeName:shadow,
                                      NSVerticalGlyphFormAttributeName:@0};

    CGSize textSize = [water_mark sizeWithAttributes:textAttributes];
    CGRect textFrame = CGRectMake(self.size.width - textSize.width - 40, self.size.height - textSize.height - 60, textSize.width, textSize.height);




    UIGraphicsBeginImageContext(self.size);
    int w = self.size.width;
    int h = self.size.height;
    NSLog(@"size of rect w: %i, h: %i", w,h);
    [self drawInRect:CGRectMake(0, 0, w, h)];
    [water_mark drawInRect:textFrame withAttributes:textAttributes];
    UIImage * waterMarkedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return waterMarkedImage;

=======

w的值为3024,h的值为4032,xcode为10.2.1,测试iphone设备为iphone 7 plus,ios版本为12.3.1。

【问题讨论】:

  • 应用程序在这部分运行流畅,直到最近客户在拍摄的照片上应用水印时向我报告崩溃问题。我每次都可以在我的 xcode 上重现它。我怀疑它可能与 lib 版本有关。但没有解决它的线索。
  • 但是如果我们在从相册中选择的照片上应用水印,代码运行顺利,不会中止。

标签: ios objective-c xcode drawrect


【解决方案1】:

将 NSPhotoLibraryAddUsageDescription 添加到 pinfo.list 后,崩溃问题消失了。

【讨论】:

    猜你喜欢
    • 2020-06-05
    • 1970-01-01
    • 2011-12-04
    • 2015-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-08
    相关资源
    最近更新 更多