Ios drawViewHierarchyInRect crash EXC_BREAKPOINT UNKNOWN

I have a random crash in my iOS app that happens from time to time. It was not possible to play it at all, but I have thousands of user crash reports.

It crashes with "EXC_BREAKPOINT UNKNOWN" during a call to [UIView drawViewHierarchyInRect:].

This only happens on iOS7 devices, as the method is not available (and therefore not called) until iOS7.

Does anyone have any ideas on how to approach this? Any help would be greatly appreciated.

- (UIImage *)imageRepresentation
{
    if (![self respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
        // Disable imageRepresentation on < iOS 7
        return nil;
    }

    UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, [UIScreen mainScreen].scale);

    [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}

Crashed: com.apple.main-thread
EXC_BREAKPOINT UNKNOWN at 0x0000defe
 raw
0
CoreFoundation  
CFRelease + 1131
1
UIKit   
-[UIView(Rendering) _imageFromRect:] + 136
2
UIKit   
-[UIView(Rendering) _imageFromRect:] + 136
3
UIKit   
-[UIView _drawViewHierarchyInRect:] + 174
4
UIKit   
-[UIView drawViewHierarchyInRect:afterScreenUpdates:] + 378
5
MyApp   
UIView+SSToolkitAdditions.m line 23
-[UIView(SSToolkitAdditions) imageRepresentation]
+4
source share
2 answers

I crashed using the same API when the target view was not yet visible (it did not have a valid view and window).

, drawViewHierarchyInRect, self.superview self.window .

+4

UIView (, 0,1), drawViewHierarchyInRect: afterScreenUpdates: . , .

0

Source: https://habr.com/ru/post/1526496/


All Articles