renderer/metal: clear callback before layer release

Clear the IOSurfaceLayer display callback when releasing the wrapper.
The host view can retain the backing layer beyond renderer teardown.
This prevents a later Core Animation display pass from invoking the
callback with a freed renderer context.
This commit is contained in:
Mitchell Hashimoto
2026-08-05 13:51:40 -07:00
parent 168c7b9467
commit 4b4a5b2411

View File

@@ -40,6 +40,10 @@ pub fn init() !IOSurfaceLayer {
}
pub fn release(self: *IOSurfaceLayer) void {
// The layer may be retained by the view after we release our reference.
// Clear the callback first so that a later display pass can't access the
// renderer that owned this wrapper after it has been freed.
self.setDisplayCallback(null, null);
self.layer.release();
}