View snapshotting on iPhone 6 and iPhone 6+ produces screen flicker
| Originator: | Vytis | ||
| Number: | rdar://18664040 | Date Originated: | 15-Oct-2014 05:26 PM |
| Status: | Duplicate of 18283329 (Open) | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 8.0.2 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
The preferred way of taking snapshot image of a view is to use UIView’s “drawViewHierarchyInRect:afterScreenUpdates:” method. This is explained in Technical Q&A QA1817 (https://developer.apple.com/library/ios/qa/qa1817/_index.html).
When making a snapshot with this method on an app that is not optimised for iPhone 6 or iPhone 6+ there is a visible flicker of the current view after calling snapshotting code.
Steps to Reproduce:
1. Create a new single view application project
2. Disable iPhone6 and iPhone 6+ support by going to main target settings and removing launch screen file setting (deleting the LaunchScreen.xib)
3. Add the following code to ViewController.m:
- (UIImage *)snapshot:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
- (IBAction)takeScreenshot:(id)sender
{
UIImage *snapshot = [self snapshot:self.view];
}
3. In the storyboard add some views (to make the effect more visible) and a single button.
4. Attach button to takeScreenshot: action in ViewController.m
5. Launch app on iPhone 6 or iPhone 6+ (or corresponding simulators).
6. Tap button to take the snapshot
Expected Results:
Nothing visible should happen because snapshot image is produced and immediately discarded
Actual Results:
Screen flickers after tapping the button.
Notes:
It seems that a similar issue was reported happening on iPad (rdar://17292507) however it is marked as fixed.
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!