ollix/MetalNanoVG

Flicker on drawableSizeWillChange

jzrake opened this issue · 1 comments

I am getting intermittent "chop" in draws that occur immediately after window resizing. By that, I mean that the rendering flickers, with every other frame drawn at an offset, and somewhat random location. My guess is that this occurs when the drawable size changes between nvgBeginFrame and nvgEndFrame. It is fixed by setting MTKView.autoResizeDrawable = false, but then of course the rendering just scales with the window size.

How can you force the drawable size to change only at appropriate times? Any ideas?

This is not a problem with MetalNanoVG. It occurs on any metal rendering when the drawable size is changing frequently:

https://stackoverflow.com/questions/45375548/resizing-mtkview-scales-old-content-before-redraw

It's not even a bug really but a logical issue related to asynchronous drawing: what do you do when resize events don't coincide with rendering completion? CALayer stretches the previously rendered texture to the new component size by default. You just need to ensure that the layer is only ever drawn into the same number of pixels for which it was rendered.