Repository navigation
fix(studio): keep the editor responsive when a preview asks for paused frames - #8943
Conversation
Edit accuracy: accurate 273 (base branch 271), smooth 90 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) |
vanceingalls
left a comment
There was a problem hiding this comment.
Code is clean at 5a25a46. I am not approving yet because two Windows checks are red and I cannot tie them to main. Approval follows green.
What I checked:
- Bound before the walk:
pausedFrames.ts:89now usesisMessageList(data.asks, PAUSED_FRAME_SOURCES).refuseMessageListcheckslength > maxfirst and then looks for holes in at most 4 slots, so a declared length of 2^32-1 is refused beforemap/everyrun. - Refusal is explicit for a real ask:
pausedFrames.ts:160throws "Preview decode over budget" inportPausedVideoProvider.decodebefore anything is posted. A hostile frame message is dropped by the parser, like the other readers.pausedVideoProvider.ts:139still replies "failed" for an empty list. - Tests cover both cases:
pausedFrames.test.tshas one test for the sparse list (hole) and 2^32-1, plus the over-cap list (5 sources), each under 1 s. A separate test covers the runtime throw with no post.pausedVideoProvider.test.tschecks that over-cap and 2^32-1 asks reach no decode and thatsuspendis still answered. - "fails without the fix:" is in the body and names real tests at this head.
- Siblings: the studio message readers in
previewChannel.tsalready useisMessageList. I found no other unbounded frame-message reader.
Non-blocking, for a follow-up: packages/studio/src/hooks/useConsoleErrorCapture.ts:106 does raised.map(String) on window[STUDIO_PREVIEW_ERRORS], an array the composition itself can set. It is a same-origin read, not a message, but a sparse array there is the same shape of problem.
CI at 5a25a46: the checks finished with 2 red, "Tests on windows-latest: engine-cli-3" and "Tests on windows-latest". The failing tests are engine/src/services/chunkEncoder.test.ts and engine/src/utils/ffprobe.test.ts (ffprobe exit code 1). This PR touches only core/runtime/editing and studio/player/lib. Main's latest Windows run (f00e934) is green, and the other red Windows run (renovate branch) failed different tests. So I cannot call it not-this-PR or a flake. A rerun that goes green, or a link to the cause on main, clears it.
|
Thanks. On the two points:
|
vanceingalls
left a comment
There was a problem hiding this comment.
Approving at 5a25a46. The code was clean on my earlier pass. The decode-ask list is bounded by isMessageList(data.asks, PAUSED_FRAME_SOURCES) before any iteration, an over-cap ask is refused explicitly, and tests cover the sparse, 2^32-1 and over-cap cases. The two red Windows checks (engine ffprobe/chunkEncoder tests, files this PR does not touch) passed on a rerun of the failed jobs, so they were flakes. Every check is now green at this head. Follow-up, not blocking: useConsoleErrorCapture.ts:106 does raised.map(String) on a composition-settable array without a bound.
What
Studio now reads a paused-frame
decodemessage only when itsaskslist has no gaps and at mostPAUSED_FRAME_SOURCES(4) entries. A longer list is dropped before any entry is read. The runtime checks the same limit before it sends, so a decode naming more than four sources still fails at once with "Preview decode over budget".Why
parsePausedFrameAskaccepted any array and then ranmapandeveryover its declared length. A message can declare a length of up to 2^32-1 with no entries behind it, and walking that kept the editor busy for minutes. The four-source limit was checked by the host only after the parse finished.Related work
Uses the
isMessageListcheck the other preview-frame readers use (packages/core/src/runtime/protocol.ts).How
parsePausedFrameAsk:Array.isArray(data.asks)becomesisMessageList(data.asks, PAUSED_FRAME_SOURCES). This checks the length first and then looks for gaps in at most four slots.portPausedVideoProvider.decode(runtime side): throws "Preview decode over budget" when it gets more than four requests. Before this change, the host sent that reply after the decode reached it. With the parser now dropping such a message, a decode over the limit would otherwise wait with no reply.pausedFrameHost.decode: drops its now-unreachable> PAUSED_FRAME_SOURCESbranch and keeps the empty-list reply.messagelistener and port handler inpackages/studio/src(15 in all). None walks a list from the frame before bounding it.Test plan
pausedFrames.test.ts: a decode of 1 to 4 sources is read; a declared length of 2^32-1, five sources and a list with a gap are each refused in under a second; the runtime fails a five-source decode without posting anything.pausedVideoProvider.test.ts: five sources and a 2^32-1 list reach no decode, and the port still answers asuspendstraight after.pausedFrames.tsthe core file did not finish within 90 s (the parser walking the declared length). On its own,fails a decode of more sources than Studio reads without askingtimed out at 5 s with no reply.pausedFrames.test.ts5/5 and the fourpausedVideoProvider*/pausedVideoDecodertest files 42/42, each 3 runs in a row.editingPort,editingAgentandpausedVideoFramestests 220/220. Studiotsc --noEmitis clean, andoxlintandoxfmtare clean on the changed files.No visible change
Message parsing and tests only; no .tsx, .css or .html changed. A valid paused-frame decode behaves as before.