Skip to content

fix(meeting): pass device IDs from components and use exact media constraints#350

Open
akulakum wants to merge 1 commit into
masterfrom
MICROPHONE_DEVICE_FIX
Open

fix(meeting): pass device IDs from components and use exact media constraints#350
akulakum wants to merge 1 commit into
masterfrom
MICROPHONE_DEVICE_FIX

Conversation

@akulakum

@akulakum akulakum commented Jul 17, 2026

Copy link
Copy Markdown

COMPLETES #https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-824300

Vidcast demo link: https://app.vidcast.io/share/f9ab47df-fd36-4380-8879-d6f23054a3b3

This pull request addresses

Meetings Widget Settings → Audio/Video device selection stopped applying the chosen microphone, speaker, or camera after @webex/sdk-component-adapter@1.113.0 shipped with PR #346.

Customer environment: @webex/widgets ^1.28.2, @webex/components 1.277.1, @webex/sdk-component-adapter 1.113.0, Chrome on macOS.

Root cause: PR #346 refactored meeting control action() methods to read device IDs from a context object (e.g. { meetingID, microphoneId }). However, @webex/components@1.277.1 still invokes device controls as:

control.action({ meetingID }, deviceId)

The device ID is passed as the second argument, not inside the context object. The adapter ignored the second argument, so microphoneId / speakerId / cameraId was undefined and switchMicrophone() never received the selected hardware ID.

Two additional issues made switching unreliable even when partially fixed:

  1. Chrome media constraints: getUserMedia({ deviceId: id }) (non-exact) silently falls back to the built-in device when a preview stream is already active. { exact: deviceId } is required for reliable switching.
  2. RxJS anti-pattern: getStream() used new Observable(async (subscriber) => …), causing UnsubscriptionError when stopping preview streams during rapid device changes.

by making the following changes

1. Device switch controls — accept 2nd argument from @webex/components

Files: SwitchMicrophoneControl.js, SwitchSpeakerControl.js, SwitchCameraControl.js

async action(context, deviceId) {
  const { meetingID } = context;
  const microphoneId = context.microphoneId != null ? context.microphoneId : deviceId;
  await this.adapter.switchMicrophone(meetingID, microphoneId);
}

Backward-compatible: supports PR #346 context-object shape and the two-argument call pattern used by @webex/components today.

2. Exact media constraints for Chrome

File: MeetingsSDKAdapter.jsswitchMicrophone(), switchCamera()

deviceId: microphoneID === 'default' ? 'default' : { exact: microphoneID }

3. Fix getStream() Observable teardown

File: MeetingsSDKAdapter.jsgetStream()

  • Replaced async Observable subscriber with sync subscriber + async IIFE
  • Added clearTimeout(askingTimeout) in teardown to prevent errors during device switch

4. Unit tests

  • Tests for action({ meetingID }, deviceId) contract on all three switch controls
  • Tests asserting { exact: deviceId } and plain 'default' constraint behavior in MeetingsSDKAdapter.test.js

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
    < ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document

…straints

Accept device ID from the second action() argument to match @webex/components
after PR #346, use exact getUserMedia constraints for reliable device switching,
and fix getStream() Observable teardown during preview device changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@akulakum akulakum changed the title fix(meeting): pass device IDs from components and use exact media con… fix(meeting): pass device IDs from components and use exact media constraints Jul 17, 2026
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.

1 participant