Skip to content

Device switching in Settings panel broken: action methods ignore dropdown value + camera uses non-mandatory WebRTC constraint #348

@emavitta

Description

@emavitta

Device switching (camera, microphone, speaker) in the Settings panel does not work. Selecting a different device from the dropdown has no effect, the meeting continues using the original device.

Root cause is a mismatch between how @webex/components passes the selected value and how @webex/sdk-component-adapter receives it, plus a weak WebRTC constraint for video.

Bug 1: Action methods don't receive the selected device ID

useMeetingControl in @webex/components calls control actions with two arguments:

  // @webex/components — useMeetingControl hook
  control.action({ meetingID, meetingPasswordOrPin, participantName }, value)

But the switch control actions in @webex/sdk-component-adapter destructure the device ID from the first argument, where it
doesn't exist:

  // SwitchCameraControl
  async action({ meetingID, cameraId }) { ... }

  // SwitchMicrophoneControl
  async action({ meetingID, microphoneId }) { ... }

  // SwitchSpeakerControl
  async action({ meetingID, speakerId }) { ... }

cameraId, microphoneId, and speakerId are always undefined because they are not properties of the first argument. The actual
value is passed as the second argument and is ignored.

Fix:

  async action({ meetingID }, cameraId) { ... }
  async action({ meetingID }, microphoneId) { ... }
  async action({ meetingID }, speakerId) { ... }

Bug 2: switchCamera() uses a non-mandatory WebRTC constraint

After fixing Bug 1, microphone and speaker switching work correctly, but camera switching still fails. switchCamera() passes
deviceId as a plain value:

  video: { deviceId: cameraID }

Per the https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#using_the_new_api:

Plain values are inherently ideal [...] the keywords min, max, and exact are inherently mandatory — whereas plain values and
a keyword called ideal are not.

A plain deviceId is treated as a preference that the browser can ignore. In practice, it returns the currently active camera
instead of switching to the requested one. This was confirmed by logging: the deviceId returned by getStream() did not
match the one requested.

The fix is to use an exact constraint:

  video: { deviceId: { exact: cameraID } }

Reference: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/deviceId

Note: switchMicrophone() works without exact because browsers handle audio device constraints more permissively than video.

Affected versions

  • @webex/sdk-component-adapter: 1.113.0
  • @webex/components: 1.277.1
  • webex: 2.60.4

Steps to reproduce

  1. Join a meeting using the WebexMeeting component with the settings control enabled on a machine with multiple cameras
  2. Open Settings > Video tab
  3. Select a different camera from the dropdown
  4. The preview does not change — the original camera stream is returned
  5. Same issue affects Audio tab for microphone and speaker (Bug 1 only)

Workaround

We applied a pnpm patch to @webex/sdk-component-adapter that fixes both issues. Happy to open a PR if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions