Title: [276570] trunk/Source/WebKit
Revision
276570
Author
jer.no...@apple.com
Date
2021-04-25 13:32:24 -0700 (Sun, 25 Apr 2021)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (276569 => 276570)


--- trunk/Source/WebKit/ChangeLog	2021-04-25 19:17:10 UTC (rev 276569)
+++ trunk/Source/WebKit/ChangeLog	2021-04-25 20:32:24 UTC (rev 276570)
@@ -1,3 +1,38 @@
+2021-04-25  Jer Noble  <jer.no...@apple.com>
+
+        [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:
+
 2021-04-25  Dean Jackson  <d...@apple.com>
 
         [WebXR] Should be enabled when WEBXR_INTERNALS is true

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp (276569 => 276570)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp	2021-04-25 19:17:10 UTC (rev 276569)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp	2021-04-25 20:32:24 UTC (rev 276570)
@@ -80,7 +80,7 @@
 
     m_category = category;
     m_routeSharingPolicy = policy;
-    audioSessionManager().setCategoryForProcess(*this, category, policy);
+    audioSessionManager().updateCategory();
 }
 
 void RemoteAudioSessionProxy::setPreferredBufferSize(uint64_t size)

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h (276569 => 276570)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h	2021-04-25 19:17:10 UTC (rev 276569)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h	2021-04-25 20:32:24 UTC (rev 276570)
@@ -78,8 +78,8 @@
     IPC::Connection& connection();
 
     GPUConnectionToWebProcess& m_gpuConnection;
-    WebCore::AudioSession::CategoryType m_category;
-    WebCore::RouteSharingPolicy m_routeSharingPolicy;
+    WebCore::AudioSession::CategoryType m_category { WebCore::AudioSession::None };
+    WebCore::RouteSharingPolicy m_routeSharingPolicy { WebCore::RouteSharingPolicy::Default };
     size_t m_preferredBufferSize { 0 };
     bool m_active { false };
 };

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp (276569 => 276570)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp	2021-04-25 19:17:10 UTC (rev 276569)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp	2021-04-25 20:32:24 UTC (rev 276570)
@@ -58,6 +58,7 @@
 {
     ASSERT(!m_proxies.contains(proxy));
     m_proxies.add(proxy);
+    updateCategory();
 }
 
 void RemoteAudioSessionProxyManager::removeProxy(RemoteAudioSessionProxy& proxy)
@@ -64,10 +65,14 @@
 {
     ASSERT(m_proxies.contains(proxy));
     m_proxies.remove(proxy);
+    updateCategory();
 }
 
-void RemoteAudioSessionProxyManager::setCategoryForProcess(RemoteAudioSessionProxy& proxy, AudioSession::CategoryType category, RouteSharingPolicy policy)
+void RemoteAudioSessionProxyManager::updateCategory()
 {
+    AudioSession::CategoryType category = AudioSession::None;
+    RouteSharingPolicy policy = RouteSharingPolicy::Default;
+
     HashCountedSet<AudioSession::CategoryType, WTF::IntHash<AudioSession::CategoryType>, WTF::StrongEnumHashTraits<AudioSession::CategoryType>> categoryCounts;
     HashCountedSet<RouteSharingPolicy, WTF::IntHash<RouteSharingPolicy>, WTF::StrongEnumHashTraits<RouteSharingPolicy>> policyCounts;
     for (auto& otherProxy : m_proxies) {

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h (276569 => 276570)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h	2021-04-25 19:17:10 UTC (rev 276569)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h	2021-04-25 20:32:24 UTC (rev 276570)
@@ -46,7 +46,7 @@
     void addProxy(RemoteAudioSessionProxy&);
     void removeProxy(RemoteAudioSessionProxy&);
 
-    void setCategoryForProcess(RemoteAudioSessionProxy&, WebCore::AudioSession::CategoryType, WebCore::RouteSharingPolicy);
+    void updateCategory();
     void setPreferredBufferSizeForProcess(RemoteAudioSessionProxy&, size_t);
 
     bool tryToSetActiveForProcess(RemoteAudioSessionProxy&, bool);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to