Skip to content

Conversation

@santhoshvai
Copy link
Member

@santhoshvai santhoshvai commented Nov 17, 2025

💡 Overview

const changes = call.state.updateParticipantTracks(trackType, {
          [participantSessionId]: { dimension },
});

changes object show that changes are reflected in the call state

call.dynascaleManager.applyTrackSubscriptions();

but dynascale manager, does not read the participant update.. it still shows that participant dimensions are undefined

📝 Implementation notes

The root cause is shareReplay({ refCount: true }) on remoteParticipants$. When there are no active subscribers:

  • The observable disconnects from the source
  • When getCurrentValue re-subscribes, there might be micro-task timing issues in React Native
  • The getter reads before the observable pipe completes
    The proper fix is to make the trackSubscriptions getter read directly from the BehaviorSubject, bypassing the shareReplay:

🎫 Ticket: https://linear.app/stream/issue/XYZ-123

📑 Docs: https://github.com/GetStream/docs-content/pull/

@santhoshvai santhoshvai merged commit d91e008 into main Nov 17, 2025
18 checks passed
@santhoshvai santhoshvai deleted the fix-stale-dynascale branch November 17, 2025 15:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a timing issue in the DynascaleManager where participant dimension updates were not being picked up reliably due to stale data from RxJS shareReplay with refCount: true.

Key Changes:

  • Introduced getParticipantsSnapshot() method in CallState to bypass the observable pipeline and read directly from the BehaviorSubject
  • Updated DynascaleManager to use the snapshot method, avoiding stale data when there are no active subscribers
  • Fixed TrackSubscriber to properly unsubscribe from tracks when participants stop publishing

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/client/src/store/CallState.ts Added getParticipantsSnapshot() method to provide synchronous access to participants data, bypassing potential timing issues with shareReplay
packages/client/src/helpers/DynascaleManager.ts Updated trackSubscriptions getter to use getParticipantsSnapshot() and optimized by caching videoTrackSubscriptionOverrides lookup, includes explicit local participant filtering
packages/react-native-sdk/src/components/Participant/ParticipantView/VideoRenderer/TrackSubscriber.tsx Added !isPublishing condition to unsubscribe when participant stops publishing, removed redundant distinctUntilChanged() operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 86 to 87
// isPublishing is not used here, but we need to keep it for the subscription
// to send the dimensions again when the participant starts publishing the track again
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "isPublishing is not used here" but it is now being used in the condition on line 89 (!isVisible || !isPublishing). Please update the comment to reflect the actual usage, for example: "isPublishing is used to unsubscribe when the participant stops publishing, and to re-subscribe when they start publishing again".

Suggested change
// isPublishing is not used here, but we need to keep it for the subscription
// to send the dimensions again when the participant starts publishing the track again
// isPublishing is used to unsubscribe when the participant stops publishing,
// and to re-subscribe when they start publishing again, ensuring dimensions are sent appropriately.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants