Skip to content

Conversation

@Pintorado
Copy link
Contributor

@Pintorado Pintorado commented Dec 15, 2025

Closes https://github.com/muxinc/devextravaganza/issues/190 and https://github.com/muxinc/devextravaganza/issues/130

Problem

When using prefer-playback="mse" with stream-type="on-demand" on mux-player, Safari experienced an infinite loading state.

Changes

  • Added #hasLoaded flag that is set to true when loadstart event fires
  • Only if the element has loaded return the storyboard URL, otherwise return undefined

Testing

When using mux-player with prefer-playback="mse" and stream-type="on-demand" in Safari, the video now loads and plays correctly without getting stuck. Try refreshing the page a couple of times when testing this to make sure that there are no cache problems.

Code snippets to test:

HTML:

<mux-player
  stream-type="on-demand"
  prefer-playback="mse"
  playback-id="ihZa7qP1zY8oyLSQW9TS602VgwQvNdyIvlk9LInEGU2s"
/>

React:

<MuxPlayer
  streamType="on-demand"
  preferPlayback="mse"
  playbackId="ihZa7qP1zY8oyLSQW9TS602VgwQvNdyIvlk9LInEGU2s"
/>

@Pintorado Pintorado requested a review from a team as a code owner December 15, 2025 20:26
@vercel
Copy link

vercel bot commented Dec 15, 2025

@Pintorado is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

@snyk-io
Copy link

snyk-io bot commented Dec 15, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Contributor

@luwes luwes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changes to more clearly show the root cause and use less code to workaround the iOS bug.

@Pintorado Pintorado requested a review from luwes December 17, 2025 19:29
@vercel
Copy link

vercel bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
elements-demo-astro Ready Ready Preview, Comment Dec 18, 2025 4:42pm
elements-demo-nextjs Ready Ready Preview, Comment Dec 18, 2025 4:42pm
elements-demo-svelte-kit Ready Ready Preview, Comment Dec 18, 2025 4:42pm
elements-demo-vanilla Ready Ready Preview, Comment Dec 18, 2025 4:42pm
elements-demo-vue Ready Ready Preview, Comment Dec 18, 2025 4:42pm

Comment on lines 1005 to 1008
// NOTE: We don't want to return a storyboard until the media has loaded,
// otherwise iOS Safari would stall playback.
if (!this.#hasLoaded) return undefined;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this and revert the test changes?
We still want the storyboard getter to return a defined value but what we pass to the template in getProps should be undefined until hasLoaded...

Comment on lines +559 to +563
let storyboardTrack;
await waitUntil(() => {
storyboardTrack = muxVideo.shadowRoot.querySelector("track[label='thumbnails']");
return storyboardTrack && !!storyboardTrack.getAttribute('src');
}, 'storyboard <track> src never set');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luwes this test was failing because storyboardTrack was null at this point. We now wait until the track is rendered before accessing its src attribute.

@Pintorado Pintorado requested a review from luwes December 18, 2025 18:30
Comment on lines 830 to 833
get hasLoaded() {
return this.#hasLoaded;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
get hasLoaded() {
return this.#hasLoaded;
}

#isInit = false;
#tokens: Tokens = {};
#userInactive = true;
#hasLoaded = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#hasLoaded = false;

// NOTE: Make sure we re-render when <source> tags are appended so hasSrc is updated.
this.media?.addEventListener('loadstart', () => this.#render());
this.media?.addEventListener('loadstart', () => {
this.#hasLoaded = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.#hasLoaded = true;

hasSrc: !!el.playbackId || !!el.src || !!el.currentSrc,
poster: el.poster,
storyboard: el.storyboard,
storyboard: el.hasLoaded && el.storyboard,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
storyboard: el.hasLoaded && el.storyboard,
storyboard: el.media.src && el.storyboard,

Copy link
Contributor Author

@Pintorado Pintorado Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix didn't work with el.media.src but it does work with el.media?.currentSrc

@Pintorado Pintorado requested a review from luwes December 18, 2025 19:24
hasSrc: !!el.playbackId || !!el.src || !!el.currentSrc,
poster: el.poster,
storyboard: el.storyboard,
storyboard: el.media?.currentSrc && el.storyboard,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@luwes luwes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@luwes luwes merged commit dadca90 into muxinc:main Dec 18, 2025
10 of 15 checks passed
@github-actions github-actions bot mentioned this pull request Dec 17, 2025
luwes pushed a commit that referenced this pull request Dec 18, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>@mux/playback-core: 0.32.2</summary>

##
[0.32.2](https://github.com/muxinc/elements/compare/@mux/playback-core@0.32.1...@mux/playback-core@0.32.2)
(2025-12-18)


### Bug Fixes

* avoid prerender errors caused by date access
([#1226](#1226))
([d044183](d044183))
</details>

<details><summary>@mux/mux-player: 3.10.2</summary>

##
[3.10.2](https://github.com/muxinc/elements/compare/@mux/mux-player@3.10.1...@mux/mux-player@3.10.2)
(2025-12-18)


### Bug Fixes

* bump the prod-dependencies group across 2 directories with 2 updates
([#1259](#1259))
([ee4d961](ee4d961))
* Resolve infinite loading state in Safari with MSE and on-demand stream
type ([#1257](#1257))
([dadca90](dadca90))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/mux-video bumped from 0.29.1 to 0.29.2
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

<details><summary>@mux/mux-player-astro: 3.10.2</summary>

##
[3.10.2](https://github.com/muxinc/elements/compare/@mux/mux-player-astro@3.10.1...@mux/mux-player-astro@3.10.2)
(2025-12-18)


### Miscellaneous Chores

* **@mux/mux-player-astro:** Synchronize player versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/mux-player bumped from 3.10.1 to 3.10.2
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

<details><summary>@mux/mux-player-react: 3.10.2</summary>

##
[3.10.2](https://github.com/muxinc/elements/compare/@mux/mux-player-react@3.10.1...@mux/mux-player-react@3.10.2)
(2025-12-18)


### Miscellaneous Chores

* **@mux/mux-player-react:** Synchronize player versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/mux-player bumped from 3.10.1 to 3.10.2
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

<details><summary>@mux/mux-audio: 0.15.19</summary>

##
[0.15.19](https://github.com/muxinc/elements/compare/@mux/mux-audio@0.15.18...@mux/mux-audio@0.15.19)
(2025-12-18)


### Bug Fixes

* Resolve infinite loading state in Safari with MSE and on-demand stream
type ([#1257](#1257))
([dadca90](dadca90))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

<details><summary>@mux/mux-audio-react: 0.15.19</summary>

##
[0.15.19](https://github.com/muxinc/elements/compare/@mux/mux-audio-react@0.15.18...@mux/mux-audio-react@0.15.19)
(2025-12-18)


### Miscellaneous Chores

* **@mux/mux-audio-react:** Synchronize audio versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

<details><summary>@mux/mux-video: 0.29.2</summary>

##
[0.29.2](https://github.com/muxinc/elements/compare/@mux/mux-video@0.29.1...@mux/mux-video@0.29.2)
(2025-12-18)


### Bug Fixes

* Resolve infinite loading state in Safari with MSE and on-demand stream
type ([#1257](#1257))
([dadca90](dadca90))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

<details><summary>@mux/mux-video-react: 0.29.2</summary>

##
[0.29.2](https://github.com/muxinc/elements/compare/@mux/mux-video-react@0.29.1...@mux/mux-video-react@0.29.2)
(2025-12-18)


### Miscellaneous Chores

* **@mux/mux-video-react:** Synchronize video versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @mux/playback-core bumped from 0.32.1 to 0.32.2
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants