Fix crash in CAOpenGLLayer shadow-copy init on macOS 27 beta

macOS 27 beta routes contentsScale changes (window moving between
screens) through Core Animation's implicit-animation path, which builds
a presentation copy of the layer via init(layer:). Our override re-ran
visual setters on that copy, and -[CAOpenGLLayer setColorspace:]
dereferences render state the shadow copy doesn't own, crashing with
EXC_BAD_ACCESS.

Drop the redundant setter block (super.init(layer:) already copies
presentation values) and disable implicit actions around the
contentsScale writes in MPVOGLView so the presentation-copy path is
never entered for scale updates.
This commit is contained in:
Arkadiusz Fal
2026-07-23 23:08:34 +02:00
parent 2ff248e262
commit ce7e9cbde7
2 changed files with 17 additions and 9 deletions

View File

@@ -236,15 +236,12 @@ final class MPVOpenGLLayer: CAOpenGLLayer {
self.bufferDepth = previousLayer.bufferDepth
self.isSetup = previousLayer.isSetup
// super.init(layer:) already copies presentation values; re-invoking
// setters like `colorspace` on the shadow copy dereferences render
// state the copy doesn't own and crashes (macOS 27 beta routes
// contentsScale changes through this path on screen changes).
super.init(layer: layer)
autoresizingMask = previousLayer.autoresizingMask
backgroundColor = previousLayer.backgroundColor
isOpaque = previousLayer.isOpaque
colorspace = previousLayer.colorspace
contentsFormat = previousLayer.contentsFormat
isAsynchronous = previousLayer.isAsynchronous
Task { @MainActor in
LoggingService.shared.debug("MPVOpenGLLayer: created shadow copy", category: .mpv)
}