mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
renderer/opengl: acquire lock to prep kitty images
Fixes #1101 GTK forces all GLArea drawing to happen on the GUI thread. In this scenario, `updateFrame` and `drawFrame` could be happening in parallel. This commit grabs the lock while updating the Kitty image protocol state since that is used by both functions. We already have a mutex called "draw_mutex" that we hold while we're modifying data that could be shared by this separate draw thread. We should reuse that here.
This commit is contained in:
@ -709,6 +709,11 @@ pub fn updateFrame(
|
|||||||
// We only do this if the Kitty image state is dirty meaning only if
|
// We only do this if the Kitty image state is dirty meaning only if
|
||||||
// it changes.
|
// it changes.
|
||||||
if (state.terminal.screen.kitty_images.dirty) {
|
if (state.terminal.screen.kitty_images.dirty) {
|
||||||
|
// prepKittyGraphics touches self.images which is also used
|
||||||
|
// in drawFrame so if we're drawing on a separate thread we need
|
||||||
|
// to lock this.
|
||||||
|
if (single_threaded_draw) self.draw_mutex.lock();
|
||||||
|
defer if (single_threaded_draw) self.draw_mutex.unlock();
|
||||||
try self.prepKittyGraphics(state.terminal);
|
try self.prepKittyGraphics(state.terminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user