I'm working on a Cocoa project using Core Animation and I've got a custom view that is displayed in two windows. It always shows up in one window, but sometimes does not show up in the other window when I start up the application. So far as I can tell, it is completely random. Here is the code I call when the view is initialized. It gets to this code whether or not the view appears.
[self setWantsLayer:YES];
root = [self layer]; // root is a CALayer
root.layoutManager = [CAConstraintLayoutManager layoutManager];
root.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
[root setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)];
[self setNeedsDisplay:YES];
Why would the view show up sometimes and other times it does not?
EDIT: Would it make a difference if I create the root CALayer on it's own instead of setting it to the view's "layer" like I'm currently doing?