Changeset 292563 in webkit


Ignore:
Timestamp:
Apr 7, 2022 1:58:35 PM (3 months ago)
Author:
youenn@apple.com
Message:

(Safari 15 - iOS15): Increased audio latency on streaming via webrtc
https://bugs.webkit.org/show_bug.cgi?id=236363
<rdar://problem/88969850>

Reviewed by Eric Carlson.

On macOS 12.3, the default preferred buffer size is roughly 100 ms.
This is ok for regular audio playback but is not desirable when playing realtime audio.
To reduce the perceived latency, we now reduce the preferred buffer size to 20ms
whenever playing an audio MediaStreamTrack, similarly to when capturing audio.

Manually tested.

  • platform/audio/PlatformMediaSession.cpp:
  • platform/audio/PlatformMediaSession.h:
  • platform/audio/cocoa/MediaSessionManagerCocoa.mm:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r292561 r292563  
     12022-04-07  Youenn Fablet  <youenn@apple.com>
     2
     3        (Safari 15 - iOS15):  Increased audio latency on streaming via webrtc
     4        https://bugs.webkit.org/show_bug.cgi?id=236363
     5        <rdar://problem/88969850>
     6
     7        Reviewed by Eric Carlson.
     8
     9        On macOS 12.3, the default preferred buffer size is roughly 100 ms.
     10        This is ok for regular audio playback but is not desirable when playing realtime audio.
     11        To reduce the perceived latency, we now reduce the preferred buffer size to 20ms
     12        whenever playing an audio MediaStreamTrack, similarly to when capturing audio.
     13
     14        Manually tested.
     15
     16        * platform/audio/PlatformMediaSession.cpp:
     17        * platform/audio/PlatformMediaSession.h:
     18        * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
     19
    1202022-04-07  Antoine Quint  <graouts@webkit.org>
    221
  • trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp

    r290575 r292563  
    366366}
    367367
     368bool PlatformMediaSession::hasMediaStreamSource() const
     369{
     370    return m_client.hasMediaStreamSource();
     371}
     372
    368373void PlatformMediaSession::canProduceAudioChanged()
    369374{
  • trunk/Source/WebCore/platform/audio/PlatformMediaSession.h

    r289942 r292563  
    180180    bool activeAudioSessionRequired() const;
    181181    bool canProduceAudio() const;
     182    bool hasMediaStreamSource() const;
    182183    void canProduceAudioChanged();
    183184
  • trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm

    r291863 r292563  
    114114    int audioCount = 0;
    115115    int webAudioCount = 0;
     116    int audioMediaStreamTrackCount = 0;
    116117    int captureCount = countActiveAudioCaptureSources();
    117118    bool hasAudibleAudioOrVideoMediaType = false;
     
    127128        case PlatformMediaSession::MediaType::VideoAudio:
    128129            ++videoAudioCount;
     130            if (session.canProduceAudio() && session.hasMediaStreamSource())
     131                ++audioMediaStreamTrackCount;
    129132            break;
    130133        case PlatformMediaSession::MediaType::Audio:
    131134            ++audioCount;
     135            if (session.canProduceAudio() && session.hasMediaStreamSource())
     136                ++audioMediaStreamTrackCount;
    132137            break;
    133138        case PlatformMediaSession::MediaType::WebAudio:
     
    153158    ALWAYS_LOG(LOGIDENTIFIER, "types: "
    154159        "AudioCapture(", captureCount, "), "
     160        "AudioTrack(", audioMediaStreamTrackCount, "), "
    155161        "Video(", videoCount, "), "
    156162        "Audio(", audioCount, "), "
     
    161167    if (webAudioCount)
    162168        bufferSize = AudioUtilities::renderQuantumSize;
    163     else if (captureCount) {
    164         // In case of audio capture, we want to grab 20 ms chunks to limit the latency so that it is not noticeable by users
     169    else if (captureCount || audioMediaStreamTrackCount) {
     170        // In case of audio capture or audio MediaStreamTrack playing, we want to grab 20 ms chunks to limit the latency so that it is not noticeable by users
    165171        // while having a large enough buffer so that the audio rendering remains stable, hence a computation based on sample rate.
    166172        bufferSize = AudioSession::sharedSession().sampleRate() / 50;
Note: See TracChangeset for help on using the changeset viewer.