fix: prevent Wistia crash when src changes while playing#2041
Open
Malaybhai11 wants to merge 1 commit into
Open
fix: prevent Wistia crash when src changes while playing#2041Malaybhai11 wants to merge 1 commit into
Malaybhai11 wants to merge 1 commit into
Conversation
Add a key prop based on src to the Player component to force a complete remount when the video source changes. This ensures the old Wistia player instance is properly destroyed before creating a new one, preventing crashes that occur when switching sources while playing. Fixes cookpete#2000
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.
Problem
After upgrading from v2.16.1 to v3.3.3, switching the video source while playing causes a Wistia player crash (fixes #2000).
Root Cause
In Player.tsx, the underlying player component (including wistia-video-element) is not re-mounted when src changes. The Wistia custom element keeps internal state (the old player instance) that becomes stale/inconsistent when a new source is set while the previous video is still playing, leading to a crash.
Fix
Added key={props.src} to the Player component in Player.tsx. This forces React to fully unmount and remount the player element whenever the src prop changes, ensuring the old Wistia player instance is properly destroyed before a new one is created.
This is a one-line change that applies to all player types, providing consistent and safe source-change behavior across Wistia, YouTube, Vimeo, and other providers.
Changes