Skip to content

Conversation

@langleyd
Copy link
Contributor

@langleyd langleyd commented Nov 5, 2025

Fixes element-hq/element-web#31123

element web PR is here for testing the netlify

A couple of cases tested manually. The main case (case 1) is easily reproducible on macOS(all browsers I believe) and was reported for Windows. There was one report it couldn't be reproduced on Linux.

Case 1: Switing camera broken(With no fix applied this is easily reproducible)

  1. Start a call with Alice
  2. Switch device from camera 1 to camera 2
    Observed: Local feed stays on camera 1 and remote feed from camera 1 received by Alice
    Expected: Local feed changes successfully to camera and remote feed from camera 2 received by Alice

Case 2: (When only using "exact" this is reproducible, hence the need for the try/catch)

  1. Start a call with Alice
  2. Switch device from camera 1 to camera 2
  3. End the call
  4. Disconnect Camera 2
  5. Start a call
    Observed: An error occurs that media cannot be connected (as we have selected "exact" and the last device saved in settings was the disconnected camera)
    Expected: Camera 2 falls back to Camera 1 and this is used for local/remote feeds.

@langleyd langleyd changed the title Specify exact for deviceId Fix media switching during legacy calls Nov 5, 2025
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

See my comment

try {
// Not specifying exact for deviceId means switching devices does not always work,
// try with exact and fallback to ideal if it fails
constraints = this.getUserMediaContraints(shouldRequestAudio, shouldRequestVideo, true);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand, as per doc
ideal: A string or an array of strings, specifying ideal values for the property. If possible, one of the listed values will be used, but if it's not possible, the user agent will use the closest possible match.

Why doing exact then ideal would work differently than just ideal? what am I missing?

Copy link
Contributor Author

@langleyd langleyd Nov 7, 2025

Choose a reason for hiding this comment

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

on macOS, Using "ideal" at the moment is not working when switching camera and providing a specific deviceId. I don't know why maybe a system bug.

By the sounds of the comments further down in the code, this api is not very consistent cross browser either.

Copy link
Contributor

@toger5 toger5 left a comment

Choose a reason for hiding this comment

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

What is needed to resolve this question:

XXX: Is this still true?

Copy link
Contributor

@toger5 toger5 left a comment

Choose a reason for hiding this comment

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

Otherwise this looks good.
Approving because for me the comment on XXX: Is this still true? is not blocking.

@langleyd
Copy link
Contributor Author

@toger5 That is old code, I just changed the formatting of it to pass the sonar cloud checks.

By the sounds of the comment, the author was not sure if it was still an issue. We'd probably need to go back and have a look at what the original issue was for that. I don't think it would affect the solution for this problem, but I can check after the fact.

@langleyd langleyd added this pull request to the merge queue Nov 10, 2025
@toger5
Copy link
Contributor

toger5 commented Nov 10, 2025

By the sounds of the comment, the author was not sure if it was still an issue. We'd probably need to go back and have a look at what the original issue was for that. I don't think it would affect the solution for this problem, but I can check after the fact.

Thanks for this info. I missed that it is old code.
Since this is legacy call code I would not invest too much time and just leave the XXX comment as is.

Merged via the queue into develop with commit 1dee1ba Nov 10, 2025
48 checks passed
@langleyd langleyd deleted the langleyd/fix-media-switching branch November 10, 2025 09:54
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.

During 1:1 calls (legacy), changing the camera does not seem to work

4 participants