I'm trying a basic experiment where I add a grid of squares to a macOS ScreenSaver view (created through the Xcode template). I am running on a reasonably well performing MacBook Pro, but for some reason, adding my grid (composed of ~900 NSView
objects) completely locks up my system — the screen saver hangs.
This isn't an unreasonable amount of views, surely? What's interesting is, I've tried the exact same layout in a macOS app (drawing in its NSWindow
), and the performance is totally fine.
What is the difference?
What was causing the performance problem was that all the views were layer-backed. Once I stopped requesting the view to have a layer, performance improved dramatically.
I also went so far to use CAShapeLayer
instead for improved animation performance.