fix(sync): survive push heap exhaustion and instrument the push path

Run 4 (2026-07-13): remote.push() consumed ~6 MB of PSRAM over 66 s and
the UI thread aborted on Frame::new_white's per-draw vec![0xFF; 26928].
Run 5 confirmed the UI now survives, but the push still exhausts both
pools (a ~7 KB inflateInit fails inside the pack build) and the heap
telemetry never fired — hence the telemetry rework.

- display/editor: Editor::draw_into() renders into a caller-owned
  Frame; main.rs keeps two boot-time frames (shown/back) and mem::swaps
  on success, so steady-state repaints never allocate.
- git_sync: odb cache capped at 1 MB via raw libgit2-sys opts (git2
  0.20 doesn't wrap the total cap); log_push_heap at pre-push,
  post-push and push-failure with largest-PSRAM-block and per-pool
  min-evers; pack_progress logging is now time-gated (2 s) — the
  count gate (+256 objects) never fired because AddingObjects reports
  total=0 and a small push inserts only dozens of objects.
- editor: empty/whitespace snippets file parses as 0 snippets instead
  of a JSON error at boot.
- build.rs: refuse a git-feature build with unset TW_* publish vars —
  a bare `cargo build --features git` baked empty creds and produced a
  firmware whose :sync could never work.
This commit is contained in:
Julien Calixte
2026-07-13 21:04:18 +02:00
parent 05706478a2
commit f79d13453a
6 changed files with 182 additions and 23 deletions

View File

@@ -35,6 +35,25 @@ impl Frame {
Self { buf: vec![0xFF; FB_BYTES] }
}
/// A zero-capacity placeholder, for the buffer-swap pattern:
/// `Editor::draw_into` takes the caller's buffer out through one of these
/// and puts it back when done. Not drawable until [`clear_white`]
/// (or a `draw_into`) gives it its buffer.
///
/// [`clear_white`]: Frame::clear_white
pub fn empty() -> Self {
Self { buf: Vec::new() }
}
/// Reset to all-white paper, reusing the existing allocation when the
/// buffer is already full-size. This is what lets firmware repaint without
/// allocating: a background `:sync` push can take the heap to the floor,
/// and a failed framebuffer alloc aborts the whole app (2026-07-13).
pub fn clear_white(&mut self) {
self.buf.clear();
self.buf.resize(FB_BYTES, 0xFF);
}
pub fn new_black() -> Self {
Self { buf: vec![0x00; FB_BYTES] }
}