CALayer bounds updated ahead of NSWindow frame when rendered to from separate thread

Number:rdar://41517629 Date Originated:June 27 2018
Status:Open Resolved:
Product:macOS + SDK Product Version:10.13
Classification:Bug Reproducible:Always
Core Graphics


When enabling layer-backed mode for a NSOpenGLView, and rendering to it from a separate thread, eg. a display-link callback, you may end up in a situation where during window resize the CALayer bounds seem to be updated ahead of the NSWindow frame:

Steps to Reproduce:

1. Download
2. Add to awakeFromNib:

    self.wantsLayer = YES;
    self.layer.borderColor = [NSColor cyanColor].CGColor;
    self.layer.borderWidth = 1;

Expected Results:

Resizing the window behaves the same as with non-layer-backed mode; the layer follows the window frame.

Actual Results:

The layer bounds are updated ahead of the window frame.


macOS 10.13.4


Using NSScreenDisableUpdates as a workaround is possible, but windowWillResize: is not a good enough signal

Minimal testcase

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!