Skip to content

RTCDTMFSender: interToneGap is not clamped to 6000 ms and is waited twice between tones - #78217

Open
Ahmad-S792 wants to merge 1 commit into
WebKit:mainfrom
Ahmad-S792:eng/RTCDTMFSender-interToneGap-is-not-clamped-to-6000-ms-and-is-waited-twice-between-tones
Open

Ahmad-S792 wants to merge 1 commit into
WebKit:mainfrom
Ahmad-S792:eng/RTCDTMFSender-interToneGap-is-not-clamped-to-6000-ms-and-is-waited-twice-between-tones

Conversation

@Ahmad-S792

@Ahmad-S792 Ahmad-S792 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

cfab9c6

RTCDTMFSender: interToneGap is not clamped to 6000 ms and is waited twice between tones
https://bugs.webkit.org/show_bug.cgi?id=328831
rdar://190946556

Reviewed by NOBODY (OOPS!).

This patch aligns WebKit with Gecko / Firefox.

Per the WebRTC spec [1], insertDTMF() sets [[InterToneGap]] to 6000 ms if
the given value is greater than 6000 ms, in addition to raising values
below 30 ms to 30 ms. We only applied the lower bound, so a large
interToneGap was used as is. Clamp it to [30, 6000] with std::clamp, and
use std::clamp for duration as well so both lines match.

The spec also queues the next playout task duration + interToneGap after
a tone starts. We waited the gap twice: libwebrtc's DtmfSender already
waits duration + gap before reporting the tone as played, and then
RTCDTMFSender::onTonePlayed() started a further interToneGap timer before
playing the next tone, so each tone took duration + 2 * interToneGap.
Play the next tone directly from onTonePlayed() and remove the timer.

[1] https://w3c.github.io/webrtc-pc/#dom-RTCDTMFSender-insertDTMF

* LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDTMFSender-ontonechange-long.https.html: Added new tests
* LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDTMFSender-ontonechange-long.https-expected.txt: Updated Expectation
* Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp:
(WebCore::RTCDTMFSender::RTCDTMFSender):
(WebCore::RTCDTMFSender::insertDTMF):
(WebCore::RTCDTMFSender::onTonePlayed):
(WebCore::RTCDTMFSender::stop):
(WebCore::RTCDTMFSender::toneTimerFired): Deleted.
* Source/WebCore/Modules/mediastream/RTCDTMFSender.h:

cfab9c6

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-cmake-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-cmake-debug
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-cmake-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-wk2-stress ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

…wice between tones

https://bugs.webkit.org/show_bug.cgi?id=328831
rdar://190946556

Reviewed by NOBODY (OOPS!).

This patch aligns WebKit with Gecko / Firefox.

Per the WebRTC spec [1], insertDTMF() sets [[InterToneGap]] to 6000 ms if
the given value is greater than 6000 ms, in addition to raising values
below 30 ms to 30 ms. We only applied the lower bound, so a large
interToneGap was used as is. Clamp it to [30, 6000] with std::clamp, and
use std::clamp for duration as well so both lines match.

The spec also queues the next playout task duration + interToneGap after
a tone starts. We waited the gap twice: libwebrtc's DtmfSender already
waits duration + gap before reporting the tone as played, and then
RTCDTMFSender::onTonePlayed() started a further interToneGap timer before
playing the next tone, so each tone took duration + 2 * interToneGap.
Play the next tone directly from onTonePlayed() and remove the timer.

[1] https://w3c.github.io/webrtc-pc/#dom-RTCDTMFSender-insertDTMF

* LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDTMFSender-ontonechange-long.https.html: Added new tests
* LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDTMFSender-ontonechange-long.https-expected.txt: Updated Expectation
* Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp:
(WebCore::RTCDTMFSender::RTCDTMFSender):
(WebCore::RTCDTMFSender::insertDTMF):
(WebCore::RTCDTMFSender::onTonePlayed):
(WebCore::RTCDTMFSender::stop):
(WebCore::RTCDTMFSender::toneTimerFired): Deleted.
* Source/WebCore/Modules/mediastream/RTCDTMFSender.h:
@Ahmad-S792 Ahmad-S792 self-assigned this Oct 25, 2026
@Ahmad-S792 Ahmad-S792 added the WebRTC For bugs in WebRTC label Oct 25, 2026
@Ahmad-S792
Ahmad-S792 marked this pull request as ready for review October 25, 2026 17:43
@Ahmad-S792
Ahmad-S792 requested review from philn and youennf October 25, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebRTC For bugs in WebRTC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants