Title: [280462] trunk/Source/WebCore
Revision
280462
Author
[email protected]
Date
2021-07-29 18:51:18 -0700 (Thu, 29 Jul 2021)

Log Message

[Cocoa|WK1] -[NSAttributeString loadFromHTML...] methods will disable bluetooth route switching
https://bugs.webkit.org/show_bug.cgi?id=228593
<rdar://81160969>

Reviewed by Eric Carlson.

NSAttributedString will use WebKitLegacy APIs to load provided HTML; in so doing, an AudioSessionIOS
singleton object is created, and -[AVAudioSession setEligibleForBTSmartRoutingConsideration:error:]
is called with a NO parameter, disabling smart routing for the calling process.

Disable this behavior if DeprecatedGlobalSettings::shouldManageAudioSessionCategory() returns false;
this setting is disabled for all WK1 clients, and enabled for WK2.

* page/DeprecatedGlobalSettings.cpp:
(WebCore::DeprecatedGlobalSettings::setShouldManageAudioSessionCategory):
(WebCore::DeprecatedGlobalSettings::shouldManageAudioSessionCategory):
* page/DeprecatedGlobalSettings.h:
(WebCore::DeprecatedGlobalSettings::setShouldManageAudioSessionCategory): Deleted.
(WebCore::DeprecatedGlobalSettings::shouldManageAudioSessionCategory): Deleted.
* platform/audio/AudioSession.h:
* platform/audio/ios/AudioSessionIOS.mm:
(WebCore::setEligibleForSmartRouting):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (280461 => 280462)


--- trunk/Source/WebCore/ChangeLog	2021-07-30 01:44:51 UTC (rev 280461)
+++ trunk/Source/WebCore/ChangeLog	2021-07-30 01:51:18 UTC (rev 280462)
@@ -1,3 +1,28 @@
+2021-07-29  Jer Noble  <[email protected]>
+
+        [Cocoa|WK1] -[NSAttributeString loadFromHTML...] methods will disable bluetooth route switching
+        https://bugs.webkit.org/show_bug.cgi?id=228593
+        <rdar://81160969>
+
+        Reviewed by Eric Carlson.
+
+        NSAttributedString will use WebKitLegacy APIs to load provided HTML; in so doing, an AudioSessionIOS
+        singleton object is created, and -[AVAudioSession setEligibleForBTSmartRoutingConsideration:error:]
+        is called with a NO parameter, disabling smart routing for the calling process.
+
+        Disable this behavior if DeprecatedGlobalSettings::shouldManageAudioSessionCategory() returns false;
+        this setting is disabled for all WK1 clients, and enabled for WK2.
+
+        * page/DeprecatedGlobalSettings.cpp:
+        (WebCore::DeprecatedGlobalSettings::setShouldManageAudioSessionCategory):
+        (WebCore::DeprecatedGlobalSettings::shouldManageAudioSessionCategory):
+        * page/DeprecatedGlobalSettings.h:
+        (WebCore::DeprecatedGlobalSettings::setShouldManageAudioSessionCategory): Deleted.
+        (WebCore::DeprecatedGlobalSettings::shouldManageAudioSessionCategory): Deleted.
+        * platform/audio/AudioSession.h:
+        * platform/audio/ios/AudioSessionIOS.mm:
+        (WebCore::setEligibleForSmartRouting):
+
 2021-07-29  Devin Rousso  <[email protected]>
 
         [Payment Request] `additionalShippingMethods` are not used if a `paymentMethodType` is provided

Modified: trunk/Source/WebCore/page/DeprecatedGlobalSettings.cpp (280461 => 280462)


--- trunk/Source/WebCore/page/DeprecatedGlobalSettings.cpp	2021-07-30 01:44:51 UTC (rev 280461)
+++ trunk/Source/WebCore/page/DeprecatedGlobalSettings.cpp	2021-07-30 01:51:18 UTC (rev 280462)
@@ -58,7 +58,6 @@
 bool DeprecatedGlobalSettings::gShouldOptOutOfNetworkStateObservation = false;
 bool DeprecatedGlobalSettings::gDisableScreenSizeOverride = false;
 #endif
-bool DeprecatedGlobalSettings::gManageAudioSession = false;
 
 #if PLATFORM(WIN)
 void DeprecatedGlobalSettings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
@@ -184,6 +183,18 @@
 }
 #endif
 
+#if USE(AUDIO_SESSION)
+void DeprecatedGlobalSettings::setShouldManageAudioSessionCategory(bool flag)
+{
+    AudioSession::setShouldManageAudioSessionCategory(flag);
+}
+
+bool DeprecatedGlobalSettings::shouldManageAudioSessionCategory()
+{
+    return AudioSession::shouldManageAudioSessionCategory();
+}
+#endif
+
 void DeprecatedGlobalSettings::setAllowsAnySSLCertificate(bool allowAnySSLCertificate)
 {
     gAllowsAnySSLCertificate = allowAnySSLCertificate;

Modified: trunk/Source/WebCore/page/DeprecatedGlobalSettings.h (280461 => 280462)


--- trunk/Source/WebCore/page/DeprecatedGlobalSettings.h	2021-07-30 01:44:51 UTC (rev 280461)
+++ trunk/Source/WebCore/page/DeprecatedGlobalSettings.h	2021-07-30 01:51:18 UTC (rev 280462)
@@ -84,8 +84,8 @@
 #endif
 
 #if USE(AUDIO_SESSION)
-    static void setShouldManageAudioSessionCategory(bool flag) { gManageAudioSession = flag; }
-    static bool shouldManageAudioSessionCategory() { return gManageAudioSession; }
+    WEBCORE_EXPORT static void setShouldManageAudioSessionCategory(bool flag);
+    WEBCORE_EXPORT static bool shouldManageAudioSessionCategory();
 #endif
 
     WEBCORE_EXPORT static void setAllowsAnySSLCertificate(bool);

Modified: trunk/Source/WebCore/platform/audio/AudioSession.cpp (280461 => 280462)


--- trunk/Source/WebCore/platform/audio/AudioSession.cpp	2021-07-30 01:44:51 UTC (rev 280461)
+++ trunk/Source/WebCore/platform/audio/AudioSession.cpp	2021-07-30 01:51:18 UTC (rev 280462)
@@ -41,6 +41,8 @@
 
 namespace WebCore {
 
+bool AudioSession::s_shouldManageAudioSessionCategory { false };
+
 static std::optional<UniqueRef<AudioSession>>& sharedAudioSession()
 {
     static NeverDestroyed<std::optional<UniqueRef<AudioSession>>> session;

Modified: trunk/Source/WebCore/platform/audio/AudioSession.h (280461 => 280462)


--- trunk/Source/WebCore/platform/audio/AudioSession.h	2021-07-30 01:44:51 UTC (rev 280461)
+++ trunk/Source/WebCore/platform/audio/AudioSession.h	2021-07-30 01:51:18 UTC (rev 280462)
@@ -125,6 +125,9 @@
 
     virtual void setRoutingArbitrationClient(WeakPtr<AudioSessionRoutingArbitrationClient>&& client) { m_routingArbitrationClient = client; }
 
+    static bool shouldManageAudioSessionCategory() { return s_shouldManageAudioSessionCategory; }
+    static void setShouldManageAudioSessionCategory(bool flag) { s_shouldManageAudioSessionCategory = flag; }
+
 protected:
     friend class NeverDestroyed<AudioSession>;
     AudioSession();
@@ -138,6 +141,8 @@
 
     WeakPtr<AudioSessionRoutingArbitrationClient> m_routingArbitrationClient;
     bool m_active { false }; // Used only for testing.
+
+    static bool s_shouldManageAudioSessionCategory;
 };
 
 class WEBCORE_EXPORT AudioSessionRoutingArbitrationClient {

Modified: trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm (280461 => 280462)


--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2021-07-30 01:44:51 UTC (rev 280461)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2021-07-30 01:51:18 UTC (rev 280462)
@@ -99,6 +99,8 @@
 static void setEligibleForSmartRouting(bool eligible)
 {
 #if PLATFORM(IOS)
+    if (!AudioSession::shouldManageAudioSessionCategory())
+        return;
 
     auto *session = [PAL::getAVAudioSessionClass() sharedInstance];
     if (![session respondsToSelector:@selector(setEligibleForBTSmartRoutingConsideration:error:)]
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to