NSView wantLayer performance

If I create a blank Mac Xcode project and lay out 500 simple objects NSView

side by side in the main window, it loads pretty quickly. If I set wantsLayer=YES

in every peep, the performance drops dramatically for a few seconds. Why is this so conceptual? It seems that the layers will be faster no slower than normal old NSViews.

+3


source to share


1 answer


You give the system more work to do by maintaining the layer so many views. Layer-backing allows graphics acceleration (for drawing), but it adds a bit of overhead to things like layout, not to mention they just create them and put them on the screen. If used correctly, this is not a big problem.

Typically, if you had so many "things" to manage onscreen at once, you would have a hosting sibling managing its own sublayer tree. "But what about view-based table views?" you ask. Deception, deception, I say! The views in a table do not actually support all kinds of cells they manipulate; they effectively reuse them, keeping them just enough to represent what's on the screen and / or the animation around.



So, I would say this is not a problem, as it is not a very good approach to start with 500-layer views up for layout and painting to start. :-)

+3


source







All Articles