diff options
| -rw-r--r-- | core/replica.zig | 40 | ||||
| -rw-r--r-- | dev/gui/gui.zig | 4 |
2 files changed, 36 insertions, 8 deletions
diff --git a/core/replica.zig b/core/replica.zig index 3e6be763..cbb64363 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -1022,10 +1022,6 @@ pub const Replica = struct { r.toConfirmed(); if (r.diverged != null) return; } - // What it shows moved only when what a digest covers did: a unit of - // the session's pump that read its clock and moved nothing draws - // no frame. - if (ends == null or !std.mem.eql(u8, ends.?, r.last_digest.items)) r.moved = true; // What the unit opens or closes outside the copy (`keepSince` below). var serials: [pardes.MAX_PANES]u32 = undefined; var retiring = false; @@ -1045,6 +1041,13 @@ pub const Replica = struct { trace(r.gpa, "replica {d}: the unit of {d}/{d} diverged: {s}\n", .{ r.id, u.origin, u.seq, why }, &.{u.tape}); return r.fail(why); } + // What it shows moved only when the unit's steps asked for a frame, + // as the session's own frontend draws (Pardes.pump): a pump that + // read its clock and stepped none, a 9P request that changed no + // pane (the close after a ctl write: its frame was drawn again), + // draw nothing. Read after the replay: before it, it is what the + // units before asked (and a first unit has no core yet). + if (r.core().needs_frame) r.moved = true; if (check) { r.since_check = 0; r.stats.checks += 1; @@ -1299,9 +1302,12 @@ pub const Replica = struct { pub fn draw(r: *Replica, present: pardes.views.Present) bool { rollback.Epoch.select(&r.epoch); defer rollback.Epoch.select(null); - // A frame drawing owes another is this process's, not the core's. + // A client's replica (`skips_render`) is never watched in its + // replay, which so never clears `needs_frame`: the frame its steps + // asked for is this one. One in process replays its session's own + // drawing (Pardes.pump), which reads and clears it as the session's. const c = r.core(); - const needs = c.needs_frame; + const needs = c.needs_frame and !r.t.skips_render; defer c.needs_frame = needs; return pardes.views.drawOne(c, r.view, present) catch true; } @@ -4140,6 +4146,28 @@ test "the copy taken for an input of its own stays once the input is confirmed: try std.testing.expectEqual(@as(u32, 1), r.stats.foreign); } +test "a client marks its view moved for a unit of the session's whose steps asked for a frame, and not for one whose steps asked none" { + // The own frontend's rule (Pardes.pump): a unit that only read the + // clock, or a ctl write's close, draws nothing; a client presented it + // again (the corpus's pet: one picture twice). + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); + defer a.deinit(); + // A client as a dial joins it: it draws none of its replay. + const r = try joinedNow(a, 1, 0); + defer r.deinit(); + _ = r.draw(.{ .ctx = null, .f = null }); + r.moved = false; + r.confirm(try a.local(.{ .key = .{ .cp = 'l', .text = "l" } })); + try std.testing.expect(r.moved); + _ = r.draw(.{ .ctx = null, .f = null }); + r.moved = false; + a.pump(); + r.confirm((try a.pending()).?); + try std.testing.expect(!r.moved); + try agrees(a, r); +} + test "the session's pump units that moved nothing, kept under a key applied on top, reach the kept list's bound: it is let go at the confirm that leaves nothing applied, never replayed whole" { // The live pair's order (core/replica.zig Peers.boundary): before it // steps a client's key the session sends its pump's unit, which moved diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 7aba4c34..4e074a6a 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -1252,8 +1252,8 @@ const Client = struct { // Idle, as the session's own window says it (writeTestStatus), once // it has what the session was told: its digest asked when quiet // and answered since the last unit (Link.quietCheck). - // A replica's `needs_frame` is the session's steps' (Replica.draw - // leaves it as it was): its own owed frame is the link's. + // A replica's `needs_frame` is the session's steps' since it last + // drew (Replica.draw): its own owed frame is the link's. if (cl.test_mode) writeTestStatus(g, cl.in.core, cl.shell.presented and l.link.r.quiet() and !l.link.changed and !l.link.asked, l.link.dirty or l.link.owed); if (latency_fd >= 0) return client_loop.forever; var ms: u32 = if (cl.test_mode) 16 else client_loop.forever; |
