mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-24 16:11:43 +00:00
renderer/metal: clear callback before layer release (#13641)
Fixes https://github.com/ghostty-org/ghostty/discussions/13242 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 doesn't happen the way Ghostty GUI uses our renderer, but it is possible for folks using ghostty-internal and its straightforward and easy for us to fix it.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user