Skip to content

Conversation

@gabriellsh
Copy link
Member

@gabriellsh gabriellsh commented Oct 28, 2025

Proposed changes (including videos or screenshots)

Issue(s)

VGA-46

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Improved tone audio quality for more natural playback.
    • Synchronized tone start times for more accurate and consistent playback.
    • Reworked tone stop behavior for precise, reliable termination of sounds.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 28, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

⚠️ No Changeset found

Latest commit: 38c631d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Reworks the tone player: switches the BiquadFilter from lowpass (8000 Hz) to bandpass (4000 Hz), computes a shared startTime (audioContext.currentTime) to start both oscillators synchronously, and replaces setTimeout-based cleanup with absolute WebAudio stop calls scheduled from startTime and durationMs.

Changes

Cohort / File(s) Summary
Tone player timing & filter
packages/ui-voip/src/v2/useTonePlayer.ts
Replaced lowpass (8000 Hz) with bandpass (4000 Hz); compute and use a shared startTime (audioContext.currentTime) to start oscillators synchronously; replace setTimeout stop/disconnect logic with explicit oscillator.stop(absoluteTime) calls and remove scheduled disconnects.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Dialpad / Caller
  participant Hook as useTonePlayer
  participant Audio as AudioContext / Nodes

  UI->>Hook: requestPlayTone(dtmfKey, durationMs)
  Note right of Hook #D6EAF8: compute startTime = audioContext.currentTime
  Hook->>Audio: createOscillators() & createBiquadFilter(type=bandpass, freq=4000)
  Hook->>Audio: connect oscillators -> filter -> destination
  Hook->>Audio: oscillator1.start(startTime)
  Hook->>Audio: oscillator2.start(startTime)
  Note right of Hook #D6EAF8: schedule absolute stop = startTime + durationMs/1000
  Hook->>Audio: oscillator1.stop(stopTime)
  Hook->>Audio: oscillator2.stop(stopTime)
  Audio-->>Hook: nodes stop at stopTime (no setTimeout)
  Hook-->>UI: playbackScheduled
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to WebAudio API timing correctness and cross-browser (Safari) behavior.
  • Verify removal of disconnects does not leak nodes in edge cases.
  • Confirm bandpass frequency choice yields expected DTMF quality.

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • aleksandernsilva

Poem

🐇 I tuned the hum to a bandpass song,
Two oscillators start together, strong.
No timeouts lingering in the air,
Stops arrive exact and fair —
Safari nods, the tone is gone.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "regression: Voice call keypad doesn't stop on safari" directly addresses the main issue being fixed, which is documented in the linked VGA-46 issue describing DTMF tones that continue playing indefinitely on Safari. The title is clear, concise, and specific about both the problem domain (voice call keypad) and the affected platform (Safari), allowing teammates to quickly understand the regression being addressed.
Linked Issues Check ✅ Passed The code changes in useTonePlayer.ts directly address the requirements from VGA-46. The core modifications—replacing setTimeout-based stopping with precise Web Audio API stop times and using computed startTime for synchronized oscillator starts—directly target the Safari regression where DTMF tones played indefinitely. These changes implement proper audio lifecycle management that ensures tones stop immediately as expected, resolving the issue where tones persisted until page refresh.
Out of Scope Changes Check ✅ Passed Most changes are directly in scope: the oscillator timing synchronization and replacement of setTimeout with absolute stop times are core fixes for the Safari regression. However, the BiquadFilter configuration change (lowpass to bandpass, 8000 Hz to 4000 Hz) appears to be a tone quality enhancement rather than part of the core regression fix addressing the stopping issue. While minor and in the same file, this change seems tangential to the primary objective of fixing the DTMF tone stopping problem on Safari.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/tonePlayer

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a1ecb89 and 38c631d.

📒 Files selected for processing (1)
  • packages/ui-voip/src/v2/useTonePlayer.ts (3 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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
packages/ui-voip/src/v2/useTonePlayer.ts (1)

57-70: Excellent fix for the Safari regression.

The use of WebAudio's built-in scheduling instead of setTimeout-based cleanup is the correct approach. This change addresses the Safari issue where DTMF tones play continuously:

  1. Precise scheduling: stop(startTime + duration) schedules the stop time directly in the WebAudio API, which is far more reliable than setTimeout callbacks that may not fire properly on Safari.
  2. Synchronous starts: Computing a shared startTime ensures both oscillators begin together, maintaining proper DTMF tone generation.
  3. No dangling oscillators: The absolute stop times prevent the scenario where oscillators continue playing indefinitely.

This pattern follows WebAudio best practices and should resolve the regression.


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.

@gabriellsh gabriellsh marked this pull request as ready for review October 28, 2025 19:25
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.60%. Comparing base (c43c06a) to head (38c631d).
⚠️ Report is 1 commits behind head on release-7.12.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-7.12.0   #37328      +/-   ##
==================================================
+ Coverage           67.59%   67.60%   +0.01%     
==================================================
  Files                3338     3338              
  Lines              113708   113708              
  Branches            20649    20651       +2     
==================================================
+ Hits                76859    76872      +13     
+ Misses              34170    34156      -14     
- Partials             2679     2680       +1     
Flag Coverage Δ
e2e 57.41% <ø> (+0.01%) ⬆️
unit 71.56% <ø> (+<0.01%) ⬆️

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.

@gabriellsh gabriellsh changed the base branch from develop to release-7.12.0 October 28, 2025 19:30
@gabriellsh gabriellsh requested review from a team as code owners October 28, 2025 19:30
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ui-voip/src/v2/useTonePlayer.ts (1)

69-70: LGTM with suggested improvement: Add explicit disconnect() calls.

Using scheduled stop times with the WebAudio API is the correct fix for the Safari regression and should resolve the continuous playback issue. This approach is much more reliable than setTimeout-based cleanup.

Consider explicitly disconnecting the oscillators after they stop to ensure proper resource cleanup, especially given Safari's historical WebAudio issues:

 		highFrequencyOscillator.stop(startTime + (durationMs ?? 400) / 1000);
 		lowFrequencyOscillator.stop(startTime + (durationMs ?? 400) / 1000);
+		
+		const stopTime = startTime + (durationMs ?? 400) / 1000;
+		// Disconnect oscillators after they finish to ensure cleanup
+		setTimeout(() => {
+			highFrequencyOscillator.disconnect();
+			lowFrequencyOscillator.disconnect();
+		}, ((durationMs ?? 400) + 50)); // Add 50ms buffer
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 157c0d1 and a1ecb89.

📒 Files selected for processing (1)
  • packages/ui-voip/src/v2/useTonePlayer.ts (3 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). (4)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 📦 Meteor Build - coverage
🔇 Additional comments (1)
packages/ui-voip/src/v2/useTonePlayer.ts (1)

57-60: LGTM: Synchronized oscillator starts.

Synchronizing both oscillators to start at the same computed startTime ensures consistent dual-tone generation and prevents phase/timing issues. This is a good improvement.

@gabriellsh gabriellsh force-pushed the fix/tonePlayer branch 2 times, most recently from 1bed630 to f2bcf05 Compare October 28, 2025 19:31
@gabriellsh gabriellsh added this to the 7.12.0 milestone Oct 28, 2025
@tassoevan tassoevan merged commit 8e6df03 into release-7.12.0 Oct 28, 2025
49 checks passed
@tassoevan tassoevan deleted the fix/tonePlayer branch October 28, 2025 21:12
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.

3 participants