ludic.ui: a new component instance's first build is declared - a first show mid-play is not a frame's keep

Master's windowed fog profile failed the fence at walk t 35 s: +512 B from value_new / value_put /
value_slot / value_lists under bd_class and cmp_keycap_model - a KeyCap first shown mid-walk.

It is a first build, bounded, not a per-show leak: an unmounted instance goes to in_free and the next
show of its class reuses it (in_reuse, `renew`), its props and model objects kept and filled in place.
Only a NEW instance makes them - bounded by how many of that class are up at once, and the ones
unmounted less than two builds ago. in_reuse already declared the record; the props and model objects
and their first fill, made afterwards in bd_class, were not. They are now: in_reuse marks a new record
`fresh`, and bd_class's first fill of it goes through bd_first_fill (@alloc_ok) - a reused instance's
fill stays judged, so a real per-show leak would still fail.

Golden ui_first_show: a component first shown at frame 700, once the fence is judging, then hidden and
shown twice more: bad 0 (the toolchain before this fails frame 701: +464 B value_new from value_slot
under cmp_cell_model, value_put grow - the profile's failure). The 37 ui examples pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 15:18:22 +03:00
parent b9f9cb8495
commit 2958539514
10 changed files with 67 additions and 10 deletions

View file

@ -0,0 +1,27 @@
# ui_first_show.ludic - a component shown for the first time once the fence is judging (a prompt's key
# hint mid-walk) makes its instance's props and model: declared, once per instance, and the failing
# fence lets it through; hidden and shown again, the instance is reused and nothing more is made:
# bad 0 shown 3
import "ludic.ui"
import "ui_first_show_parts/Cell.ludic"
import "ui_first_show_parts/Host.ludic"
program UiFirstShow {
numbers float
function frame(ui_st: mut UiState) -> UiNode {
let root: UiNode = ui_nodes(ui_st, "Host", null)
ui_place(ui_st, root, 0.0, 0.0, 400.0, 400.0)
return root
}
entry (ui_st: mut UiState) {
var shown = 0
for f in 0 .. 1400 {
let root = frame(ui_st)
if f == 700 or f == 900 or f == 1000 or f == 1100 or f == 1200 {
ui_press(ui_st, root.children[0].children[0])
if f != 900 and f != 1100 { shown += 1 }
}
Mem.frame()
}
print(`bad {Mem.bad_frames()} shown {shown}`)
}
}

View file

@ -0,0 +1 @@
.cell { width: 100px; height: 40px }

View file

@ -0,0 +1,3 @@
component Cell {
prop caption: string = ""
}

View file

@ -0,0 +1,3 @@
<div class="item">
<button class="cell" on-click="emit click"><p>{caption}</p></button>
</div>

View file

@ -0,0 +1 @@
.t { width: 60px; height: 30px }

View file

@ -0,0 +1,4 @@
component Host {
state on: bool = false
on flip() { on = not on }
}

View file

@ -0,0 +1,4 @@
<div>
<button class="t" on-click="flip()">t</button>
<if test="{on}"><Cell caption="a"/></if>
</div>