Skip to content

Guard remote video refs from unnecessary playback resets#18

Merged
bm12 merged 1 commit intomasterfrom
codex/fix-remote-video-ref-assignment-and-playback
Sep 22, 2025
Merged

Guard remote video refs from unnecessary playback resets#18
bm12 merged 1 commit intomasterfrom
codex/fix-remote-video-ref-assignment-and-playback

Conversation

@bm12
Copy link
Copy Markdown
Owner

@bm12 bm12 commented Sep 22, 2025

Summary

  • add a shared helper to attach streams only when they change
  • ensure local and remote video elements only call play when needed to avoid playback resets

Testing

  • npm --prefix frontend run lint

https://chatgpt.com/codex/tasks/task_e_68d1bde2aba4832ab047dabf3b066457

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +21 to 36
const attachStreamToElement = useCallback(
(element: HTMLVideoElement | null, stream: MediaStream | null | undefined) => {
if (!element) {
return;
}

const stream = localStreamRef.current;
if (stream && element.srcObject !== stream) {
const currentStream = element.srcObject as MediaStream | null;
let streamAttached = false;

if (stream && currentStream !== stream) {
element.srcObject = stream;
streamAttached = true;
}

element.muted = true;
if (element.srcObject) {
if ((streamAttached || element.paused) && element.srcObject) {
element.play().catch(() => undefined);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P1] Clear video element when stream disappears

The new attachStreamToElement helper only sets element.srcObject when the incoming stream is truthy. When a remote participant’s stream becomes null or undefined, the function skips assignment and never removes the previous stream, so the element keeps rendering and playing the stale video/audio. The prior implementation assigned element.srcObject = participant.stream regardless of value, which detached the stream when absent. This regression leaves orphaned media playing whenever a participant leaves or a camera stops.

Useful? React with 👍 / 👎.

@bm12 bm12 merged commit 66c8da8 into master Sep 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant