Is "responsive scrolling" still a thing in modern macOS?

I started wondering after I saw jerky scrolling in my app when it draws a lot of curves (NSBezierPath), under Sonoma.

So I made a simple Cocoa app, using the Xcode 15 objC template. The app only has a NSView subclass as a document view of an NSScrollView (not a subclass), which has copiesOnScroll set to YES.

The document view returns YES to isOpaque and its class returns YES to isCompatibleWithResponsiveScrolling.

Yet whenever I scroll, -drawRect is called on the document view and the dirtyRect passed is the same as its visibleRect. i.e., the view is asked to redraw its whole visible content at every scroll step. Clearly, responsive scrolling isn't working.

I tried setting wantsLayer to YES or NO, it doesn't change anything.

prepareContentInRect is called, but it doesn't seem that the rect argument covers a region of the view that is not visible.

Am I doing something wrong or is responsive scrolling a thing of the past?

Post not yet marked as solved Up vote post of jeanlain Down vote post of jeanlain
593 views

Replies

Of note:

preparedContentRect is called, but a call to super within the method returns NSZeroRect, which contradicts the documentation where it is said that the rectangle always includes the visible portion of the view.

Returning the view's bounds from this method doesn't change anything. No overdraw appears to be performed, the visible rectangle is redrawn at each scroll step.

Setting the layerContentsRedrawPolicy to NSViewLayerContentsRedrawNever does nothing to the scrolling behaviour. Again, the visible rectangle is redrawn at each scroll steps. I wonder how appkit does it btw, because with this setting, setNeedsDisplay does not redraw the view (which is expected).

To sum up: whatever I do, appkit wants to redraw the visible rectangle during scrolling. This is a regression from macOS 10.0, which at least had copiesOnScroll to avoid doing unnecessary calculations to redraw only the part of the view that becomes visible.

We noticed the same thing a couple weeks ago and filed a bug on 10/9/2023 about responsive scrolling appearing to not be working under macOS Sonoma. Haven't heard anything back yet.

Strangely, general scrolling performance has not decreased, at least not on my MacBook Pro.