iOS 6 3D-rotation causes layers to render without respect for view hierarchy

Originator:michelle
Number:rdar://12364220 Date Originated:24-Sep-2012 09:43 PM
Status:open Resolved:
Product:iPhone SDK Product Version:iOS 6 Simulator and Device
Classification:UI/Usability Reproducible:100%
 
Summary:
After applying a CATransform3D to a layer to rotate its view, other views render in incorrect hierarchical order: a subview A that is hierarchically below a subview B renders on top of A. Bug occurs when run on iOS 6 only.

Steps to Reproduce:
Please see the example project, which was built specifically to isolate this bug. Run it and follow the instructions. You will immediately see the bug.

The sample project causes the bug to occur by the following coding steps:
1. Create a partially transparent view and add it to the main view (ex self.bunny)
2. Create a "hidden" view, which will only be shown after the animation is complete. This view will be "revealed" by the rotation animation. Make the view hidden. Add it to the main view. (ex self.hiddenView)
3. Create the view that will rotate. Add it to the main view (ex self.rotationView)
4. Create a CATransform3D with perspective, which rotates on the y-axix.
5. Perform the animation: unhide the hidden view from 2, and animate the view from 3 using the CATransform3D from 4.
6. Run the code on an iOS 6 device or simulator (I'm using iOS Simulator 6.0 (358.4)).

Expected Results:
The hidden view from 2 should be fully visible, with nothing else rendered on top of it.

This is because the rotation view rotated away from the hidden view, and the hidden view is hierarchically on top of the transparent view from 1, 

Actual Results:
The hidden view from 2 is partially visible, but it's obscured by the partially transparent view from 1.

Regression:
This works fine when run on iOS 5 devices or simulator: this behaviour was introduced in iOS 6.

Notes:
1. There is a work-around: if you set zPositions on the incorrectly rendered layers, in increasing order of height in the view hierarchy, rendering is correct.

2. If you were to add a control to the hidden view (such as a button), you would see that touch events are correctly handled: the hidden view receives touch events, even though the transparent view is rendered on top.

3. Attached is a simple sample project showing the bug, and showing the work-around. Try running it on iOS 5 to see correct behaviour. Also attached is screenshots showing the view before and after animating.

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!