Changeset 231771 in webkit


Ignore:
Timestamp:
May 14, 2018 3:31:40 PM (6 years ago)
Author:
Chris Dumez
Message:

Overly aggressive timer throttling in service workers
https://bugs.webkit.org/show_bug.cgi?id=185575
<rdar://problem/40219038>

Reviewed by Geoff Garen.

After ~30 seconds, the system would put the service worker process in "App Nap",
causing its timers to get aggressively throttled. This happens because the
service worker processes are WebProcesses that have no visible WebPages.

To address the issue, we now disable process suppression for all service worker
processes. This causes those processes to construct a UserActivity which prevents
App Nap.

This patch also refactors the code a bit to avoid duplication. The ProcessSuppression
suppression logic in now all on ChildProcessProxy / ChildProcess.

  • NetworkProcess/NetworkProcess.messages.in:
  • PluginProcess/PluginProcess.messages.in:
  • Shared/ChildProcess.messages.in:
  • UIProcess/ChildProcessProxy.cpp:

(WebKit::ChildProcessProxy::setProcessSuppressionEnabled):

  • UIProcess/ChildProcessProxy.h:
  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/Network/mac/NetworkProcessProxyMac.mm: Removed.
  • UIProcess/Plugins/PluginProcessProxy.h:
  • UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
  • UIProcess/ServiceWorkerProcessProxy.cpp:

(WebKit::ServiceWorkerProcessProxy::didFinishLaunching):

  • UIProcess/ServiceWorkerProcessProxy.h:
  • UIProcess/WebProcessProxy.h:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/WebProcess.messages.in:
Location:
trunk/Source/WebKit
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r231770 r231771  
     12018-05-14  Chris Dumez  <cdumez@apple.com>
     2
     3        Overly aggressive timer throttling in service workers
     4        https://bugs.webkit.org/show_bug.cgi?id=185575
     5        <rdar://problem/40219038>
     6
     7        Reviewed by Geoff Garen.
     8
     9        After ~30 seconds, the system would put the service worker process in "App Nap",
     10        causing its timers to get aggressively throttled. This happens because the
     11        service worker processes are WebProcesses that have no visible WebPages.
     12
     13        To address the issue, we now disable process suppression for all service worker
     14        processes. This causes those processes to construct a UserActivity which prevents
     15        App Nap.
     16
     17        This patch also refactors the code a bit to avoid duplication. The ProcessSuppression
     18        suppression logic in now all on ChildProcessProxy / ChildProcess.
     19
     20        * NetworkProcess/NetworkProcess.messages.in:
     21        * PluginProcess/PluginProcess.messages.in:
     22        * Shared/ChildProcess.messages.in:
     23        * UIProcess/ChildProcessProxy.cpp:
     24        (WebKit::ChildProcessProxy::setProcessSuppressionEnabled):
     25        * UIProcess/ChildProcessProxy.h:
     26        * UIProcess/Network/NetworkProcessProxy.h:
     27        * UIProcess/Network/mac/NetworkProcessProxyMac.mm: Removed.
     28        * UIProcess/Plugins/PluginProcessProxy.h:
     29        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
     30        * UIProcess/ServiceWorkerProcessProxy.cpp:
     31        (WebKit::ServiceWorkerProcessProxy::didFinishLaunching):
     32        * UIProcess/ServiceWorkerProcessProxy.h:
     33        * UIProcess/WebProcessProxy.h:
     34        * WebKit.xcodeproj/project.pbxproj:
     35        * WebProcess/WebProcess.messages.in:
     36
    1372018-05-14  Andy Estes  <aestes@apple.com>
    238
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r231536 r231771  
    5353    ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle, bool allowOverwrite)
    5454
    55     SetProcessSuppressionEnabled(bool flag)
    5655#if PLATFORM(COCOA)
    5756    SetQOS(int latencyQOS, int throughputQOS)
  • trunk/Source/WebKit/PluginProcess/PluginProcess.messages.in

    r226349 r231771  
    3939    DeleteWebsiteDataForHostNames(Vector<String> hostNames, uint64_t callbackID)
    4040
    41     SetProcessSuppressionEnabled(bool flag)
    4241#if PLATFORM(COCOA)
    4342    SetQOS(int latencyQOS, int throughputQOS)
  • trunk/Source/WebKit/Shared/ChildProcess.messages.in

    r226088 r231771  
    2424    ShutDown()
    2525    RegisterURLSchemeServiceWorkersCanHandle(String scheme)
     26    SetProcessSuppressionEnabled(bool flag)
    2627}
  • trunk/Source/WebKit/UIProcess/ChildProcessProxy.cpp

    r230084 r231771  
    214214}
    215215
     216void ChildProcessProxy::setProcessSuppressionEnabled(bool processSuppressionEnabled)
     217{
     218#if PLATFORM(COCOA)
     219    if (state() != State::Running)
     220        return;
     221
     222    connection()->send(Messages::ChildProcess::SetProcessSuppressionEnabled(processSuppressionEnabled), 0);
     223#else
     224    UNUSED_PARAM(processSuppressionEnabled);
     225#endif
     226}
     227
    216228void ChildProcessProxy::connectionWillOpen(IPC::Connection&)
    217229{
  • trunk/Source/WebKit/UIProcess/ChildProcessProxy.h

    r226308 r231771  
    8484    WebCore::ProcessIdentifier coreProcessIdentifier() const { return m_processIdentifier; }
    8585
     86    void setProcessSuppressionEnabled(bool);
     87
    8688protected:
    8789    // ProcessLauncher::Client
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r231536 r231771  
    7676    void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, WTF::Function<void()>&& completionHandler);
    7777    void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, WTF::Function<void()>&& completionHandler);
    78 
    79 #if PLATFORM(COCOA)
    80     void setProcessSuppressionEnabled(bool);
    81 #endif
    8278
    8379#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
  • trunk/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.h

    r230293 r231771  
    8484
    8585    bool isValid() const { return m_connection; }
    86 
    87 #if PLATFORM(COCOA)
    88     void setProcessSuppressionEnabled(bool);
    89 
    90 #endif
    9186
    9287#if PLUGIN_ARCHITECTURE(UNIX)
  • trunk/Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm

    r230468 r231771  
    231231}
    232232
    233 void PluginProcessProxy::setProcessSuppressionEnabled(bool processSuppressionEnabled)
    234 {
    235     if (!isValid())
    236         return;
    237 
    238     m_connection->send(Messages::PluginProcess::SetProcessSuppressionEnabled(processSuppressionEnabled), 0);
    239 }
    240 
    241233static bool isFlashUpdater(const String& launchPath, const Vector<String>& arguments)
    242234{
  • trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp

    r230977 r231771  
    106106}
    107107
     108void ServiceWorkerProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
     109{
     110    WebProcessProxy::didFinishLaunching(launcher, connectionIdentifier);
     111
     112    // Prevent App Nap for Service Worker processes.
     113    // FIXME: Ideally, the Service Worker process would app nap when all its clients app nap (http://webkit.org/b/185626).
     114    setProcessSuppressionEnabled(false);
     115}
     116
    108117} // namespace WebKit
    109118
  • trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h

    r229979 r231771  
    5555    void getLaunchOptions(ProcessLauncher::LaunchOptions&) final;
    5656
     57    // ProcessLauncher::Client
     58    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) final;
     59
    5760    bool isServiceWorkerProcess() const final { return true; }
    5861
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r231321 r231771  
    231231    void processWillShutDown(IPC::Connection&) override;
    232232
     233    // ProcessLauncher::Client
     234    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
     235
    233236private:
    234237    // Called when the web process has crashed or we know that it will terminate soon.
     
    294297    void didSetAssertionState(AssertionState) override;
    295298
    296     // ProcessLauncher::Client
    297     void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
    298 
    299299    // Implemented in generated WebProcessProxyMessageReceiver.cpp
    300300    void didReceiveWebProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r231510 r231771  
    10751075                515E7728183DD6F60007203F /* AsyncRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E7726183DD6F60007203F /* AsyncRequest.h */; };
    10761076                5160BFE113381DF900918999 /* LoggingFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160BFE013381DF900918999 /* LoggingFoundation.mm */; };
    1077                 516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */; };
    10781077                5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ACC9341628064800342550 /* NetworkProcessMessageReceiver.cpp */; };
    10791078                5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ACC9351628064800342550 /* NetworkProcessMessages.h */; };
     
    20732072                CDC2831D201BD79D00E6E745 /* WKFullscreenStackView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */; };
    20742073                CDC2831E201BD79D00E6E745 /* WKFullscreenStackView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */; };
    2075                 CDC382FE17211799008A2FC3 /* SecItemShimLibrary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 511F8A78138B460900A95F44 /* SecItemShimLibrary.mm */; };
    20762074                CDCA85C8132ABA4E00E961DF /* WKFullScreenWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */; };
    20772075                CDCA85C9132ABA4E00E961DF /* WKFullScreenWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */; };
     
    34903488                515E7726183DD6F60007203F /* AsyncRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncRequest.h; sourceTree = "<group>"; };
    34913489                5160BFE013381DF900918999 /* LoggingFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingFoundation.mm; sourceTree = "<group>"; };
    3492                 516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessProxyMac.mm; path = mac/NetworkProcessProxyMac.mm; sourceTree = "<group>"; };
    34933490                5164C0941B05B757004F102A /* ChildProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChildProcess.messages.in; sourceTree = "<group>"; };
    34943491                516A4A5B120A2CCD00C05B7F /* APIError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIError.h; sourceTree = "<group>"; };
     
    46064603                CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFullscreenStackView.mm; path = ios/fullscreen/WKFullscreenStackView.mm; sourceTree = "<group>"; };
    46074604                CDC382F717211506008A2FC3 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = /System/Library/Frameworks/CFNetwork.framework; sourceTree = "<absolute>"; };
    4608                 CDC3830617211799008A2FC3 /* WebProcessShim.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = WebProcessShim.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
    46094605                CDC8F4881725E67800166F6E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
    46104606                CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFullScreenWindowController.mm; sourceTree = "<group>"; };
     
    65906586                        isa = PBXGroup;
    65916587                        children = (
    6592                                 516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */,
    65936588                        );
    65946589                        name = mac;
     
    1070510700                                E14A954916E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp in Sources */,
    1070610701                                5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */,
    10707                                 516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */,
    1070810702                                513A163C163088F6005D7D22 /* NetworkProcessProxyMessageReceiver.cpp in Sources */,
    1070910703                                51FD18B51651FBAD00DBE1CE /* NetworkResourceLoader.cpp in Sources */,
     
    1145111445                        runOnlyForDeploymentPostprocessing = 0;
    1145211446                };
    11453                 CDC382FD17211799008A2FC3 /* Sources */ = {
    11454                         isa = PBXSourcesBuildPhase;
    11455                         buildActionMask = 2147483647;
    11456                         files = (
    11457                                 CDC382FE17211799008A2FC3 /* SecItemShimLibrary.mm in Sources */,
    11458                         );
    11459                         runOnlyForDeploymentPostprocessing = 0;
    11460                 };
    1146111447/* End PBXSourcesBuildPhase section */
    1146211448
  • trunk/Source/WebKit/WebProcess/WebProcess.messages.in

    r230640 r231771  
    8585
    8686    SetHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds)
    87     SetProcessSuppressionEnabled(bool flag)
    8887#if PLATFORM(COCOA)
    8988    SetQOS(int latencyQOS, int throughputQOS)
Note: See TracChangeset for help on using the changeset viewer.