fix: Mux - conditionally render MuxPlayer only when data is ready []#10710
Open
Renzo Delfino (R-Delfino95) wants to merge 1 commit intocontentful:masterfrom
Open
fix: Mux - conditionally render MuxPlayer only when data is ready []#10710Renzo Delfino (R-Delfino95) wants to merge 1 commit intocontentful:masterfrom
Renzo Delfino (R-Delfino95) wants to merge 1 commit intocontentful:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The MuxPlayer was always mounted in the DOM and hidden via
display: none, meaning the player component would initialize and attempt to load resources even when the required data wasn't available yet. This caused unnecessary resource usage and a visible flicker on signed playback assets where the player would briefly appear then hide again while tokens were loading.Approach
Part of the DRM feature (#10376) was to fix the re-render issue. We can now safely conditionally render MuxPlayer instead of keeping it mounted at all times.
Replaced CSS-based hiding with conditional rendering (
{showPlayer && <section>...</section>}) so MuxPlayer only mounts when all required data is present.Extracted the readiness logic into an
isPlayerReady()method that gates on:readyandplaybackIdexistsisUsingSigned(), tokens finished loading, andplaybackTokenis setAlso fixed the signed playback flicker by batching
isTokenLoading: falsetogether with the token values into a singlesetStatecall insetSignedPlayback. Previously,isTokenLoadingwas set tofalseinsidefetchSignedTokensbefore the tokens were written to state, causing an intermediate render where the player appeared ready but had no tokens yet.Testing steps
Breaking Changes
None.
Dependencies and/or References
None.
Deployment
No extra deployment steps required.