Skip to content

fix(audio): broken mute toggle when using LiveKit#24229

Merged
prlanzarin merged 1 commit intobigbluebutton:v3.0.x-releasefrom
prlanzarin:u30/fix/livekit-mu-loop
Nov 13, 2025
Merged

fix(audio): broken mute toggle when using LiveKit#24229
prlanzarin merged 1 commit intobigbluebutton:v3.0.x-releasefrom
prlanzarin:u30/fix/livekit-mu-loop

Conversation

@prlanzarin
Copy link
Member

What does this PR do?

  • fix(audio): broken mute toggle when using LiveKit
    • A recent change altered AudioManager's audio state observer to call
      mute/unmute state on every audio state update - regardless of whether
      the local mute state actually changes. Since the mute/unmute actions of
      the LiveKit audio bridge are not fully idempotent yet, this may cause
      audio tracks to be published and unpublished in sequence, mistakengly,
      due to trailing (un)mute calls sent in a short timespan.
      This breaks the mute toggle when using LiveKit - i.e.: unresponsive or
      flipping mute states incorrectly.
    • Guarantee that AudioManager's audio state observer only triggers
      mute/unmute when its muted state actually changes. This fixes the
      "catalyst" for the above problem.
    • The LK audio bridge should still have an idempotent mute/unmute API
      (setSenderTrackEnabled) - this issue wouldn't have happened if that was
      the case. That will be addressed in subsequent commits.

Closes Issue(s)

None

A recent change altered AudioManager's audio state observer to call
mute/unmute state on every audio state update - regardless of whether
the local mute state actually changes. Since the mute/unmute actions of
the LiveKit audio bridge are not fully idempotent yet, this may cause
audio tracks to be published and unpublished in sequence, mistakengly,
due to trailing (un)mute calls sent in a short timespan.
This breaks the mute toggle when using LiveKit - i.e.: unresponsive or
flipping mute states incorrectly.

Guarantee that AudioManager's audio state observer only triggers
mute/unmute when its muted state actually changes. This fixes the
"catalyst" for the above problem.

The LK audio bridge should still have an idempotent mute/unmute API
(setSenderTrackEnabled) - this issue wouldn't have happened if that was
the case. That will be addressed in subsequent commits.
@prlanzarin prlanzarin added this to the Release 3.0 milestone Nov 13, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

The onVoiceUserChanges method in the audio manager service has been refactored to defer mute state mutations. Previously, mute state changes were applied immediately and inline throughout the function. The refactored code now accumulates the intended mute state in a local variable (newMuteState) before applying the state change and corresponding mute/unmute operation once, consolidating the decision logic into a single update path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Verify the logic for computing newMuteState correctly captures all previous inline state update paths
  • Confirm the deferred mutation approach does not inadvertently alter behavior or timing of mute/unmute operations
  • Check that all conditional branches leading to state changes now flow through the consolidated update path

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(audio): broken mute toggle when using LiveKit' directly and accurately summarizes the main fix in the changeset, which defers mute state changes to prevent repeated mute/unmute calls that break the toggle.
Description check ✅ Passed The description is directly related to the changeset, explaining the root cause of the bug, the specific fix applied (deferring mute state changes), and the broader context of the LiveKit audio bridge idempotency issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fedfbad and b3e0427.

📒 Files selected for processing (1)
  • bigbluebutton-html5/imports/ui/services/audio-manager/index.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-package (bbb-html5)
🔇 Additional comments (1)
bigbluebutton-html5/imports/ui/services/audio-manager/index.js (1)

719-738: Excellent fix for the mute toggle issue!

The refactored logic correctly addresses the root cause by ensuring mute()/unmute() are only called when the muted state actually changes. The key improvements are:

  1. Deferred state mutation: Accumulating the intended state in newMuteState before applying changes prevents multiple rapid updates
  2. Idempotency at caller level: The condition on line 730 (newMuteState !== this.isMuted) ensures no action is taken when the state hasn't changed, eliminating redundant calls to the bridge
  3. Single update path: Consolidating the state mutation and mute/unmute calls (lines 731-737) prevents the race condition where multiple calls could interfere with each other

This defensive change protects against the LiveKit bridge's non-idempotent behavior and should resolve the unresponsive mute toggle issue.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

@github-actions
Copy link

Automated tests Summary

All the CI tests have passed!

@prlanzarin prlanzarin merged commit dbee51a into bigbluebutton:v3.0.x-release Nov 13, 2025
32 checks passed
@prlanzarin prlanzarin deleted the u30/fix/livekit-mu-loop branch November 13, 2025 12:38
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