Quick answer: macOS game rendering to a different monitor than the one the window appears on after Mission Control swap? Listen for NSWindow screen-change notifications and rebind the Metal layer’s display.
After dragging a fullscreen game between displays via Mission Control, the window stays on display 2 but pixels go to display 1. The CAMetalLayer’s display ID is stale.
NSWindow Screen-Change
NSNotificationCenter.default.addObserver(forName: NSWindow.didChangeScreenNotification,
object: window, queue: nil) { _ in
rebindMetalLayer(window.screen)
}Re-set the contentScale and maximumDrawableCount to match the new screen.
Display ID for VRR
If you’re using ProMotion / VRR, the display’s refresh capabilities change with the screen. Refresh CADisplayLink bindings on screen change.
DPI Scale
Retina vs non-Retina screens have different backing scale factors. Resize the drawable to frame.size * screen.backingScaleFactor.
Verifying
Dragging the window between displays via Mission Control keeps rendering on the correct display, with correct DPI.
“Mission Control moves don’t rebind the Metal layer. Hook the screen-change notification.”
Test on a two-display laptop dock — the failure mode is invisible on single-display dev machines.