wess / Glimpse

UIView recording library.
MIT License
557 stars 42 forks source link

Terminated due to memory issue #18

Open lawgimenez opened 5 years ago

lawgimenez commented 5 years ago

Whenever I call stop() method, the app crashes with the debugger message: Terminated due to memory issue

shutup commented 5 years ago

try the change code

- (UIImage *)imageFromView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.frame.size , YES , 0 );

//    if ([view respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
//        [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
//    } else {
        [view.layer renderInContext:UIGraphicsGetCurrentContext()];
//    }

    UIImage *rasterizedView = UIGraphicsGetImageFromCurrentImageContext();
    //compress image
    NSData* data = UIImageJPEGRepresentation(rasterizedView, 0.5);
    rasterizedView = [UIImage imageWithData:data];
    UIGraphicsEndImageContext();

    return rasterizedView;
}