⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276570 in webkit


Ignore:
Timestamp:
Apr 25, 2021, 1:32:24 PM (5 years ago)
Author:
jer.noble@apple.com
Message:

[GPUP][iOS] Silent video playback can interrupt system audio
https://bugs.webkit.org/show_bug.cgi?id=225031
<rdar://76652073>

Reviewed by Eric Carlson.

When the WebContent process asks the GPU Process to set the AVAudioSession audio session
category, the GPU Process as an optimization returns early if the session category being
requested is the same as has already been set. However, the default value of the category
is "None" (which translates to AVAudioSessionCategoryAmbient), and setting the category
to "None" becomes a no-op due to this default. As such, the GPUP never sets the underlying
AVAudioSession's category away from the default, which is AVAudioSessionCategorySoloAmbient,
and thus will interrupt other audio during playback.

Additionally, there's a subtle logic error where the audio session category is not changed
when a given WebContent process (and it's RemoteAudioSession & Proxy) goes away.

The fix for both of these issues is to re-calculate the correct audio session category
when a RemoteAudioSessionProxy is added or removed from RemoteAudioSessionProxyManager.
Since "None" is the default value for a RemoteAudioSessionProxy, the mere act of adding
a new RemoteAudioSessionProxy (which is created when a WebContent process is created)
will cause the audio session category to be set to AVAudioSessionCategoryAmbient.

  • GPUProcess/media/RemoteAudioSessionProxy.cpp:

(WebKit::RemoteAudioSessionProxy::setCategory):

  • GPUProcess/media/RemoteAudioSessionProxy.h:
  • GPUProcess/media/RemoteAudioSessionProxyManager.cpp:

(WebKit::RemoteAudioSessionProxyManager::addProxy):
(WebKit::RemoteAudioSessionProxyManager::removeProxy):
(WebKit::RemoteAudioSessionProxyManager::updateCategory):
(WebKit::RemoteAudioSessionProxyManager::setCategoryForProcess): Deleted.

  • GPUProcess/media/RemoteAudioSessionProxyManager.h:
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r276566 r276570  
     12021-04-25  Jer Noble  <jer.noble@apple.com>
     2
     3        [GPUP][iOS] Silent video playback can interrupt system audio
     4        https://bugs.webkit.org/show_bug.cgi?id=225031
     5        <rdar://76652073>
     6
     7        Reviewed by Eric Carlson.
     8
     9        When the WebContent process asks the GPU Process to set the AVAudioSession audio session
     10        category, the GPU Process as an optimization returns early if the session category being
     11        requested is the same as has already been set. However, the default value of the category
     12        is "None" (which translates to AVAudioSessionCategoryAmbient), and setting the category
     13        to "None" becomes a no-op due to this default. As such, the GPUP never sets the underlying
     14        AVAudioSession's category away from the default, which is AVAudioSessionCategorySoloAmbient,
     15        and thus will interrupt other audio during playback.
     16
     17        Additionally, there's a subtle logic error where the audio session category is not changed
     18        when a given WebContent process (and it's RemoteAudioSession & Proxy) goes away.
     19
     20        The fix for both of these issues is to re-calculate the correct audio session category
     21        when a RemoteAudioSessionProxy is added or removed from RemoteAudioSessionProxyManager.
     22        Since "None" is the default value for a RemoteAudioSessionProxy, the mere act of adding
     23        a new RemoteAudioSessionProxy (which is created when a WebContent process is created)
     24        will cause the audio session category to be set to AVAudioSessionCategoryAmbient.
     25
     26        * GPUProcess/media/RemoteAudioSessionProxy.cpp:
     27        (WebKit::RemoteAudioSessionProxy::setCategory):
     28        * GPUProcess/media/RemoteAudioSessionProxy.h:
     29        * GPUProcess/media/RemoteAudioSessionProxyManager.cpp:
     30        (WebKit::RemoteAudioSessionProxyManager::addProxy):
     31        (WebKit::RemoteAudioSessionProxyManager::removeProxy):
     32        (WebKit::RemoteAudioSessionProxyManager::updateCategory):
     33        (WebKit::RemoteAudioSessionProxyManager::setCategoryForProcess): Deleted.
     34        * GPUProcess/media/RemoteAudioSessionProxyManager.h:
     35
    1362021-04-25  Dean Jackson  <dino@apple.com>
    237
  • trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp

    r274891 r276570  
    8181    m_category = category;
    8282    m_routeSharingPolicy = policy;
    83     audioSessionManager().setCategoryForProcess(*this, category, policy);
     83    audioSessionManager().updateCategory();
    8484}
    8585
  • trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h

    r274189 r276570  
    7979
    8080    GPUConnectionToWebProcess& m_gpuConnection;
    81     WebCore::AudioSession::CategoryType m_category;
    82     WebCore::RouteSharingPolicy m_routeSharingPolicy;
     81    WebCore::AudioSession::CategoryType m_category { WebCore::AudioSession::None };
     82    WebCore::RouteSharingPolicy m_routeSharingPolicy { WebCore::RouteSharingPolicy::Default };
    8383    size_t m_preferredBufferSize { 0 };
    8484    bool m_active { false };
  • trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp

    r270705 r276570  
    5959    ASSERT(!m_proxies.contains(proxy));
    6060    m_proxies.add(proxy);
     61    updateCategory();
    6162}
    6263
     
    6566    ASSERT(m_proxies.contains(proxy));
    6667    m_proxies.remove(proxy);
     68    updateCategory();
    6769}
    6870
    69 void RemoteAudioSessionProxyManager::setCategoryForProcess(RemoteAudioSessionProxy& proxy, AudioSession::CategoryType category, RouteSharingPolicy policy)
     71void RemoteAudioSessionProxyManager::updateCategory()
    7072{
     73    AudioSession::CategoryType category = AudioSession::None;
     74    RouteSharingPolicy policy = RouteSharingPolicy::Default;
     75
    7176    HashCountedSet<AudioSession::CategoryType, WTF::IntHash<AudioSession::CategoryType>, WTF::StrongEnumHashTraits<AudioSession::CategoryType>> categoryCounts;
    7277    HashCountedSet<RouteSharingPolicy, WTF::IntHash<RouteSharingPolicy>, WTF::StrongEnumHashTraits<RouteSharingPolicy>> policyCounts;
  • trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h

    r258390 r276570  
    4747    void removeProxy(RemoteAudioSessionProxy&);
    4848
    49     void setCategoryForProcess(RemoteAudioSessionProxy&, WebCore::AudioSession::CategoryType, WebCore::RouteSharingPolicy);
     49    void updateCategory();
    5050    void setPreferredBufferSizeForProcess(RemoteAudioSessionProxy&, size_t);
    5151
Note: See TracChangeset for help on using the changeset viewer.