diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 10:35:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 10:35:42 -0300 |
| commit | f11b123a8f4c38b6582c03d2acf84143ed1e7fd3 (patch) | |
| tree | 71466c252634daeceba6c4dc183f250e122ca79c /core/Kind.zig | |
| parent | 2dae98b564e677c24c5275070c413d05a85d12fc (diff) | |
| download | pardes-f11b123a8f4c38b6582c03d2acf84143ed1e7fd3.tar.gz pardes-f11b123a8f4c38b6582c03d2acf84143ed1e7fd3.zip | |
Kind: a picture drawn for a pane that shows no kind's slot when it lands is dropped there, never kept in `ready` for a paint that never comes (the soak with the pdf addon on this stack's top, after kysrwqpz: `allocator leaks detected` at seed 1 rtt 30, two draws of the pdf addon's, their inputs (api.draw's copy), their KindJobs and their pixels (KindJob.run's arena), and `ready`'s own buffer, all from Kind.paint's draws landed by Kind.landDraw); THE CAUSE: a draw is a frame's, run on a worker and landed on the loop later (landDraw), which kept it for the pane's next paint unless the pane had closed or its serial moved; a picker's preview (Pick.showKind) is a kind's slot over a pane that stays: Esc, the next row or ⏎ closes the slot (Kind.close drops the draws then in `ready`), and a draw still on its worker lands after it on a pane that is its own text again; no paint of a kind ever takes it (deliver runs for a kind's pane alone) and the pane's own close passes it by (Kind.close returns at once for a pane with no slot), so it stayed until the process ended, a page's pixels a draw (megabytes) in a long session for every preview closed under a draw; THE FIX: landDraw drops a draw whose pane has no kind's slot (`pane.addon == null`), as one whose pane closed; a draw of an earlier slot landing on a later one is dropped at its paint as before (Slot.drawn_from, gen, ops); RUN (TEST FIRST): Kind.zig "a picture drawn for a pane that shows no kind's slot when it lands (a picker's preview closed meanwhile) is dropped, never kept for a paint that never comes": a draw landed on a text pane: kept in `ready` on the base (expected 0, found 1), dropped now; the soak with the pdf addon: diverged 0, unequal 0, quiet checks 566/0 481/0 674/0, stops not on may_wait 0, the corpus 22 of 22 scenes the same, no leak, the pdf panes the session opened 6, 7 and 7 (the same stack without this change: the leak at seed 1 rtt 30); a user hit it with every picker over PDFs moved or closed while a page drew (the session's own frontend draws on workers too): memory held to the session's end; NEW HOT PATHS: none (one field read as a draw lands); GATES: core-test 1164/1339 (175 skipped: +1); load 2.9 to 9.8
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Kind.zig')
| -rw-r--r-- | core/Kind.zig | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/core/Kind.zig b/core/Kind.zig index 9316c502..c8420c8a 100644 --- a/core/Kind.zig +++ b/core/Kind.zig @@ -1310,8 +1310,11 @@ var drawn: u32 = 0; /// its own. pub fn landDraw(p: *Pardes, j: *host_io.KindJob) void { if (j.draw != p) return j.drop(); - // Its pane closed meanwhile: no paint of it would ever take it. - if (if (p.panes[j.pane]) |pane| pane.serial != j.serial else true) return j.drop(); + // Its pane closed meanwhile, or showing no kind now (a picker's preview + // closed, the pane its own text again): no paint of it would ever take + // it, nor would the pane's close (Kind.close: a slot's draws). + const pane = p.panes[j.pane] orelse return j.drop(); + if (pane.serial != j.serial or pane.addon == null) return j.drop(); ready.append(heap, j) catch return j.drop(); p.needs_frame = true; } @@ -1427,3 +1430,18 @@ const GpuPaint = struct { return 0; } }; + +test "a picture drawn for a pane that shows no kind's slot when it lands (a picker's preview closed meanwhile) is dropped, never kept for a paint that never comes" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + _ = try p.setTestFile("the notes\n"); + const id = p.view().active; + try std.testing.expect(p.panes[id].?.addon == null); + // A draw of the preview's, back from its worker after Esc gave the pane + // its own text again. + const j = try heap.create(host_io.KindJob); + j.* = .{ .gpa = heap, .pane = @intCast(id), .serial = p.panes[id].?.serial, .token = c.PA_DRAWN | 1, .gen = 0, .ops = &test_kind.ops, .in = try heap.dupe(u8, "draw"), .arena = .init(heap), .draw = p }; + Addon.holdJob(j.ops, true); + landDraw(p, j); + try std.testing.expectEqual(@as(usize, 0), ready.items.len); +} |
