-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix crash when expanding video player #37772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -60,6 +60,7 @@ function BaseVideoPlayer({ | |||||||
const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); | ||||||||
const isCurrentlyURLSet = currentlyPlayingURL === url; | ||||||||
const isUploading = _.some(CONST.ATTACHMENT_LOCAL_URL_PREFIX, (prefix) => url.startsWith(prefix)); | ||||||||
const shouldUseSharedVideoElementRef = useRef(shouldUseSharedVideoElement); | ||||||||
|
||||||||
const togglePlayCurrentVideo = useCallback(() => { | ||||||||
videoResumeTryNumber.current = 0; | ||||||||
|
@@ -145,8 +146,27 @@ function BaseVideoPlayer({ | |||||||
}, [currentVideoPlayerRef, handleFullscreenUpdate, handlePlaybackStatusUpdate]); | ||||||||
|
||||||||
useEffect(() => { | ||||||||
if (!isUploading) { | ||||||||
return; | ||||||||
} | ||||||||
// If we are uploading a new video, we want to immediately set the video player ref. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example, if we have video A and B in carousel, and we open video B, it could be possible the video A video player is set as the ref when both component mounted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
currentVideoPlayerRef.current = videoPlayerRef.current; | ||||||||
}, [url, currentVideoPlayerRef]); | ||||||||
}, [url, currentVideoPlayerRef, isUploading]); | ||||||||
|
||||||||
useEffect(() => { | ||||||||
shouldUseSharedVideoElementRef.current = shouldUseSharedVideoElement; | ||||||||
}, [shouldUseSharedVideoElement]); | ||||||||
|
||||||||
useEffect( | ||||||||
() => () => { | ||||||||
if (shouldUseSharedVideoElementRef.current) { | ||||||||
return; | ||||||||
} | ||||||||
// If it's not a shared video player, clear the video player ref. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
currentVideoPlayerRef.current = null; | ||||||||
}, | ||||||||
[currentVideoPlayerRef], | ||||||||
); | ||||||||
|
||||||||
// update shared video elements | ||||||||
useEffect(() => { | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that this removal doesn't cause regression of #37142.