Repository navigation
feat(runtime): expose frame-presented request and preview health metrics - #8933
Conversation
Edit accuracy: accurate 273 (base branch 271), smooth 67 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
…ealth-metrics # Conflicts: # packages/core/src/runtime/editingAgent.test.ts # packages/core/src/runtime/editingAgent.ts # packages/core/src/runtime/editingPort.test.ts # packages/core/src/runtime/editingPort.ts
…ealth-metrics # Conflicts: # packages/core/src/runtime/editingAgent.ts
terencecho
left a comment
There was a problem hiding this comment.
P2 · Bound the frame-side lifetime of frame-presented. packages/core/src/runtime/editingAgent.ts:184–213 installs a fresh set of seek listeners and a document-wide observer per seeking video per request. The caller timeout in editingPort.ts:977–981 settles only the host promise. A seek that stays pending leaves the frame-side listeners and observers alive, and subsequent requests add more. Disposal also settles the seek waits into the two-RAF stage, whose callbacks are outside cleanup. Use a bounded, cancellable wait across both stages, release listeners and observers and cancel RAF callbacks on teardown, and report presented: false if the wait expires before presentation. Please cover cleanup for a seek that never settles and disposal with an animation frame pending.
The required checks are green or skipped as expected. This finding is from source review.
— tai (automated review)
|
Fixed in b7489b7.
Tests (both fail on 218cce9): "answers presented false and lets go of the video when its seek never settles" (all four listeners removed, observer disconnected) and "cancels a pending animation frame when the agent is disposed". The existing frame-presented tests still pass; |
terencecho
left a comment
There was a problem hiding this comment.
The new request cleans up its timer, video listeners, observer, and pending animation frame on completion, deadline, or agent disposal. The deadline returns presented: false. All 197 targeted editing-agent tests passed locally, and the new cancellation test failed with the previous source. All applicable required checks passed.
— tai (automated review)
…ealth-metrics # Conflicts: # packages/core/src/runtime/editingAgent.test.ts # packages/core/src/runtime/editingAgent.ts # packages/core/src/runtime/editingPort.test.ts # packages/core/src/runtime/editingPort.ts
terencecho
left a comment
There was a problem hiding this comment.
The merge preserves both parents’ request kinds, parameter parsers, handlers, and teardown calls. The bounded frame wait and its tests are intact. All applicable required checks passed at this head.
— tai (automated review)
…ealth-metrics # Conflicts: # packages/core/src/runtime/editingAgent.ts
terencecho
left a comment
There was a problem hiding this comment.
The merge retains main’s canvas-key handler verbatim and preserves the frame-presented registration, bounded wait, and teardown. All applicable required checks passed on this head.
— tai (automated review)
Summary
Expose frame-presentation timing and playback-health metrics from inside the preview runtime so Studio and host applications receive identical readings regardless of frame origin:
frame-presentedediting request (packages/core/src/runtime/editingPort.ts,editingAgent.ts,packages/studio/src/player/lib/frameFacts.ts):frame-presentedrequest that waits for any seeking<video>elements inside the preview document to settle and then awaits tworequestAnimationFrameticks before returning{ presented: true }.seeked,error,abort,emptied, DOM disconnection (viaMutationObserver), and agentdispose(), removing all listeners and observers on settlement so no listeners leak.wait-for-seekunchanged for existing callers.preview-health(packages/core/src/runtime/playbackHealth.ts,init.ts,types.ts):<audio>element frommediaClipsInWindow(zero per-frame DOM queries) and computesmediaStepP90Ms(positive steps under 500 ms over the 3 s window) alongsideover16(gaps > 25 ms) andover33(gaps > 41.7 ms).motionBlur(attr,shutter,state,tier,movers) viareadMotionBlurSummaryonly when emitting the 1 s health report (zero per-frame work).preview-facts(packages/core/src/runtime/playbackHealth.ts,init.ts,types.ts):frameShape(canvas,svg,filter,tweens) topreview-facts, read only on demand whenrequest-preview-factsis handled (zero per-frame work).packages/studio/src/player/store/previewQualitySlice.ts):parsePlaybackHealthandparsePreviewFacts, dropping out-of-range numbers, non-finite values, oversized strings, and unknown enum values.Testing
packages/core/src/runtime/editingAgent.test.ts(frame-presentedsuite failed withunknown-kind),packages/core/src/runtime/playbackHealth.test.ts(emits audio step p90, missed-frame counts, and reads motionBlur only on the 1 s emitfailed withexpected undefined to be 25), andpackages/studio/src/player/store/previewQualitySlice.test.ts(validates, bounds, and allowlists ...andvalidates and bounds frameShape ...failed withundefined).packages/core/src/runtime/editingAgent.test.ts(195 tests) andeditingPort.test.ts(13 tests): verifiesframe-presentedwaits forseeked+ two animation frames, settles onerror/abort/emptied/DOM disconnect, and removes listeners cleanly.packages/core/src/runtime/playbackHealth.test.ts(16 tests): verifiesmediaStepP90Ms,over16,over33,readMotionBlurSummary(invoked only on health emits, never per frame), andreadPreviewFrameShape.packages/studio/src/player/store/previewQualitySlice.test.ts(8 tests): verifies valid, nullable, and rejected/out-of-bounds payloads formediaStepP90Ms,over16,over33,motionBlur, andframeShape.packages/core:build,typecheck(includingtypecheck:runtime),lint:runtime-preview-guards, runtime contract/behavior/seek checks, and full vitest suite (354/354 files passed).packages/studio:typecheck,oxlint,oxfmt, and full unit vitest suite (851/851 passed, 1 skipped).packages/engine:typecheckpassed; vitest 217/222 passed (5 local MPEG-TS tests failed withSIGSEGVin the local static FFmpeg binary; CI verifies full engine suite).packages/producer:typecheckpassed; unit vitest 123/124 passed (same local MPEG-TS static FFmpegSIGSEGV) and bun unit lane 54/55 passed (videoAudioProbe.test.tsremote-probe download path deferred to CI).No visible change
Pure runtime editing-port, playback-health reporting, and Studio store parser changes (
.tsonly, no UI, CSS, or DOM rendering changes).