Inconsistent z-position for layer hosting and layer backed sibling NSViews

Originator:i
Number:rdar://13542277 Date Originated:30-Mar-2013 02:15 PM
Status:Open Resolved:
Product:OS X Product Version:10.8.3
Classification:Serious Bug Reproducible:Sometimes
 
30-Mar-2013 02:15 PM Indragie Karunaratne:
Summary:

When using sibling overlapping NSViews where one of the sibling views is a layer hosting view and the other sibling is a layer backed view, the z-position of the views' layers at runtime (and hence the views themselves) is inconsistent.

Steps to Reproduce:

1. Create a layer hosting view and a layer backed view
2. In the XIB, put the layer hosting view in the background and place the layer backed view on top of it
3. Run the app

Expected Results:

The z-order of the two views is maintained consistently.

Actual Results:

About 1 in every 10-20 launches, the z-position will be wrong -- the layer hosting view will appear over the layer backed view. 

Regression:

Notes:

Sample code is attached. Run the application 10-20 times to see where the problem kicks in (it happens, I promise!). Also attached are screenshots on what it SHOULD look like (correct.png, where the blue rectangle is visible over the red background) and what happens when the z-position gets messed up (incorrect.png, where only the red background is visible). 

I found the following workaround: [self.window.contentView setSubviews:[[self.window.contentView subviews] copy]];. Triggering the setter for subviews seems to reset the proper z-positions. 

Example project + screenshots can be found here: https://github.com/indragiek/radars/tree/master/13542277/LayerHostingBug

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!