forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on dff7d843f3d0fedec086d9c2e7e2b68304835ed5Filtered to crates/engine/src/decode.rsClear filter

2026-08-10

🐛 fix(engine): a refused project load cannot hang on its own decoderAhmet Kaan Gümüş · 771cd4a
🐛 fix(engine): a refused project load cannot hang on its own decoder

`open_project` starts decoding source 0 before it validates anything, so
by the time a later source is refused that worker has filled the
two-frame channel and parked in `send`. The receiver and the worker were
two locals, and locals drop in reverse order of declaration: the worker
joined a decode thread that only the receiver beside it could ever wake.
The app froze on a bad project file instead of showing the error.

The two are one value now. `FrameStream` holds the receiver first and
the worker second, and Rust drops fields in declaration order, so the
disconnect always precedes the join -- in an early return, on an unwind,
and in call sites not written yet. Nothing on the seek path changes:
`start_span` still installs the new receiver and parks the old worker in
the retire list without ever joining.

The device moves below the validation for the same reason. Its feeder
thread outlives the `Audio` value and only a session's `drop` retires
it, so a refusal above that line left a PipeWire stream and a thread
behind for a project that never opened.

Tests: dropping a stream whose frames nobody took returns instead of
hanging (10 s bound; hangs if the two fields are swapped), and the
refusal path itself with enough sources that the park is certain -- 60 s
hang before the fix, 0.04 s after.
✨ feat(engine): video+audio lanes with offset-placed clips, gaps, .edith v2Ahmet Kaan Gümüş · 59eb78e
✨ feat(engine): video+audio lanes with offset-placed clips, gaps, .edith v2

Project gains two lanes; a Clip now carries `start` (its timeline
placement) and `link` (group id), so a gap is simply the absence of a
placement rather than an object anyone has to keep in sync. Moves and
trims become arithmetic on start/in_frame; the lane invariant (sorted,
non-overlapping) is checked in from_parts, at the .edith parser, and
asserted after every mutation.

split cuts every lane and hands the two sides fresh group ids; regroup
is its exact inverse. delete still ripples both lanes (the app keeps its
behaviour), lift removes one placement and leaves a hole, place is the
per-lane overwrite that can make one.

A video gap plays as black frames from a worker that opens no file --
same channel, backpressure, cancel and retire path as a decoder -- and
exports as encoded black. An audio gap is synthesised zero chunks, real
ones, so the master clock keeps counting through it; on the export side
it is spent as stts duration on the packet beside it, since there is no
AAC encoder to make silence with.

.edith v2 writes one line per placement per lane; v1 files still load,
as fully-grouped gapless lanes, and save as v2.

2026-08-09

⚡ perf(playback): retire cancelled workers off the seek pathAhmet Kaan Gümüş · 3adbaf7
⚡ perf(playback): retire cancelled workers off the seek path

Joining the outgoing decode worker inline made a seek pay whatever VA-API
init that worker was still inside -- 98.4 ms worst case against 1.6 ms
before the join landed, i.e. a scrub capped at ~10 seeks/s with a visible
hitch per step.

Cancelled workers now go into a retire list instead. Every seek sweeps it,
dropping only the ones whose thread has already returned (`is_finished`,
never a wait), and the session's drop joins whatever is left along with the
running worker -- so the exit guarantee is untouched: no decode worker
outlives its session, and none can be inside libva when Mesa's atexit
handlers run.

Worst seek back to 4.7-6.1 ms over three drill runs. Open+drop stays at
~13.5 ms, which is the same join as before and a session drops rarely.
Retire list peaked at 16 under a back-to-back 20-seek loop -- a UI scrub
leaves far more time between steps.
🐛 fix(decode): join workers on drop — Mesa atexit race killed exiting processesAhmet Kaan Gümüş · 9276137
🐛 fix(decode): join workers on drop — Mesa atexit race killed exiting processes

A decode worker was spawned detached and nothing ever waited for it, so a
process could exit while a worker sat inside `vaInitialize`. Mesa frees its
process name from an `atexit` handler and the worker then reads it back
NULL: SIGSEGV at exit, 9 runs in 20 of the saveload suite.

`DecodeSession::open_worker` now hands the caller a `Worker` that owns the
`JoinHandle`; dropping or replacing one cancels and joins. `PlaybackSession`
holds one, so a seek, a clip boundary and the session's own drop all wait
for the worker they abandon. The worker also checks the cancel flag before
and after opening the hardware session, so a cancelled one never enters
VA-API init at all. Public `open`/`open_at`/`open_range` are unchanged.
✨ feat(engine): clips primitives — edit-list model, bounded decode, segmented audioAhmet Kaan Gümüş · e75a7ba
✨ feat(engine): clips primitives — edit-list model, bounded decode, segmented audio

Lane 1 of the clips slice; PlaybackSession traversal comes next.

- project.rs: Clip/Project — cut (metadata-only, refuses no-op
  splits), delete (closes gap, keeps ≥1 clip), undo snapshots,
  timeline↔source mapping with boundary sweep tests
- decode: open_range(start, end) — both backends stop after end-1,
  empty/inverted ranges disconnect cleanly without spawning a worker
- audio: open_segments — one worker walks the edit list; segments
  bit-exact vs equivalent seeks, joins gapless by contiguity assert,
  head+tail trim inside a single AAC packet handled
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_atAhmet Kaan Gümüş · 96ae365
✨ feat(engine): seek primitives — video open_at, ao_flush, audio open_at

Lane 1 of the seek slice; PlaybackSession orchestration comes next.

- demux/decode: stss sync lookup, DecodeSession::open_at decodes from
  the keyframe and discards to the target; Frame.index stays absolute.
  HW plugin ABI: vh_open renamed vh_open_at(path, target) — discards
  skip the vaGetImage readback; measured seek cost 65ms HW / 222ms SW
- engine-audio: ao_flush drains the ring consumer-side in the RT
  callback (one-shot atomic), stale PCM unplayable even when paused;
  played-position atomics untouched so clock math survives
- audio: open_at walks stts, 2-packet AAC pre-roll (MDCT overlap
  reconstructed exactly — verified 0-diff before the first PNS band),
  sample-exact trim; priming skip and seek discard unified. AAC seek
  is deliberately not bit-exact: symphonia's PNS noise LCG state
  depends on packet history; bounded <1e-3 by test instead
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui previewAhmet Kaan Gümüş · 0acbf8d
🎉 feat: MVP decode pipeline — mp4 → H.264 → gpui preview

- engine: mp4 demux → Annex-B, rusty_h264 software decode, BT.601
  I420→BGRA; decode on worker thread behind a bounded channel
- engine-hw: optional VA-API decode plugin (cros-codecs) behind a
  C ABI, dlopen'd at runtime with silent software fallback; the app
  binary keeps zero libva/gbm/drm linkage so it runs on any distro
- app: gpui window, per-frame RenderImage swap + drop_image
- vendor/: cros-libva + cros-codecs with 3 LOCAL PATCH fixes (libva
  1.23 struct init, radeonsi 64x64 min context, pub surface()) —
  upstream is dormant, so vendor/ is adopted code, not a temp fork
- fixtures are gitignored; scripts/gen_fixtures.sh regenerates them