Title: [273082] trunk/Source
Revision
273082
Author
pvol...@apple.com
Date
2021-02-18 10:18:30 -0800 (Thu, 18 Feb 2021)

Log Message

[macOS] Observe system sleep events in the UI process
https://bugs.webkit.org/show_bug.cgi?id=221996
<rdar://problem/74406570>

Reviewed by Chris Dumez.

Source/WebCore:

System sleep events should be observed in the UI process, which should notify the WebContent process.

* platform/audio/PlatformMediaSessionManager.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::MediaSessionManagerCocoa):

Source/WebCore/PAL:

Export symbols, since the system sleep listener will be instantiated in the UI process.

* pal/system/SystemSleepListener.h:

Source/WebKit:

System sleep events should be observed in the UI process, which should notify the WebContent process.

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::registerNotificationObservers):
(WebKit::WebProcessPool::unregisterNotificationObservers):
(WebKit::WebProcessPool::systemWillSleep):
(WebKit::WebProcessPool::systemDidWake):
* UIProcess/WebProcessPool.h:
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::systemWillSleep):
(WebKit::WebProcess::systemDidWake):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273081 => 273082)


--- trunk/Source/WebCore/ChangeLog	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebCore/ChangeLog	2021-02-18 18:18:30 UTC (rev 273082)
@@ -1,3 +1,18 @@
+2021-02-18  Per Arne  <pvol...@apple.com>
+
+        [macOS] Observe system sleep events in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=221996
+        <rdar://problem/74406570>
+
+        Reviewed by Chris Dumez.
+
+        System sleep events should be observed in the UI process, which should notify the WebContent process.
+
+        * platform/audio/PlatformMediaSessionManager.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+        * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+        (WebCore::MediaSessionManagerCocoa::MediaSessionManagerCocoa):
+
 2021-02-18  Alex Christensen  <achristen...@webkit.org>
 
         Disable RangeResponseGenerator again.

Modified: trunk/Source/WebCore/PAL/ChangeLog (273081 => 273082)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-02-18 18:18:30 UTC (rev 273082)
@@ -1,3 +1,15 @@
+2021-02-18  Per Arne  <pvol...@apple.com>
+
+        [macOS] Observe system sleep events in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=221996
+        <rdar://problem/74406570>
+
+        Reviewed by Chris Dumez.
+
+        Export symbols, since the system sleep listener will be instantiated in the UI process.
+
+        * pal/system/SystemSleepListener.h:
+
 2021-02-15  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Unreviewed, fix the Apple internal iOS build after r272878

Modified: trunk/Source/WebCore/PAL/pal/system/SystemSleepListener.h (273081 => 273082)


--- trunk/Source/WebCore/PAL/pal/system/SystemSleepListener.h	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebCore/PAL/pal/system/SystemSleepListener.h	2021-02-18 18:18:30 UTC (rev 273082)
@@ -36,7 +36,7 @@
         virtual void systemDidWake() = 0;
     };
 
-    static std::unique_ptr<SystemSleepListener> create(Client&);
+    PAL_EXPORT static std::unique_ptr<SystemSleepListener> create(Client&);
     virtual ~SystemSleepListener() = default;
 
     Client& client() { return m_client; }

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (273081 => 273082)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2021-02-18 18:18:30 UTC (rev 273082)
@@ -157,6 +157,9 @@
     virtual void addSupportedCommand(PlatformMediaSession::RemoteControlCommandType) { };
     virtual void removeSupportedCommand(PlatformMediaSession::RemoteControlCommandType) { };
 
+    WEBCORE_EXPORT void processSystemWillSleep();
+    WEBCORE_EXPORT void processSystemDidWake();
+
 protected:
     friend class PlatformMediaSession;
     PlatformMediaSessionManager();
@@ -184,9 +187,6 @@
 
     bool computeSupportsSeeking() const;
 
-    WEBCORE_EXPORT void processSystemWillSleep();
-    WEBCORE_EXPORT void processSystemDidWake();
-
 private:
     friend class Internals;
 

Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (273081 => 273082)


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h	2021-02-18 18:18:30 UTC (rev 273082)
@@ -31,7 +31,6 @@
 #include "GenericTaskQueue.h"
 #include "PlatformMediaSessionManager.h"
 #include "RemoteCommandListener.h"
-#include <pal/system/SystemSleepListener.h>
 
 namespace WebCore {
 
@@ -40,7 +39,6 @@
 class MediaSessionManagerCocoa
     : public PlatformMediaSessionManager
     , private RemoteCommandListenerClient
-    , private PAL::SystemSleepListener::Client
     , private AudioHardwareListener::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -100,10 +98,6 @@
     void audioHardwareDidBecomeInactive() final { }
     void audioOutputDeviceChanged() final;
 
-    // PAL::SystemSleepListener
-    void systemWillSleep() final { processSystemWillSleep(); }
-    void systemDidWake() final { processSystemDidWake(); }
-
     bool m_nowPlayingActive { false };
     bool m_registeredAsNowPlayingApplication { false };
     bool m_haveEverRegisteredAsNowPlayingApplication { false };
@@ -117,7 +111,6 @@
     GenericTaskQueue<Timer> m_taskQueue;
 
     std::unique_ptr<RemoteCommandListener> m_remoteCommandListener;
-    std::unique_ptr<PAL::SystemSleepListener> m_systemSleepListener;
     RefPtr<AudioHardwareListener> m_audioHardwareListener;
 };
 

Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (273081 => 273082)


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2021-02-18 18:18:30 UTC (rev 273082)
@@ -55,7 +55,6 @@
 #endif // !PLATFORM(MAC)
 
 MediaSessionManagerCocoa::MediaSessionManagerCocoa()
-    : m_systemSleepListener(PAL::SystemSleepListener::create(*this))
 {
 }
 

Modified: trunk/Source/WebKit/ChangeLog (273081 => 273082)


--- trunk/Source/WebKit/ChangeLog	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebKit/ChangeLog	2021-02-18 18:18:30 UTC (rev 273082)
@@ -1,3 +1,25 @@
+2021-02-18  Per Arne  <pvol...@apple.com>
+
+        [macOS] Observe system sleep events in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=221996
+        <rdar://problem/74406570>
+
+        Reviewed by Chris Dumez.
+
+        System sleep events should be observed in the UI process, which should notify the WebContent process.
+
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::registerNotificationObservers):
+        (WebKit::WebProcessPool::unregisterNotificationObservers):
+        (WebKit::WebProcessPool::systemWillSleep):
+        (WebKit::WebProcessPool::systemDidWake):
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::systemWillSleep):
+        (WebKit::WebProcess::systemDidWake):
+
 2021-02-18  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         WebGL contexts do not work as source for Context2D drawImage calls in GPU process

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (273081 => 273082)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-02-18 18:18:30 UTC (rev 273082)
@@ -630,6 +630,7 @@
         if (weakThis)
             weakThis->sendToAllProcesses(Messages::WebProcess::SystemWillPowerOn());
     });
+    m_systemSleepListener = PAL::SystemSleepListener::create(*this);
     // Listen for enhanced accessibility changes and propagate them to the WebProcess.
     m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
         setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]);
@@ -728,6 +729,7 @@
 {
 #if !PLATFORM(IOS_FAMILY)
     m_powerObserver = nullptr;
+    m_systemSleepListener = nullptr;
     [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
@@ -937,6 +939,17 @@
         PAL::softLink_CoreMedia_CMNotificationCenterAddListener(center, object, webProcessPoolHighDynamicRangeDidChangeCallback, notification, object, 0);
     });
 }
+
+void WebProcessPool::systemWillSleep()
+{
+    sendToAllProcesses(Messages::WebProcess::SystemWillSleep());
+}
+
+void WebProcessPool::systemDidWake()
+{
+    sendToAllProcesses(Messages::WebProcess::SystemDidWake());
+}
+
 #endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (273081 => 273082)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2021-02-18 18:18:30 UTC (rev 273082)
@@ -71,6 +71,7 @@
 
 #if PLATFORM(MAC)
 #import <WebCore/PowerObserverMac.h>
+#import <pal/system/SystemSleepListener.h>
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
 #include "DisplayLink.h"
 #endif
@@ -123,7 +124,14 @@
 enum class CallDownloadDidStart : bool;
 enum class ProcessSwapRequestedByClient : bool;
 
-class WebProcessPool final : public API::ObjectImpl<API::Object::Type::ProcessPool>, public CanMakeWeakPtr<WebProcessPool>, private IPC::MessageReceiver {
+class WebProcessPool final
+    : public API::ObjectImpl<API::Object::Type::ProcessPool>
+    , public CanMakeWeakPtr<WebProcessPool>
+    , private IPC::MessageReceiver
+#if PLATFORM(MAC)
+    , private PAL::SystemSleepListener::Client
+#endif
+{
 public:
     static Ref<WebProcessPool> create(API::ProcessPoolConfiguration&);
 
@@ -578,6 +586,12 @@
 
     static void registerHighDynamicRangeChangeCallback();
 
+#if PLATFORM(MAC)
+    // PAL::SystemSleepListener
+    void systemWillSleep() final;
+    void systemDidWake() final;
+#endif
+
     Ref<API::ProcessPoolConfiguration> m_configuration;
 
     IPC::MessageReceiverMap m_messageReceiverMap;
@@ -778,6 +792,7 @@
     
 #if PLATFORM(MAC)
     std::unique_ptr<WebCore::PowerObserver> m_powerObserver;
+    std::unique_ptr<PAL::SystemSleepListener> m_systemSleepListener;
 #endif
 };
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (273081 => 273082)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2021-02-18 18:18:30 UTC (rev 273082)
@@ -513,6 +513,8 @@
 
 #if PLATFORM(MAC)
     void systemWillPowerOn();
+    void systemWillSleep();
+    void systemDidWake();
 #endif
     
     void platformInitializeProcess(const AuxiliaryProcessInitializationParameters&);

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (273081 => 273082)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2021-02-18 18:18:30 UTC (rev 273082)
@@ -198,5 +198,7 @@
 
 #if PLATFORM(MAC)
     SystemWillPowerOn()
+    SystemWillSleep()
+    SystemDidWake()
 #endif
 }

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (273081 => 273082)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-02-18 17:52:28 UTC (rev 273081)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-02-18 18:18:30 UTC (rev 273082)
@@ -1212,6 +1212,18 @@
 {
     MainThreadSharedTimer::restartSharedTimer();
 }
+
+void WebProcess::systemWillSleep()
+{
+    if (PlatformMediaSessionManager::sharedManagerIfExists())
+        PlatformMediaSessionManager::sharedManager().processSystemWillSleep();
+}
+
+void WebProcess::systemDidWake()
+{
+    if (PlatformMediaSessionManager::sharedManagerIfExists())
+        PlatformMediaSessionManager::sharedManager().processSystemDidWake();
+}
 #endif
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to