RESOLVED FIXED 236363
(Safari 15 - iOS15): Increased audio latency on streaming via webrtc
https://bugs.webkit.org/show_bug.cgi?id=236363
Summary (Safari 15 - iOS15): Increased audio latency on streaming via webrtc
asanand
Reported 2022-02-09 07:03:40 PST
We are observing noticeable increase in audio latency in Safari browser iOS 15.4 beta. Our Client side implementation plays webrtc audio/video stream received from server on video element. We have looked in the mediaserverd logs(presented below) and here is our finding default 12:34:35.138370+0530 mediaserverd -CMVAEndptMgr- vaemSetDeviceBufferDuration: duration = 0.085, sampleRate = 48000.000, numPCMSamples = 4095, NearestPowerOf2 = 4096, UseQuietBufferSizeProperty = ‘NO’ When we play the same after enabling the "AudioContext", we are getting following log default 12:42:35.257580+0530 mediaserverd -CMVAEndptMgr- vaemSetDeviceBufferDuration: duration = 0.003, sampleRate = 48000.000, numPCMSamples = 127, NearestPowerOf2 = 128, UseQuietBufferSizeProperty = ‘NO’ the numPCMSamples in case of AudioContext is reducing down to 127 and its having direct impact on our audio latency.
Attachments
Patch (4.96 KB, patch)
2022-04-07 04:29 PDT, youenn fablet
no flags
Alexey Proskuryakov
Comment 1 2022-02-10 10:32:30 PST
Could you please clarify if this is a new issue in Safari 15.4 beta, or if it affects shipping Safari too?
youenn fablet
Comment 2 2022-02-10 10:53:27 PST
Also, is the application capturing microphone? It is not unexpected that web audio will get you the lowest latency.
asanand
Comment 3 2022-02-10 20:21:25 PST
(In reply to Alexey Proskuryakov from comment #1) > Could you please clarify if this is a new issue in Safari 15.4 beta, or if > it affects shipping Safari too? It affects shipping safari too
asanand
Comment 4 2022-02-10 20:25:06 PST
(In reply to youenn fablet from comment #2) > Also, is the application capturing microphone? > It is not unexpected that web audio will get you the lowest latency. The application is not capturing microphone. What should be the difference in latency between playing with and without WebAudio.
youenn fablet
Comment 5 2022-02-11 01:03:17 PST
(In reply to asanand from comment #4) > (In reply to youenn fablet from comment #2) > > Also, is the application capturing microphone? > > It is not unexpected that web audio will get you the lowest latency. > > The application is not capturing microphone. > > What should be the difference in latency between playing with and without > WebAudio. A small latency is better for reactiveness, less so for battery life and stability. With WebAudio, spec mentions a small audio quantum so we tune the audio renderer accordingly. For regular audio, we do a different set up but I can see some applications wanting to get low latency for incoming WebRTC audio. We could look at implementing https://w3c.github.io/webrtc-extensions/#dom-rtcrtpreceiver-playoutdelay so that your application could provide a hint about this. Can you provide more info on your usecase?
asanand
Comment 6 2022-02-14 05:04:34 PST
(In reply to youenn fablet from comment #5) > (In reply to asanand from comment #4) > > (In reply to youenn fablet from comment #2) > > > Also, is the application capturing microphone? > > > It is not unexpected that web audio will get you the lowest latency. > > > > The application is not capturing microphone. > > > > What should be the difference in latency between playing with and without > > WebAudio. > > A small latency is better for reactiveness, less so for battery life and > stability. > With WebAudio, spec mentions a small audio quantum so we tune the audio > renderer accordingly. > For regular audio, we do a different set up but I can see some applications > wanting to get low latency for incoming WebRTC audio. > > We could look at implementing > https://w3c.github.io/webrtc-extensions/#dom-rtcrtpreceiver-playoutdelay so > that your application could provide a hint about this. > > Can you provide more info on your usecase? We are having application for cloud gaming where we stream audio/video with optional upstream(mic streams)
Radar WebKit Bug Importer
Comment 7 2022-02-15 09:32:08 PST
asanand
Comment 8 2022-03-16 06:18:30 PDT
(In reply to youenn fablet from comment #5) > (In reply to asanand from comment #4) > > (In reply to youenn fablet from comment #2) > > > Also, is the application capturing microphone? > > > It is not unexpected that web audio will get you the lowest latency. > > > > The application is not capturing microphone. > > > > What should be the difference in latency between playing with and without > > WebAudio. > > A small latency is better for reactiveness, less so for battery life and > stability. > With WebAudio, spec mentions a small audio quantum so we tune the audio > renderer accordingly. > For regular audio, we do a different set up but I can see some applications > wanting to get low latency for incoming WebRTC audio. > > We could look at implementing > https://w3c.github.io/webrtc-extensions/#dom-rtcrtpreceiver-playoutdelay so > that your application could provide a hint about this. > > Can you provide more info on your usecase? When can we expect a fix for this issue where we could provide a hint as mentioned here > We could look at implementing > https://w3c.github.io/webrtc-extensions/#dom-rtcrtpreceiver-playoutdelay so > that your application could provide a hint about this.
Virginia Farley
Comment 9 2022-03-29 14:20:08 PDT
Youenn, could you please provide an update on the fix for this?
youenn fablet
Comment 10 2022-04-07 04:29:13 PDT
EWS
Comment 11 2022-04-07 13:59:46 PDT
Committed r292563 (249401@main): <https://commits.webkit.org/249401@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 456906 [details].
asanand
Comment 12 2022-04-07 21:08:51 PDT
(In reply to youenn fablet from comment #10) > Created attachment 456906 [details] > Patch Which Safari version should have this fix ?
Brent Fulgham
Comment 13 2022-05-26 15:05:23 PDT
This fix shipped with Safari 15.5 (all platforms).
Virginia Farley
Comment 14 2022-06-24 14:02:11 PDT
Still observing an additional ~50ms of latency after this patch. Could we please reevaluate whether the preferred buffer size could be further reduced to address the audio latency, or whether a different approach could be considered to resolve this?
Note You need to log in before you can comment on or make changes to this bug.