perf: unblock long-file loading; add collision detection and jump nav

Three things, all surfaced while working a multi-node protocol issue on a
5.7-hour capture.

**Loading was frame-paced, not compute-bound.** The STFT overview advanced
a fixed 200 segments per frame, so the frame limiter — not the FFT — set
the pace: 478k segments at ACTIVE_FPS meant over a minute spent waiting
between frames rather than computing. The tell was absurd: backgrounding
the window, which skips presenting entirely, loaded the same file in
seconds. The progress bar was slower precisely because you were watching
it. The overview is now computed in one blocking call after presenting the
loading panel, so focused load matches the unfocused speed. The panel says
the window will stop responding and drops the percentage, which could not
animate and would have read as a hang. ACTIVE_FPS 30 -> 60 while here;
idle still parks at ~0% CPU through the event-wait path.

Background work also no longer stops when the window loses focus. Pending
work now counts as "active" regardless of focus, so the loop doesn't block
in PollInputEvents waiting for input that isn't coming, and an unfocused
frame with work outstanding skips the draw pass entirely rather than
throttling the high-res fill to the refresh rate.

**Collision detection.** Annotations that overlap in both time and
frequency are flagged, merged into contiguous regions, and drawn as red
bands confined to the band the overlap occupies (padded, so a narrow
overlap stays findable) rather than spanning the full axis and hiding the
signal being pointed at. N / Shift+N and sidebar buttons jump between
regions, centring each without disturbing the current zoom.

Point markers are excluded: control events and assertions have no band and
zero duration, and treating a missing band as "whole spectrum" — which is
how they are *drawn* — made every marker collide with whatever it sat
inside. That was 38% of the reported collisions on a real capture. Only
things that actually occupy the air can interfere. Counts verified against
an independent reference implementation on two captures.

**Scope waveform via min/max summary.** The envelope rescanned every
visible sample every frame — ~245M reads, near 1 GB of memory traffic, on
a multi-hour file, measured at ~60 ms/frame for a few hundred pixel
columns. It now draws from 1024-sample buckets built once at load (60 ms,
1.9 MB), measured at ~0.07 ms/frame. Keeping both extremes per bucket
means single-sample transients still show at full zoom-out, which plain
decimation would drop; verified that no column ever understates a true
peak. Zoomed in past a bucket it falls back to raw samples, which is cheap
there by definition.

Also fixes ComputeCollisions never running for files opened through the
file browser, and moves the collision panel above the annotations dropdown
where it isn't pushed off the bottom of the sidebar.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ZWfr5XZyyDttvkhJUgHN
This commit is contained in:
2026-08-12 13:58:58 -07:00
parent 8026d10547
commit 4c3c6a955a
8 changed files with 656 additions and 135 deletions
+34 -1
View File
@@ -135,7 +135,8 @@ or pressing **O** for the file browser. Try the bundled sample:
| **Alt+drag** / **middle-drag** | Pan the view |
| **LMB drag** | Select a time + frequency region |
| **Space** | Play / stop the selected region |
| **Hover an annotation** | Tooltip with that frame's mLnL detail |
| **Hover an annotation** | Tooltip with that frame's mLnL detail; lists **every** overlapping frame under the cursor |
| **N** / **Shift+N** | Jump to the next / previous collision |
| **P** | Show / hide the waveform scope |
| **M** | Marker / ruler tool |
| **S** | Spectrum slice (PSD) |
@@ -150,6 +151,28 @@ or pressing **O** for the file browser. Try the bundled sample:
Most controls are also available as buttons in the left sidebar (colormap, floor,
dynamic range, annotation opacity, grid, …).
### Inspecting overlapping transmissions
When several stations are on the air at once their annotation boxes stack, and
the one drawn last hides the rest. Two features address that:
- **Hover** any pile-up and the tooltip lists *every* frame under the cursor —
one row per frame with its own colour swatch, led by the fields that actually
tell them apart (node, frame name, position in the PTT, channel). Deep piles
are capped with a `+N more` count.
- **Collisions** (sidebar toggle) highlights where transmissions genuinely
overlap in **both** time and frequency. `N` / `Shift+N`, or the sidebar
`< prev` / `next >` buttons, jump between them; each jump centres the region,
keeps the current zoom unless the region needs more room, and reports its
position (`Collision 7/54 — 3 frames at 1284.95s`).
A collision requires a real overlap in time *and* band, so two frames in
different channels at the same instant are not flagged, and neither are
zero-duration point markers (`control`, assertions), which annotate the run
rather than occupy the air. Markers are drawn only across the band the overlap
occupies, not the full frequency axis. Adjacent collisions merge into one
region, so a busy stretch reads as a single span rather than dozens of bars.
---
## Usage (headless render)
@@ -231,6 +254,16 @@ paths.
frequency resolution `sampleRate / fftSize` Hz per bin. Amplitude in dB.
- **Axes** — X = time (s), Y = frequency (Hz, scaled to the file's Nyquist),
colour = amplitude.
- **Long files** — two things keep cost tied to what's on screen rather than to
total duration. The spectrogram image is built for the *visible* segment range
(capped at 8192 px wide), so a multi-hour capture renders at all — an
unbounded full-file image exceeds the GPU texture limit and silently draws
nothing — and zooming in genuinely re-renders at higher resolution instead of
magnifying pixels. The scope draws from a precomputed min/max summary
(1024-sample buckets) rather than rescanning every visible sample each frame,
which on a 5.7-hour file is the difference between ~60 ms and ~0.07 ms per
frame. Keeping both extremes per bucket means a single-sample transient still
shows up when fully zoomed out.
- **Time zoom limit** — the tightest visible window is derived from the STFT hop
(`fftSize / HOP_RATIO` samples), not from a fixed fraction of the file, so time
resolution does not degrade as files get longer: a 30-minute recording zooms in