Repository navigation
fix(mux-input): mount the Mux player only after clicking the poster - #2074
Conversation
🦋 Changeset detectedLatest commit: 9289eb6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
✅ E2E Tests🟢 46 passed • view full report • view run Studio: https://plugins-e2e-test-studio-ae7qwgn0i.sanity.dev Datasets: |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Deferred state persists across asset replacement, causing replacement videos to mount and autoplay without a new click.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Defers Mux player mounting in video inputs until the poster is activated, reducing Safari layout stalls while preserving eager playback elsewhere.
Changes:
- Adds opt-in deferred player rendering with an accessible poster button.
- Shares the existing play-button component across views.
- Adds Vitest coverage and required test dependencies.
| File | Description |
|---|---|
.changeset/mux-input-defer-player.md |
Records the Safari performance fix. |
pnpm-lock.yaml |
Locks new test dependencies. |
plugins/sanity-plugin-mux-input/package.json |
Adds testing dependencies. |
src/components/Player.tsx |
Enables deferred playback in inputs. |
src/components/PlayButton.tsx |
Extracts the shared play button. |
src/components/VideoInBrowser.tsx |
Uses the shared play button. |
src/components/VideoPlayer.tsx |
Implements poster-first deferred mounting. |
src/components/VideoPlayer.test.tsx |
Tests eager and deferred behavior. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation addresses the reported performance issue while preserving existing behavior in other player contexts and adding focused regression coverage.
Review effort: Balanced
Findings: None
Resolved since last review (1)
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
|
Changes look great; will test it out! Haven't set up my workspace since the repo migration so it may take me a minute. Just in case, did you test this with audio only assets and/or signed assets? |
Thank you @spuppo-mux let us know if you have any difficulties setting up the new workspace, in my experience it should be much simpler now. No, haven't tested with audio only assets or signed assets, good catch, will test it next week. |
|
Hi, btw I could test this with no issues. Audio-only, signed and drm cases seemed to work well to me! |
Every visible mux.video input mounted a full <mux-player> eagerly. Its media-chrome buttons force several full-document layouts while upgrading, which freezes Safari for seconds on forms with multiple video fields. The input now shows the poster with a play button and mounts the player (with autoplay) on click. The asset browser and details dialog are unchanged. Fixes #2068 Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
950f122 to
9289eb6
Compare
|
Thank you @spuppo-mux had to rebase due to some conflicts, would you mind approving again? |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## sanity-plugin-mux-input@5.2.1 ### Patch Changes - [#2074](#2074) [`1494069`](1494069) Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Show the video poster with a play button in the input and only mount the Mux player when the editor clicks it, so opening forms with several video fields no longer freezes Safari <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Version and changelog-only release; the underlying change is a Studio UI performance fix with no API or security surface in this PR. > > **Overview** > **Release-only PR:** bumps `sanity-plugin-mux-input` from **5.2.0** to **5.2.1**, adds the **5.2.1** changelog entry, and removes the consumed changeset (`.changeset/mux-input-defer-player.md`). No application source changes in this diff. > > The published patch documents [#2074](#2074): the Studio video input shows a **poster + play control** and **defers mounting `MuxPlayer`** until the editor clicks, avoiding Safari freezes when forms load many Mux fields. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a9d8bee. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: squiggler-app[bot] <265501495+squiggler-app[bot]@users.noreply.github.com>

Summary
Every visible
mux.videoinput rendered a full<MuxPlayer>as soon as the field mounted. While the player'smedia-chromecontrols upgrade, they force several full-document layouts, and the issue reports this freezes Safari for seconds on forms with multiple video fields.With this change, the form input shows the poster as a play button.
<MuxPlayer>mounts (withautoPlay) only after a click.VideoPlayergets an opt-indeferPlayerprop. Only the input'sPlayersets it. The asset browser (VideoInBrowser, which already defers with its own play button) and the video details dialog behave as before.0when no player is mounted, which is the dialog's existing default.PlayButtonmoves out ofVideoInBrowserinto its own module so both places share it. In the input, the play icon is always visible.Investigation
media-chrome4.19.2):media-chrome-button'sattributeChangedCallbackcallsMediaTooltip.updateXOffseton every observed attribute change. That function runscheckVisibility(),getComputedStyle().getPropertyValue()andgetBoundingClientRect()on both the tooltip and its container, which matches the reporter's Safari sample. The root cause is inmedia-chrome; this PR only stops the plugin from triggering it for videos the editor never plays.Testing
src/components/VideoPlayer.test.tsx(jsdom, with@mux/mux-player-react/lazymocked):deferPlayer, no player is in the DOM, the poster<img>uses the Mux thumbnail URL, and overlay children render once. After a click, the player mounts withautoPlay.pnpm lintand thesanity-plugin-mux-inputbuild and tests pass.pnpm knipfails only on the rootlefthookdevDependency, which also fails on a clean tree and is unrelated to this change.muxTrailerdocument:document.querySelectorAll('mux-player').lengthis0.1), which autoplays.Poster before click
Player after click
mux-deferred-player.mp4
Lockfile
The test adds
@testing-library/react,@types/react-domandjsdomas dev dependencies, on the same catalog versions other plugins already lock. Only the three importer entries were added topnpm-lock.yaml, andpnpm install --frozen-lockfilepasses. A plainpnpm installwould also re-resolve thenext-tagged Studio overrides (sanity6.17.0-next.112 → 6.18.0-next.21), so that bump is deliberately not included.Fixes #2068
To show artifacts inline, enable in settings.