Multiple displays result in frame stutters on macOS

tl;dr


When using either CAMetalLayer.nextDrawable or MTKViewDelegate's drawInMTKView: APIs, a consistent 60fps does not seem possible when multiple displays are attached to macOS.


Background


I added Metal support to RetroArch, a popular open source game front end, and have been troubleshooting an issue where the frame rate will periodically drop below 60fps, causing frame and audio stuttering. To eliminate any issues with RetroArch itself, I ended up creating my own minimal libretro front end and using MTKView's drawInMTKView, which is synchronized with a CVDisplayLink timer. This too had frame stuttering issues when multiple displays are connected. When I limited macOS to a single display, there is no stuttering.


I don't yet know if this is a macOS issue or whether I would need to manage my own CVDisplayLink timer and constantly update which CGDisplay it is associated with. Debugging the minimal front end, I added a symbolic breakpoint to determine how the CVDisplayLink was created for triggering the drawInMTKView. I hit a call to CVDisplayLinkCreateWithActiveCGDisplays during initialization of the MTKView. During initialization, a single call was made to CVDisplayLinkSetCurrentCGDisplay, however, moving the window between displays did not result in further calls to this API.


My hypothesis is the CVDisplayLink, CAMetalLayer and CGDisplay presenting the view are not congruent, however, it is unclear if it is even possible to manage all this within user code.

Replies

That's a relief! I'm not able to use the Catalina beta yet, could you let us know if the issue does reappear or if it stays resolved?

any updates to this?


im having major issues with Resolume software dropping frames when plugged into a decimator (hdmi to sdi convertor) via a t3 > hdmi convertor. also problems going hdmi to dvi into a video mixer.


thanks

b

Hi. The issue seems fixed in latest macOS Mojave beta (10.14.6) as well as in macOS Catalina beta (10.15).

So upgrade your Mojave to beta (safer than upgrading to Catalina beta).

Hi, i confirm that the massive lag is finally gone on the latest Mojave beta (18G59b) but when using the mission control the FPS counter still drops down to 30 fps, and it's noticeable.