Skip to content

fix: (Mobile) Voice calls failing when accepted from the lock screen - #40422

Merged
dionisio-bot[bot] merged 1 commit into
developfrom
fix/mobile-voip-input-track-missing
Jun 16, 2026
Merged

fix: (Mobile) Voice calls failing when accepted from the lock screen#40422
dionisio-bot[bot] merged 1 commit into
developfrom
fix/mobile-voip-input-track-missing

Conversation

@pierre-lehnen-rc

@pierre-lehnen-rc pierre-lehnen-rc commented May 6, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Due to how the mobile app implements voice calls, when a call is accepted from the phone's lock screen it will be registered in the lib and then immediately accepted. This was causing a soft lock where the lib would never request the user's audio for that call, the negotiation would eventually timeout and the call would be dropped.

It happened because when a call is first initialized, it doesn't yet need to request the audio; only after it was accepted. The initialization would trigger the function that updates the state of audio track and it would determine the track is not yet needed, but this function has an await instruction that causes it to remain in the "updating" state until after the call is flagged as accepted. Once the update function completes, the call would be flagged as already updated and the state change would not be processed.

This PR changes the code so that the call will only enter the "updating" state when the track state is actually being changed (as opposed to every time it checks if it needs to change).

In addition I've also made sure that the call's internal state will be refreshed when the first negotiation starts and I also improved the timeout code to explicitly identify when a call fails due to missing the audio track.

Issue(s)

VMUX-113

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • Resolved soft lock issue in call negotiation that could stall when calls are accepted during initialization.
  • Improvements

    • Enhanced input track switching with improved concurrency handling and race condition protection.
    • Strengthened state management during call negotiation lifecycle for better stability.

@dionisio-bot

dionisio-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented May 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3539af6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 43 packages
Name Type
@rocket.chat/media-signaling Minor
@rocket.chat/meteor Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/ui-voip Patch
@rocket.chat/media-calls Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/ui-composer Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/cron Patch
@rocket.chat/http-router Patch
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR fixes a soft lock in call negotiation initialization by introducing a new waiting-for-track client state, a timeout-local-track hangup reason, and refactoring input track switching to be race-aware with dedicated guarding logic.

Changes

Call Negotiation Soft Lock Fix

Layer / File(s) Summary
Type Definitions
packages/media-signaling/src/definition/call/IClientMediaCall.ts, packages/media-signaling/src/definition/client.ts, packages/media-signaling/src/definition/services/negotiation.ts
New waiting-for-track client state and timeout-local-track hangup reason added to distinguish initialization delays from remote timeouts. New negotiation-started event added to lifecycle.
Negotiation Lifecycle
packages/media-signaling/src/lib/NegotiationManager.ts
isConfigured() method visibility changed to public. Negotiation completion now emits negotiation-started event to trigger state updates.
Call State Management
packages/media-signaling/src/lib/Call.ts
Early-path guard returns waiting-for-track when negotiation is not configured. New onNegotiationStarted() handler refreshes client state on negotiation start. Timeout mapping recognizes waiting-for-tracktimeout-local-track scenario. Calls updateClientState() when input track becomes available.
Input Track Switching
packages/media-signaling/src/lib/Session.ts
Replaced updatingInputTrack flag with switchingInputTrack. Made requestInputTrackUpdate() public. Introduced switchInputTrack(), shouldStartInputTrack(), and shouldSwitchInputTrack() with re-entrancy guards and concurrency-aware device tracking. Updated startInputTrack() to track concurrent calls and skip processing if requests race.
Documentation
.changeset/fluffy-poets-check.md
Changeset entry documents minor version bump for @rocket.chat/media-signaling with fix description.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main issue being fixed: voice calls failing on mobile when accepted from the lock screen, which directly matches the root cause addressed in the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • VMUX-113: Request failed with status code 401

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@codecov

codecov Bot commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.93%. Comparing base (b52c2a7) to head (3539af6).
⚠️ Report is 314 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40422      +/-   ##
===========================================
- Coverage    70.00%   69.93%   -0.08%     
===========================================
  Files         3298     3307       +9     
  Lines       120067   120581     +514     
  Branches     21538    21629      +91     
===========================================
+ Hits         84049    84323     +274     
- Misses       32741    32967     +226     
- Partials      3277     3291      +14     
Flag Coverage Δ
e2e 59.70% <ø> (+<0.01%) ⬆️
e2e-api 46.29% <ø> (-0.80%) ⬇️
unit 70.66% <ø> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pierre-lehnen-rc
pierre-lehnen-rc marked this pull request as ready for review May 6, 2026 17:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/media-signaling/src/definition/call/IClientMediaCall.ts (1)

25-34: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add 'timeout-local-track' to the clientMediaSignalHangupSchema enum.

The CallHangupReason type at IClientMediaCall.ts includes 'timeout-local-track', but the corresponding schema at packages/media-signaling/src/definition/signals/client/hangup.ts (line 33-51) does not include this variant in its enum. The inline contract at line 25 of IClientMediaCall.ts explicitly requires this synchronization. Without it, hangup signals carrying 'timeout-local-track' will be rejected by schema validation at runtime.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/media-signaling/src/definition/call/IClientMediaCall.ts` around
lines 25 - 34, CallHangupReason includes 'timeout-local-track' but the runtime
schema enum (clientMediaSignalHangupSchema) is missing that variant; update the
enum in clientMediaSignalHangupSchema (the enum definition in the hangup signal
schema) to include 'timeout-local-track' so the schema matches the
CallHangupReason type and will accept hangup signals with that reason.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/media-signaling/src/definition/call/IClientMediaCall.ts`:
- Around line 25-34: CallHangupReason includes 'timeout-local-track' but the
runtime schema enum (clientMediaSignalHangupSchema) is missing that variant;
update the enum in clientMediaSignalHangupSchema (the enum definition in the
hangup signal schema) to include 'timeout-local-track' so the schema matches the
CallHangupReason type and will accept hangup signals with that reason.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59daee12-1f5e-47e8-8540-f13f7fb3d855

📥 Commits

Reviewing files that changed from the base of the PR and between 5b291c3 and 3539af6.

📒 Files selected for processing (7)
  • .changeset/fluffy-poets-check.md
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/services/negotiation.ts
  • packages/media-signaling/src/lib/Call.ts
  • packages/media-signaling/src/lib/NegotiationManager.ts
  • packages/media-signaling/src/lib/Session.ts
📜 Review details
⏰ 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). (2)
  • GitHub Check: 📦 Track Image Sizes
  • GitHub Check: 🔎 Code Check / Code Lint
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/NegotiationManager.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/services/negotiation.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/Call.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/fluffy-poets-check.md
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/NegotiationManager.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/services/negotiation.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/Call.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/NegotiationManager.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/services/negotiation.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/Call.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/NegotiationManager.ts
  • packages/media-signaling/src/definition/client.ts
  • packages/media-signaling/src/definition/services/negotiation.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/Call.ts
🔇 Additional comments (10)
.changeset/fluffy-poets-check.md (1)

1-6: LGTM!

The minor bump is appropriate — the PR adds additive surface area to @rocket.chat/media-signaling (new public methods, a new event, and new union variants).

packages/media-signaling/src/definition/services/negotiation.ts (1)

7-7: LGTM!

New negotiation-started event slot added cleanly; producer (NegotiationManager.processNegotiation) and consumer (Call.onNegotiationStarted) are wired consistently.

packages/media-signaling/src/definition/client.ts (1)

5-5: LGTM!

The waiting-for-track state slots logically between accepting and waiting-for-offer, matching the new lifecycle introduced in Call.getClientState and timeout mapping.

packages/media-signaling/src/lib/NegotiationManager.ts (1)

232-240: LGTM!

negotiation-started is emitted right after the fire-and-forget process() call, which is fine since the only consumer (Call.onNegotiationStarted) just refreshes client state. The visibility bump on isConfigured() is the minimum needed to expose it to Call.getClientState, and the this is WebRTCNegotiationManager type-guard return is preserved.

packages/media-signaling/src/lib/Call.ts (3)

513-516: LGTM — the new branch correctly closes the soft-lock window.

When the call is accepted but negotiationManager.isConfigured() is false (most commonly because no input track is available yet), reporting waiting-for-track lets updateClientState install the dedicated TIMEOUT_TO_PROGRESS_SIGNALING timer with a timeout-local-track hangup reason. Once the track arrives and setInputTrack invokes updateClientState + processNegotiations, the state advances cleanly to waiting-for-offer and then to generating-local-sdp via the new negotiation-started notification.


556-559: LGTM — ordering matches the fix intent.

Calling updateClientState() before processNegotiations() ensures the state moves out of waiting-for-track first; otherwise the listener-driven negotiation-started callback would race with stale timeouts still bound to waiting-for-track.


1378-1381: LGTM!

onNegotiationStarted simply forwards into updateClientState, which is the right place to consume the new lifecycle event — the negotiation manager has already set currentNegotiation by the time this fires, so getClientState will advance past waiting-for-offer.

packages/media-signaling/src/lib/Session.ts (3)

438-446: LGTM — this matches the PR's root-cause fix.

The previous flow flipped an "updating" flag before the async work completed (even when no work was needed), which caused the lock-screen-accept race. The new shape keeps requestInputTrackUpdate as a cheap, synchronous early-bail and only enters the guarded switchInputTrack (with switchingInputTrack=true) when an actual switch is required. The double shouldSwitchInputTrack() check (here and inside switchInputTrack) correctly handles state changes between scheduling and execution.


489-513: LGTM!

shouldStartInputTrack correctly accounts for the callsToGetUserMedia in-flight counter so retries while a getUserMedia is pending don't kick off a duplicate request, and shouldSwitchInputTrack cleanly composes the start/stop conditions.


462-487: 💤 Low value

setDeviceId bypasses the switchingInputTrack guard without test coverage for concurrent execution.

switchInputTrack correctly guards against concurrent invocations by checking shouldSwitchInputTrack() after acquiring the lock. However, setDeviceId logs a warning when switchingInputTrack is true then proceeds with its own setInputTrack(null) + startInputTrack() sequence, completely bypassing the guard. The callsToGetUserMedia counter mitigates overlapping getUserMedia calls but does not protect the full concurrent sequence. A race condition exists where a device change and a lock-screen-accept switch can execute their track-switching logic simultaneously. No test coverage exists for this concurrent scenario. Recommend adding a test that changes device while a call switch is in-flight, or consider making setDeviceId also respect the switchingInputTrack guard.

@pierre-lehnen-rc
pierre-lehnen-rc changed the base branch from release-8.4.1 to develop May 8, 2026 15:42
@pierre-lehnen-rc pierre-lehnen-rc added this to the 8.6.0 milestone May 26, 2026
@scuciatto scuciatto added the stat: QA assured Means it has been tested and approved by a company insider label Jun 11, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jun 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 11, 2026
@alfredodelfabro alfredodelfabro modified the milestone: 8.6.0 Jun 15, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 15, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jun 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 15, 2026
@alfredodelfabro alfredodelfabro removed this from the 8.6.0 milestone Jun 16, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 16, 2026
@alfredodelfabro alfredodelfabro added this to the 8.6.0 milestone Jun 16, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 16, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jun 16, 2026
Merged via the queue into develop with commit ebc9c17 Jun 16, 2026
81 of 84 checks passed
@dionisio-bot
dionisio-bot Bot deleted the fix/mobile-voip-input-track-missing branch June 16, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants