I have a large custom NSView subclass that's set as an NSScrollView's documentView. This view achieves zooming in the standard AppKit way, by having a bounds size that's some factor of the frame size, eg: frame.size.width = bounds.size.width * 2.0. This has worked just fine for years.
The problem is that on modern versions of macOS (eg: Catalina), for certain zoom factors, there are "seams" that show up during drawing. The seams are fine lines that show a view's background color (or stale content from a prior drawing pass). The seams are always aligned in neat rectangular patterns, which tipped me off that macOS is doing some kind of tiling.
After poking around I see that my view is assigned a CALayer, despite never opting-in via setWantsLayer or anything like that. This implicit layer backing seems to be expected on current versions of macOS, but it's definitely the cause of my problem. I can see that my view is assigned a layer like:
_NSViewBackingLayer → sublayers: _NSTiledLayer
If I increase the tileSize property of this automatically generated layer (eg: from 512x512 to 2048x2048), I can decrease the visual frequency of the problem. But this is naturally a hack, and not a complete solution. The seams still occur, just less often.
Can I somehow opt my view out of implicit layer backing? Is there a more modern way to implement zoom now that everything is using layers?
The problem is that on modern versions of macOS (eg: Catalina), for certain zoom factors, there are "seams" that show up during drawing. The seams are fine lines that show a view's background color (or stale content from a prior drawing pass). The seams are always aligned in neat rectangular patterns, which tipped me off that macOS is doing some kind of tiling.
After poking around I see that my view is assigned a CALayer, despite never opting-in via setWantsLayer or anything like that. This implicit layer backing seems to be expected on current versions of macOS, but it's definitely the cause of my problem. I can see that my view is assigned a layer like:
_NSViewBackingLayer → sublayers: _NSTiledLayer
If I increase the tileSize property of this automatically generated layer (eg: from 512x512 to 2048x2048), I can decrease the visual frequency of the problem. But this is naturally a hack, and not a complete solution. The seams still occur, just less often.
Can I somehow opt my view out of implicit layer backing? Is there a more modern way to implement zoom now that everything is using layers?