fix: Resolve infinite loading state in Safari with MSE and on-demand stream type#1257
Conversation
…ari issues using MSE & on-demand
|
@Pintorado is attempting to deploy a commit to the Mux Team on Vercel. A member of the Team first needs to authorize it. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
luwes
left a comment
There was a problem hiding this comment.
Needs changes to more clearly show the root cause and use less code to workaround the iOS bug.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
packages/mux-player/src/base.ts
Outdated
| // 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; | ||
|
|
There was a problem hiding this comment.
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...
| let storyboardTrack; | ||
| await waitUntil(() => { | ||
| storyboardTrack = muxVideo.shadowRoot.querySelector("track[label='thumbnails']"); | ||
| return storyboardTrack && !!storyboardTrack.getAttribute('src'); | ||
| }, 'storyboard <track> src never set'); |
There was a problem hiding this comment.
@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.
packages/mux-player/src/base.ts
Outdated
| get hasLoaded() { | ||
| return this.#hasLoaded; | ||
| } | ||
|
|
There was a problem hiding this comment.
| get hasLoaded() { | |
| return this.#hasLoaded; | |
| } |
packages/mux-player/src/base.ts
Outdated
| #isInit = false; | ||
| #tokens: Tokens = {}; | ||
| #userInactive = true; | ||
| #hasLoaded = false; |
There was a problem hiding this comment.
| #hasLoaded = false; |
packages/mux-player/src/base.ts
Outdated
| // 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; |
There was a problem hiding this comment.
| this.#hasLoaded = true; |
packages/mux-player/src/base.ts
Outdated
| hasSrc: !!el.playbackId || !!el.src || !!el.currentSrc, | ||
| poster: el.poster, | ||
| storyboard: el.storyboard, | ||
| storyboard: el.hasLoaded && el.storyboard, |
There was a problem hiding this comment.
| storyboard: el.hasLoaded && el.storyboard, | |
| storyboard: el.media.src && el.storyboard, |
There was a problem hiding this comment.
The fix didn't work with el.media.src but it does work with el.media?.currentSrc
| hasSrc: !!el.playbackId || !!el.src || !!el.currentSrc, | ||
| poster: el.poster, | ||
| storyboard: el.storyboard, | ||
| storyboard: el.media?.currentSrc && el.storyboard, |
🤖 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>
Closes https://github.com/muxinc/devextravaganza/issues/190 and https://github.com/muxinc/devextravaganza/issues/130
Problem
When using
prefer-playback="mse"withstream-type="on-demand"onmux-player, Safari experienced an infinite loading state.Changes
#hasLoadedflag that is set totruewhenloadstartevent firesTesting
When using
mux-playerwithprefer-playback="mse"andstream-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:
React: