Skip to content

Commit b30ca34

Browse files
authored
fix: no video if camera is disabled on init and then enabled (#1981)
### 💡 Overview The videorenderer latest refactor introduced a bug. If remote video was disabled initially and then joined. The video was not received. We sent the dimensions to the SFU only after the published tracks bool came true. But SFU doesnt set the video stream after that. It expects the dimensions to be known before this. The SFU contract for sending updateSubscriptions is * send dimensions whenever it changes if view is visible * send undefined dimensions if view is invisible * send dimensions again whenever subscriber or publisher reconnects This change ensures that the contract is satisfied now. It fixes the issue. Ticket: https://linear.app/stream/issue/RN-298/
1 parent 112e380 commit b30ca34

File tree

1 file changed

+9
-10
lines changed
  • packages/react-native-sdk/src/components/Participant/ParticipantView/VideoRenderer

1 file changed

+9
-10
lines changed

packages/react-native-sdk/src/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ const TrackSubscriber = forwardRef<TrackSubscriberHandle, TrackSubscriberProps>(
8383
dimensions$,
8484
isPublishingTrack$,
8585
isJoinedState$,
86+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8687
]).subscribe(([dimension, isPublishing, isJoined]) => {
87-
if (isJoined && isPublishing && !isVisible) {
88-
// the participant is publishing and we are not visible, so we unsubscribe from the video track
89-
requestTrackWithDimensions(DebounceType.FAST, undefined);
90-
} else if (isJoined && isPublishing && isVisible && dimension) {
91-
// the participant is publishing and we are visible and have valid dimensions, so we subscribe to the video track
92-
requestTrackWithDimensions(DebounceType.IMMEDIATE, dimension);
93-
} else if (isJoined && !isPublishing) {
94-
// the participant stopped publishing a track, so we unsubscribe from the video track
95-
requestTrackWithDimensions(DebounceType.FAST, undefined);
88+
// isPublishing is not used here, but we need to keep it for the subscription
89+
// to send the dimensions again when the participant starts publishing the track again
90+
if (isJoined) {
91+
if (!isVisible) {
92+
requestTrackWithDimensions(DebounceType.MEDIUM, undefined);
93+
} else if (dimension) {
94+
requestTrackWithDimensions(DebounceType.IMMEDIATE, dimension);
95+
}
9696
}
97-
// if isPublishing but no dimension yet, we wait for dimensions
9897
});
9998

10099
return () => {

0 commit comments

Comments
 (0)