Repository navigation
fix(studio): a sealed preview shows its loading overlay while media still loads - #8184
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 70 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
d595636 to
424a478
Compare
terencecho
left a comment
There was a problem hiding this comment.
- [P1] The first asset check can report ready during buffering. At
packages/studio/src/player/components/Player.tsx:266, an editing-port client opened before iframe load can be disposed by the same load event that starts the asset check. The first request then falls back to “ready.” In Chromium, using Studio’s Player and the editing agent with a stub player element, the preconnected case reported ready with the overlay hidden while a fresh port reported buffering. Without a preconnection, the overlay appeared and readiness stayed false. Run the first check after the frame’s load-time port cleanup and cover that ordering at the Player level. - [P2] Include the first sealed reply in the asset wait cap. At
packages/studio/src/player/components/previewAssetWait.ts:83, the ten-second timer starts after the first reply. With the first reply delayed and the next check pending, a fake-timer probe still showed the preview loading after the ten-second mark. - [P2] Invalidate the pending first reply on teardown. The liveness check in
packages/studio/src/player/components/Player.tsx:269only compares the load count. A Player test unmounted during the first request and observed two more polls afterward.
The workspace build, Studio and Core typechecks, 2,594 Studio player tests and 205 focused Core tests passed. Restoring the old direct read caused both sealed query regressions to fail. The CI support shard timed out in an AWS Lambda test, which also made the aggregate check fail. I did not repeat the full CLI screenshot run.
— tai (automated review)
|
Fixed in c9da5a6. All three findings came from one cause, fixed in one place,
fails without the fix, in
The tests drive the wait with a stand-in for the frame's answers rather than at the Player level. With the fix, the outcome no longer depends on when the port connects, so the wait itself is the place to pin it. The two sealed tests that ask the real editing agent stay in |
terencecho
left a comment
There was a problem hiding this comment.
The three prior findings are resolved. A missing sealed reply keeps the preview unready and retries. The first request counts against the shared window, and a late reply after teardown cannot update loading state.
- [P2] Dispose the editing-port client with its iframe. At
packages/studio/src/player/components/Player.tsx:317, cleanup clears the interval and removes the frame. The client only disposes on a future iframe load (previewChannel.ts:27). When the editing agent never connects, the client's window message listener retains the detached iframe. A Chromium fixture with a nonresponsive preview still had one listener registered 10.3 seconds after unmount. The same fixture with the base Player had none. Dispose the existing client during cleanup so each retired Player releases its listener and pending work.
All 2,597 Studio player tests, 205 focused Core tests, Studio typecheck, and eight extra timing checks passed. The three new wait tests failed with the previous implementation and passed at this head. The Chromium preconnected-port fixture now kept readiness false while the media buffered. Full screenshot comparison and sealed Lottie browser validation were outside this pass.
— tai (automated review)
|
Fixed in 53fa69d. [P2] A closed preview frees its editing-port client. Each frame's client now has one retire step, fails without the fix: |
terencecho
left a comment
There was a problem hiding this comment.
The teardown finding is resolved. Player cleanup now retires the iframe's editing-port client and removes its load listener. The Chromium fixture with an unresponsive preview dropped from one window message listener to zero after unmount. A separate reload check showed the retired client's pending request was rejected and the replacement client stayed usable. The preconnected preview still showed the loading overlay while media buffered.
The Player teardown regression failed without the retirement call and passed at this head. All 59 focused Studio tests, Studio typecheck, and lint and formatting checks for the changed files passed. Preview parity passed in CI. The full CLI screenshot comparison was outside this pass.
— tai (automated review)
…hrough the editing port
…never taken as ready
e0a2f45 to
5ef4be8
Compare
Rebased on main at 5ef4be8: what changed since e0a2f45
No other line differs from the approved head. CI at 5ef4be8: 89 pass, 11 skipped. |
terencecho
left a comment
There was a problem hiding this comment.
The rebase preserves the approved patch. Eight commits match exactly, and the remaining commit adds the same asset-readiness request alongside the soft-reload request now on main. Each request keeps its own type, validator, and handler. Both returned the expected reply when sent concurrently on one editing port.
The workspace rebuild, 224 focused Core tests, 130 focused Studio tests, lint, and formatting checks passed. CI reported 89 successful checks and 11 skipped. The full CLI screenshot comparison was outside this pass.
— tai (automated review)
What
With the preview sealed (
VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true), the preview's loading overlay shows while its video, audio or Lottie still loads, as it does with the preview open. Before, a sealed preview never showed it, so pressing play on a cold video could start on a blank or stalled first frame with nothing saying why.Why
Studio decides whether to show the overlay by reading the preview's document for media that cannot play through yet. A sealed frame refuses that read, so the check fell back to "nothing loading" every time.
How
previewAssetsUnloaded(core/src/lottieReadiness.ts) holds the check: a<video>or<audio>without an error, with a source, that cannot play through yet, or a Lottie still loading. Studio's open-frame check (hasUnloadedAssets) now calls it, so both frames answer the same question the same way.assets-unloaded, added at the end of the list. The frame's agent answers it with that same check over its own document.previewStillLoading(player/components/Player.tsx) asks the open frame directly and a sealed frame over the port. The overlay poll uses it after the first check: an open frame's first check is still synchronous, and a sealed frame's first answer holds readiness back without showing the overlay. Every 100 ms tick still counts toward the 10 s cap, even while an answer is pending, and an answer that arrives after a newer load is ignored.Test plan
packages/studio/src/player/components/Player.sealed.test.ts, the first commit. It runs the real editing agent behind a frame Studio cannot read. On a Linux box, with the sealed branch ofpreviewStillLoadingsent back to the direct document read main uses, both sealed tests fail: a buffering sealed preview reads as loaded (expected false to be true), and a ready one reads as still loading (expected true to be false).Player.sealed.test.tsandPlayer.test.tspass 3 of 3 runs (38 tests). The Studio player suite (src/player) passes 211 files, 2,592 tests, and core's editing port, agent and readiness tests pass 169. Studio and core typechecks exit 0.Player.test.ts). A sealed preview holds readiness back until its first answer arrives, without showing the overlay for a frame that has no media.window.originin the frame isnull) at main and at this branch, opening a fixture whose audio request is held back for 20 s. Inside the frame the audio stays unloaded (readyState0,networkState2) on both. Both screenshots show the same loader over the first frame, and no pixel differs by more than 24 of 255: in this setup the preview's own loader already covers the media wait, so Studio's asset overlay never gets its turn. No console errors either way.Before
No visible difference in a real sealed preview: the preview's own loader covers the media wait there (details under Manual testing). The unit tests above carry the proof.
After
The same screen on this branch.
What I did not exercise