fix: prevent flicker while shrinking screen by eliminating thread race

Before this fix, if vsync was on the GPU cells buffer could be cleared
for a frame while resizing the terminal down. This was due to the fact
that the surface sent messages for the resize to both the renderer and
the IO thread. If the renderer thread was processed first then the GPU
cells buffer(s) would be cleared and not rebuilt, because the terminal
state would be larger than the GPU cell buffers causing updateFrame to
bail out early, leaving empty cell buffers.

This fixes the problem by changing the origin of the renderer's resize
message to be the IO thread, only after properly updating the terminal
state, to avoid clearing the GPU cells buffers at a time they can't be
successfully rebuilt.
This commit is contained in:
Qwerasd
2024-08-14 19:35:52 -04:00
parent 93c377c6a1
commit 7929e0bc09
4 changed files with 16 additions and 17 deletions

View File

@@ -480,7 +480,7 @@ fn drawCallback(
r: xev.Timer.RunError!void,
) xev.CallbackAction {
_ = r catch unreachable;
const t = self_ orelse {
const t: *Thread = self_ orelse {
// This shouldn't happen so we log it.
log.warn("render callback fired without data set", .{});
return .disarm;
@@ -504,7 +504,7 @@ fn renderCallback(
r: xev.Timer.RunError!void,
) xev.CallbackAction {
_ = r catch unreachable;
const t = self_ orelse {
const t: *Thread = self_ orelse {
// This shouldn't happen so we log it.
log.warn("render callback fired without data set", .{});
return .disarm;
@@ -543,7 +543,7 @@ fn cursorTimerCallback(
},
};
const t = self_ orelse {
const t: *Thread = self_ orelse {
// This shouldn't happen so we log it.
log.warn("render callback fired without data set", .{});
return .disarm;