I have an interesting case for you. And need help.
My Mac app has a layer-hosted NSView with lots of layers and sublayers and sub-sub layers inside. Imagine a Finder window with items (icons, text labels)... something like that. Each item has a button, selection background layer.
And everything is fine until you have 1000 of those items.
Now with lots of those items, my app becomes unresponsive when I try to interact with this view. And the tricky part is that it is not my app that consumes the CPU, but WindowServer. It gets to 100% and the system freezes for some time.
Important Note:
My view is a part of the app interface. There is a main window with other views. They have their own structure as well.
And I've noticed that if I put this layer-hosted view into a separate window, it works just fine with no freezes having the same 1000 items. But starts to halt the system if I put it back to the main window.
The Question
- What is it in my app (views/layers) that makes WindowServer go mad?
- Why does placing this view to a separate window helps?
I've run some tests and removed all the sublayers for every item, leaving just one-two for each. It has reduced the load on the system, but still bad. I've disabled all the drawings - just small images for the icons. Didn't help as well.
