Calling drawViewHierarchyInRect: breaks four-finger system gestures on iOS 10

Originator:mreagan
Number:rdar://28344025 Date Originated:9/16/2016
Status:Open Resolved:
Product:iOS / iOS SDK Product Version:10.0.1 (14A403)
Classification:UI/Usability Reproducible:Always
 
*** Description ***

When any app calls into drawViewHierarchyInRect:afterScreenUpdates: and `afterScreenUpdates` is YES, the app afterwards exhibits visual bugs with the iOS multi-finger system gestures (five finger pinch to background app, or four finger swipe to move between apps, etc). Specifically, a black frame can be seen when swiping between apps or pinching away to the home screen.

If afterScreenUpdates is NO or renderInContext: etc. is used, the issue does not occur.

This is reproducible in a template iOS project using Apple's own example code for drawViewHierarchyInRect:afterScreenUpdates.

*** Repro Steps ***

1. Create a new iOS app from a default template, with a single view and label in the view (label is optional)
2. In the main view controller's `viewDidLoad` method, call the following snippet below which calls into drawViewHierarchyInRect:afterScreenUpdates:
3. Perform a four finger swipe (slowly) on the app to move to another app

Snippet:

    dispatch_async(dispatch_get_main_queue(), ^{
        CGRect rect = self.view.bounds;
        UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
        [self.view drawViewHierarchyInRect:rect afterScreenUpdates:YES];
        UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        
        //Don't need to actually do anything with our image to reproduce the bug,
        //so we'll just log it to the console. After this code has run, four finger
        //gestures (to swipe between apps, or background the current app) will show
        //a black frame on iOS 10
        NSLog(@"%@", snapshotImage);
    });

*** Comments ***
Contact info:
Twitter: @hmblebee    |    http://sound-of-silence.com/

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!