[NSView drawRect:] is called only once, however two different renderings are generated

I have a custom NSView embedded in a NSScrollView.

[NSView drawRect:] is called once, when the window is created and displayed, and the rendering is exactly how it should be.

Then I resize (shrink) the window, which does not make [NSView drawRect:] being called again, as no new part of my view needs to be drawn; however, the window's content is flushed again on screen, and the rendering is now different.

How could this be possible? I am logging a message in my [NSView drawRect:] implementation, so I am absolutely certain that it is called only once in this scenario. Is it possible that a single drawing instruction ([NSBezierPath stroke], in this case) called only once actually produces two different rendered images, in two different drawing buffers, and that the buffer flushed to the screen can change depending on the size of the window??

Now, what is different in the rendering? Two things: antialiasing is performed differently (the line width is 0.25 pixel), correctly in the first case, and not very smoothly in the second case. I also changed [NSBezierPath setFlatness:], and this flatness is taken in account in the first case, and unchanged (default flatness) in the second case.

When I continue to resize the window, enlarging then shrinking it, drawRect: is called when I enlarge it, and depending on the window size, sometimes I get the "correct" rendering, and sometimes the "wrong" one (for the whole view; it is not limited to the newly revealed area).

I have a built-in display set to "more space", and an external non-retina monitor; with "desktop & dock" settings set to "displays have different Spaces", in case this has any impact on the situation.

Hi tartiflette74,

That sounds like some very unusual drawing behavior! Off the top of my head, one possible way to get this behavior is via the view's layerContentsRedrawPolicy property. That property can be configured to prevent a view from redrawing when its frame size changes, but only if it's been customized away from its default value (NSViewLayerContentsRedrawDuringViewResize).

Otherwise, it would be most helpful to write up a report in Feedback Assistant with a small reproducing sample so that we can take a look. It's also helpful to know which version of macOS you're observing this behavior on. If you reply with a FB number from Feedback Assistant, I can help guide your report to the right place.

Hi .jsn; FB13600818 Thanks!

As usual, there is absolutely no activity on this Feedback Assistant report. I spent sevral hours to produce a precise description of the problem, with a video and sample code. I won't do this again if nobody replys that this was actually usefu to you, as it is not useful to me.

[NSView drawRect:] is called only once, however two different renderings are generated
 
 
Q