szn

Bug 431 — Render output bypasses appendClientOut, defeating display flow control

431. Render output bypasses appendClientOut, defeating display flow control

Severity: MEDIUM-HIGH Status: Fixed

The per-frame render path appends the serialized frame directly to the display client’s output buffer, never calling appendClientOut() (which implements the high-watermark backpressure and diagnostic counters):

// src/server/server.zig:3141-3154
const pkt = protocol.Packet.make(.output, self.render_buf.items);
var hdr: [5]u8 = undefined;
pkt.header.encode(&hdr);
const prev_len = dc.out_buf.items.len;
var append_ok = true;
dc.out_buf.appendSlice(self.allocator, hdr[0..]) catch { append_ok = false; };
if (append_ok) {
    dc.out_buf.appendSlice(self.allocator, self.render_buf.items) catch {
        dc.out_buf.shrinkRetainingCapacity(prev_len);
        append_ok = false;
    };
}
// src/server/server.zig:2735 — the path that IS bypassed
fn appendClientOut(self: *Server, dc: *DisplayClient, data: []const u8) bool {
    // ... RENDER_HIGH_WATERMARK check + diagnostic counters ...
}

Problem & Impact

Proposed Fix

Route render frames through appendClientOut() (or replicate its watermark check) so render output participates in the same backpressure as other display traffic. On watermark exceed, skip the frame (or mark all_flushed = false) instead of unconditionally appending.