Title: [285584] trunk/Source
Revision
285584
Author
[email protected]
Date
2021-11-10 09:32:43 -0800 (Wed, 10 Nov 2021)

Log Message

[iOS] Adopt -[AVAudioSession setAuditTokensForProcessAssertion:]
https://bugs.webkit.org/show_bug.cgi?id=232909
<rdar://68184444>

Reviewed by Eric Carlson.

Source/WebCore:

* platform/audio/AudioSession.h:
* platform/audio/ios/AudioSessionIOS.h:
* platform/audio/ios/AudioSessionIOS.mm:
(WebCore::AudioSessionIOS::setPresentingProcesses):

Source/WebCore/PAL:

* pal/spi/cocoa/AVFoundationSPI.h:

Source/WebKit:

When a page is loaded through SafariViewService, the UIProcess is SVS, but the "presenting"
application is the client of SafariViewController. To further compliate things, multiple apps
all using a SafariViewController will use a singleton SafariViewService application. When such
an application goes to the background while playing audio, the audio subsystem will keep the
UIProcess from suspending, but not the presenting application. The audio subsystem will see
that the presenting application has become suspended, and will interrupt audio playback.

Opt into a AVAudioSession behavior where a client can provide an array of audit tokens for
those processes which are "presenting" the audio playback to the user. This will include the
UIProcess, but also the process which is hosting the SafariViewController. The audio subsystem
will keep the processes in that list from becoming suspended during audio playback.

Since there may be different clients of SafariViewService existing simultaneously, only include
those presenting application tokens whose WebContent processes require an "active" audio session.

* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::GPUConnectionToWebProcess):
* GPUProcess/GPUConnectionToWebProcess.h:
(WebKit::GPUConnectionToWebProcess::presentingApplicationAuditToken const):
* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::audioSessionManager const):
* GPUProcess/media/RemoteAudioSessionProxy.cpp:
(WebKit::RemoteAudioSessionProxy::tryToSetActive):
* GPUProcess/media/RemoteAudioSessionProxy.h:
(WebKit::RemoteAudioSessionProxy::gpuConnectionToWebProcess const):
* GPUProcess/media/RemoteAudioSessionProxyManager.cpp:
(WebKit::RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager):
(WebKit::RemoteAudioSessionProxyManager::updatePresentingProcesses):
* GPUProcess/media/RemoteAudioSessionProxyManager.h:
* Scripts/process-entitlements.sh:
* Shared/GPUProcessConnectionParameters.h:
(WebKit::GPUProcessConnectionParameters::encode const):
(WebKit::GPUProcessConnectionParameters::decode):
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration setPresentingApplicationProcessToken:]):
(-[_WKProcessPoolConfiguration presentingApplicationProcessToken]):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::getGPUProcessConnection):
* WebProcess/GPU/GPUProcessConnection.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285583 => 285584)


--- trunk/Source/WebCore/ChangeLog	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebCore/ChangeLog	2021-11-10 17:32:43 UTC (rev 285584)
@@ -1,3 +1,16 @@
+2021-11-10  Jer Noble  <[email protected]>
+
+        [iOS] Adopt -[AVAudioSession setAuditTokensForProcessAssertion:]
+        https://bugs.webkit.org/show_bug.cgi?id=232909
+        <rdar://68184444>
+
+        Reviewed by Eric Carlson.
+
+        * platform/audio/AudioSession.h:
+        * platform/audio/ios/AudioSessionIOS.h:
+        * platform/audio/ios/AudioSessionIOS.mm:
+        (WebCore::AudioSessionIOS::setPresentingProcesses):
+
 2021-11-10  Rob Buis  <[email protected]>
 
         [css-contain] Support contain:paint

Modified: trunk/Source/WebCore/PAL/ChangeLog (285583 => 285584)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-11-10 17:32:43 UTC (rev 285584)
@@ -1,3 +1,13 @@
+2021-11-10  Jer Noble  <[email protected]>
+
+        [iOS] Adopt -[AVAudioSession setAuditTokensForProcessAssertion:]
+        https://bugs.webkit.org/show_bug.cgi?id=232909
+        <rdar://68184444>
+
+        Reviewed by Eric Carlson.
+
+        * pal/spi/cocoa/AVFoundationSPI.h:
+
 2021-11-09  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] Migrate from CTFontCopyVariationAxes() to CTFontCopyVariationAxesInternal() if possible

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (285583 => 285584)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -402,6 +402,7 @@
 @property (readonly) BOOL eligibleForBTSmartRoutingConsideration;
 - (BOOL)setEligibleForBTSmartRoutingConsideration:(BOOL)inValue error:(NSError **)outError;
 - (BOOL)setHostProcessAttribution:(NSArray<NSString *>*)inHostProcessInfo error:(NSError **)outError SPI_AVAILABLE(ios(15.0), watchos(8.0), tvos(15.0)) API_UNAVAILABLE(macCatalyst, macos);
+- (BOOL)setAuditTokensForProcessAssertion:(NSArray<NSData *>*)inAuditTokens error:(NSError **)outError;
 @end
 
 NS_ASSUME_NONNULL_END

Modified: trunk/Source/WebCore/platform/audio/AudioSession.h (285583 => 285584)


--- trunk/Source/WebCore/platform/audio/AudioSession.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebCore/platform/audio/AudioSession.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -131,6 +131,7 @@
     static void setShouldManageAudioSessionCategory(bool flag) { s_shouldManageAudioSessionCategory = flag; }
 
     virtual void setHostProcessAttribution(audit_token_t) { };
+    virtual void setPresentingProcesses(Vector<audit_token_t>&&) { };
 
 protected:
     friend class NeverDestroyed<AudioSession>;

Modified: trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.h (285583 => 285584)


--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -43,6 +43,7 @@
     virtual ~AudioSessionIOS();
 
     void setHostProcessAttribution(audit_token_t) final;
+    void setPresentingProcesses(Vector<audit_token_t>&&) final;
 
     using CategoryChangedObserver = WTF::Observer<void(AudioSession&, CategoryType)>;
     WEBCORE_EXPORT static void addAudioSessionCategoryChangedObserver(const CategoryChangedObserver&);

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


--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2021-11-10 17:32:43 UTC (rev 285584)
@@ -167,7 +167,26 @@
 #endif
 };
 
+void AudioSessionIOS::setPresentingProcesses(Vector<audit_token_t>&& auditTokens)
+{
+#if !PLATFORM(MACCATALYST)
+    auto session = [PAL::getAVAudioSessionClass() sharedInstance];
+    if (![session respondsToSelector:@selector(setAuditTokensForProcessAssertion:error:)])
+        return;
 
+    auto nsAuditTokens = adoptNS([[NSMutableArray alloc] init]);
+    for (auto& token : auditTokens) {
+        auto nsToken = adoptNS([[NSData alloc] initWithBytes:token.val length:sizeof(token.val)]);
+        [nsAuditTokens addObject:nsToken.get()];
+    }
+
+    NSError *error = nil;
+    [session setAuditTokensForProcessAssertion:nsAuditTokens.get() error:&error];
+    if (error)
+        RELEASE_LOG_ERROR(Media, "Failed to set audit tokens for process assertion with error: %@", error.localizedDescription);
+#endif
+}
+
 void AudioSessionIOS::setCategory(CategoryType newCategory, RouteSharingPolicy policy)
 {
 #if !HAVE(ROUTE_SHARING_POLICY_LONG_FORM_VIDEO)

Modified: trunk/Source/WebKit/ChangeLog (285583 => 285584)


--- trunk/Source/WebKit/ChangeLog	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/ChangeLog	2021-11-10 17:32:43 UTC (rev 285584)
@@ -1,3 +1,55 @@
+2021-11-10  Jer Noble  <[email protected]>
+
+        [iOS] Adopt -[AVAudioSession setAuditTokensForProcessAssertion:]
+        https://bugs.webkit.org/show_bug.cgi?id=232909
+        <rdar://68184444>
+
+        Reviewed by Eric Carlson.
+
+        When a page is loaded through SafariViewService, the UIProcess is SVS, but the "presenting"
+        application is the client of SafariViewController. To further compliate things, multiple apps
+        all using a SafariViewController will use a singleton SafariViewService application. When such
+        an application goes to the background while playing audio, the audio subsystem will keep the
+        UIProcess from suspending, but not the presenting application. The audio subsystem will see
+        that the presenting application has become suspended, and will interrupt audio playback.
+
+        Opt into a AVAudioSession behavior where a client can provide an array of audit tokens for
+        those processes which are "presenting" the audio playback to the user. This will include the
+        UIProcess, but also the process which is hosting the SafariViewController. The audio subsystem
+        will keep the processes in that list from becoming suspended during audio playback.
+
+        Since there may be different clients of SafariViewService existing simultaneously, only include
+        those presenting application tokens whose WebContent processes require an "active" audio session.
+
+        * GPUProcess/GPUConnectionToWebProcess.cpp:
+        (WebKit::GPUConnectionToWebProcess::GPUConnectionToWebProcess):
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        (WebKit::GPUConnectionToWebProcess::presentingApplicationAuditToken const):
+        * GPUProcess/GPUProcess.cpp:
+        (WebKit::GPUProcess::audioSessionManager const):
+        * GPUProcess/media/RemoteAudioSessionProxy.cpp:
+        (WebKit::RemoteAudioSessionProxy::tryToSetActive):
+        * GPUProcess/media/RemoteAudioSessionProxy.h:
+        (WebKit::RemoteAudioSessionProxy::gpuConnectionToWebProcess const):
+        * GPUProcess/media/RemoteAudioSessionProxyManager.cpp:
+        (WebKit::RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager):
+        (WebKit::RemoteAudioSessionProxyManager::updatePresentingProcesses):
+        * GPUProcess/media/RemoteAudioSessionProxyManager.h:
+        * Scripts/process-entitlements.sh:
+        * Shared/GPUProcessConnectionParameters.h:
+        (WebKit::GPUProcessConnectionParameters::encode const):
+        (WebKit::GPUProcessConnectionParameters::decode):
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::copy):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration setPresentingApplicationProcessToken:]):
+        (-[_WKProcessPoolConfiguration presentingApplicationProcessToken]):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::getGPUProcessConnection):
+        * WebProcess/GPU/GPUProcessConnection.h:
+
 2021-11-10  Per Arne Vollan <[email protected]>
 
         [iOS][GPUP] Remove access to sysctl properties

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-11-10 17:32:43 UTC (rev 285584)
@@ -234,6 +234,9 @@
 #if ENABLE(MEDIA_STREAM)
     , m_captureOrigin(SecurityOrigin::createUnique())
 #endif
+#if HAVE(AUDIT_TOKEN)
+    , m_presentingApplicationAuditToken(WTFMove(parameters.presentingApplicationAuditToken))
+#endif
 #if ENABLE(ROUTING_ARBITRATION) && HAVE(AVAUDIO_ROUTING_ARBITER)
     , m_routingArbitrator(LocalAudioSessionRoutingArbitrator::create(*this))
 #endif

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -187,6 +187,10 @@
     using RemoteRenderingBackendMap = HashMap<RenderingBackendIdentifier, IPC::ScopedActiveMessageReceiveQueue<RemoteRenderingBackend>>;
     const RemoteRenderingBackendMap& remoteRenderingBackendMap() const { return m_remoteRenderingBackendMap; }
 
+#if HAVE(AUDIT_TOKEN)
+    const std::optional<audit_token_t>& presentingApplicationAuditToken() const { return m_presentingApplicationAuditToken; }
+#endif
+
 private:
     GPUConnectionToWebProcess(GPUProcess&, WebCore::ProcessIdentifier, IPC::Connection::Identifier, PAL::SessionID, GPUProcessConnectionParameters&&);
 
@@ -295,6 +299,9 @@
     bool m_allowsVideoCapture { false };
     bool m_allowsDisplayCapture { false };
 #endif
+#if HAVE(AUDIT_TOKEN)
+    std::optional<audit_token_t> m_presentingApplicationAuditToken;
+#endif
 
     RemoteRenderingBackendMap m_remoteRenderingBackendMap;
 #if ENABLE(WEBGL)

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-11-10 17:32:43 UTC (rev 285584)
@@ -410,7 +410,7 @@
 RemoteAudioSessionProxyManager& GPUProcess::audioSessionManager() const
 {
     if (!m_audioSessionManager)
-        m_audioSessionManager = WTF::makeUnique<RemoteAudioSessionProxyManager>();
+        m_audioSessionManager = WTF::makeUnique<RemoteAudioSessionProxyManager>(const_cast<GPUProcess&>(*this));
     return *m_audioSessionManager;
 }
 #endif

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp	2021-11-10 17:32:43 UTC (rev 285584)
@@ -92,6 +92,8 @@
 {
     m_active = audioSessionManager().tryToSetActiveForProcess(*this, active);
     completion(m_active);
+
+    audioSessionManager().updatePresentingProcesses();
 }
 
 void RemoteAudioSessionProxy::setIsPlayingToBluetoothOverride(std::optional<bool>&& value)

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -65,6 +65,8 @@
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) final;
 
+    GPUConnectionToWebProcess& gpuConnectionToWebProcess() const { return m_gpuConnection; }
+
 private:
     friend UniqueRef<RemoteAudioSessionProxy> WTF::makeUniqueRefWithoutFastMallocCheck<RemoteAudioSessionProxy>(GPUConnectionToWebProcess&);
     explicit RemoteAudioSessionProxy(GPUConnectionToWebProcess&);

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp	2021-11-10 17:32:43 UTC (rev 285584)
@@ -43,7 +43,8 @@
     return category == AudioSession::CategoryType::AmbientSound;
 }
 
-RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager()
+RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager(GPUProcess& gpuProcess)
+    : m_gpuProcess(gpuProcess)
 {
     AudioSession::sharedSession().addInterruptionObserver(*this);
     AudioSession::sharedSession().addConfigurationChangeObserver(*this);
@@ -175,6 +176,27 @@
     return true;
 }
 
+void RemoteAudioSessionProxyManager::updatePresentingProcesses()
+{
+    Vector<audit_token_t> presentingProcesses;
+
+    if (auto token = m_gpuProcess.parentProcessConnection()->getAuditToken())
+        presentingProcesses.append(*token);
+
+    // AVAudioSession will take out an assertion on all the "presenting applications"
+    // when it moves to a "playing" state. But it's possible that (e.g.) multiple
+    // applications may be using SafariViewService simultaneously. So only include
+    // tokens from those proxies whose sessions are currently "active". Only their
+    // presenting applications will be kept from becoming "suspended" during playback.
+    m_proxies.forEach([&](auto& proxy) {
+        if (!proxy.isActive())
+            return;
+        if (auto& token = proxy.gpuConnectionToWebProcess().presentingApplicationAuditToken())
+            presentingProcesses.append(*token);
+    });
+    AudioSession::sharedSession().setPresentingProcesses(WTFMove(presentingProcesses));
+}
+
 void RemoteAudioSessionProxyManager::beginAudioSessionInterruption()
 {
     m_proxies.forEach([](auto& proxy) {

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h (285583 => 285584)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -41,7 +41,7 @@
     , private WebCore::AudioSession::ConfigurationChangeObserver {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    RemoteAudioSessionProxyManager();
+    RemoteAudioSessionProxyManager(GPUProcess&);
     ~RemoteAudioSessionProxyManager();
 
     void addProxy(RemoteAudioSessionProxy&, std::optional<audit_token_t>);
@@ -55,6 +55,8 @@
     WebCore::AudioSession& session() { return WebCore::AudioSession::sharedSession(); }
     const WebCore::AudioSession& session() const { return WebCore::AudioSession::sharedSession(); }
 
+    void updatePresentingProcesses();
+
 private:
     void beginAudioSessionInterruption() final;
     void endAudioSessionInterruption(WebCore::AudioSession::MayResume) final;
@@ -64,6 +66,7 @@
     void sampleRateDidChange(const WebCore::AudioSession&) final;
     void configurationDidChange(const WebCore::AudioSession&);
 
+    GPUProcess& m_gpuProcess;
     WeakHashSet<RemoteAudioSessionProxy> m_proxies;
 };
 

Modified: trunk/Source/WebKit/Scripts/process-entitlements.sh (285583 => 285584)


--- trunk/Source/WebKit/Scripts/process-entitlements.sh	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/Scripts/process-entitlements.sh	2021-11-10 17:32:43 UTC (rev 285584)
@@ -308,6 +308,7 @@
     plistbuddy Add :com.apple.private.allow-explicit-graphics-priority bool YES
     plistbuddy Add :com.apple.private.coremedia.extensions.audiorecording.allow bool YES
     plistbuddy Add :com.apple.private.mediaexperience.startrecordinginthebackground.allow bool YES
+    plistbuddy Add :com.apple.private.mediaexperience.processassertionaudittokens.allow bool YES
     plistbuddy Add :com.apple.private.coremedia.pidinheritance.allow bool YES
     plistbuddy Add :com.apple.private.memorystatus bool YES
     plistbuddy Add :com.apple.private.memory.ownership_transfer bool YES

Modified: trunk/Source/WebKit/Shared/GPUProcessConnectionParameters.h (285583 => 285584)


--- trunk/Source/WebKit/Shared/GPUProcessConnectionParameters.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/Shared/GPUProcessConnectionParameters.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -39,6 +39,9 @@
 #if ENABLE(IPC_TESTING_API)
     bool ignoreInvalidMessageForTesting { false };
 #endif
+#if HAVE(AUDIT_TOKEN)
+    std::optional<audit_token_t> presentingApplicationAuditToken;
+#endif
 
     void encode(IPC::Encoder& encoder) const
     {
@@ -49,6 +52,9 @@
 #if ENABLE(IPC_TESTING_API)
         encoder << ignoreInvalidMessageForTesting;
 #endif
+#if HAVE(AUDIT_TOKEN)
+        encoder << presentingApplicationAuditToken;
+#endif
     }
 
     static std::optional<GPUProcessConnectionParameters> decode(IPC::Decoder& decoder)
@@ -72,6 +78,12 @@
             return std::nullopt;
 #endif
 
+#if HAVE(AUDIT_TOKEN)
+        std::optional<audit_token_t> presentingApplicationAuditToken;
+        if (!decoder.decode(presentingApplicationAuditToken))
+            return std::nullopt;
+#endif
+
         return GPUProcessConnectionParameters {
 #if HAVE(TASK_IDENTITY_TOKEN)
             WTFMove(*webProcessIdentityToken),
@@ -80,6 +92,9 @@
 #if ENABLE(IPC_TESTING_API)
             *ignoreInvalidMessageForTesting,
 #endif
+#if HAVE(AUDIT_TOKEN)
+            WTFMove(presentingApplicationAuditToken),
+#endif
         };
     }
 };

Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp (285583 => 285584)


--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp	2021-11-10 17:32:43 UTC (rev 285584)
@@ -81,6 +81,9 @@
 #if PLATFORM(GTK) || PLATFORM(WPE)
     copy->m_memoryPressureHandlerConfiguration = this->m_memoryPressureHandlerConfiguration;
 #endif
+#if HAVE(AUDIT_TOKEN)
+    copy->m_presentingApplicationProcessToken = this->m_presentingApplicationProcessToken;
+#endif
     return copy;
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h (285583 => 285584)


--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -119,6 +119,11 @@
     ProcessID presentingApplicationPID() const { return m_presentingApplicationPID; }
     void setPresentingApplicationPID(ProcessID pid) { m_presentingApplicationPID = pid; }
 
+#if HAVE(AUDIT_TOKEN)
+    const std::optional<audit_token_t> presentingApplicationProcessToken() const { return m_presentingApplicationProcessToken; }
+    void setPresentingApplicationProcessToken(std::optional<audit_token_t>&& token) { m_presentingApplicationProcessToken = WTFMove(token); }
+#endif
+
     bool processSwapsOnNavigation() const
     {
         return m_processSwapsOnNavigationFromClient.value_or(m_processSwapsOnNavigationFromExperimentalFeatures);
@@ -198,6 +203,9 @@
 #if PLATFORM(GTK) || PLATFORM(WPE)
     std::optional<MemoryPressureHandler::Configuration> m_memoryPressureHandlerConfiguration;
 #endif
+#if HAVE(AUDIT_TOKEN)
+    std::optional<audit_token_t> m_presentingApplicationProcessToken;
+#endif
 };
 
 } // namespace API

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h (285583 => 285584)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -64,6 +64,7 @@
 @property (nonatomic) BOOL shouldTakeUIBackgroundAssertion WK_API_AVAILABLE(ios(11.0));
 #endif
 @property (nonatomic) pid_t presentingApplicationPID WK_API_AVAILABLE(macos(10.13), ios(11.0));
+@property (nonatomic) audit_token_t presentingApplicationProcessToken WK_API_AVAILABLE(macos(10.13), ios(11.3));
 @property (nonatomic) BOOL processSwapsOnNavigation WK_API_AVAILABLE(macos(10.14), ios(12.0));
 @property (nonatomic) BOOL alwaysKeepAndReuseSwappedProcesses WK_API_AVAILABLE(macos(10.14), ios(12.0));
 @property (nonatomic) BOOL processSwapsOnWindowOpenWithOpener WK_API_AVAILABLE(macos(10.14), ios(12.0));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm (285583 => 285584)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2021-11-10 17:32:43 UTC (rev 285584)
@@ -235,6 +235,18 @@
     return _processPoolConfiguration->presentingApplicationPID();
 }
 
+- (void)setPresentingApplicationProcessToken:(audit_token_t)token
+{
+    _processPoolConfiguration->setPresentingApplicationProcessToken(token);
+}
+
+- (audit_token_t)presentingApplicationProcessToken
+{
+    if (_processPoolConfiguration->presentingApplicationProcessToken())
+        return *_processPoolConfiguration->presentingApplicationProcessToken();
+    return { };
+}
+
 - (void)setProcessSwapsOnNavigation:(BOOL)swaps
 {
     _processPoolConfiguration->setProcessSwapsOnNavigation(swaps);

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (285583 => 285584)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2021-11-10 17:32:43 UTC (rev 285584)
@@ -473,6 +473,11 @@
 #if ENABLE(IPC_TESTING_API)
     parameters.ignoreInvalidMessageForTesting = webProcessProxy.ignoreInvalidMessageForTesting();
 #endif
+
+#if HAVE(AUDIT_TOKEN)
+    parameters.presentingApplicationAuditToken = configuration().presentingApplicationProcessToken();
+#endif
+
     ensureGPUProcess().getGPUProcessConnection(webProcessProxy, parameters, [this, weakThis = WeakPtr { *this }, parameters, webProcessProxy = WeakPtr { webProcessProxy }, reply = WTFMove(reply)] (auto& connectionInfo) mutable {
         if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()))) {
             // Retry on the next RunLoop iteration because we may be inside the WebProcessPool destructor.

Modified: trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.h (285583 => 285584)


--- trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.h	2021-11-10 17:24:42 UTC (rev 285583)
+++ trunk/Source/WebKit/WebProcess/GPU/GPUProcessConnection.h	2021-11-10 17:32:43 UTC (rev 285584)
@@ -71,6 +71,8 @@
 #if HAVE(AUDIT_TOKEN)
     void setAuditToken(std::optional<audit_token_t> auditToken) { m_auditToken = auditToken; }
     std::optional<audit_token_t> auditToken() const { return m_auditToken; }
+
+    void setPresentingApplicationAuditToken(std::optional<audit_token_t>&&);
 #endif
 #if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
     SampleBufferDisplayLayerManager& sampleBufferDisplayLayerManager();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to