Changeset 258180 in webkit


Ignore:
Timestamp:
Mar 9, 2020 6:17:09 PM (4 years ago)
Author:
Chris Dumez
Message:

[iOS] Replace "unexpectedly resumed" observer with RunningBoard suspendible assertions
https://bugs.webkit.org/show_bug.cgi?id=205687
<rdar://problem/57890246>

Reviewed by Tim Horton.

Adopt new RunningBoard process assertion to indicate that WebContent processes depend on their
UIProcess (and therefore, the UIProcess must be running if the WebContent process is). This
replaces our "Unexpectedly resumed" assertion which was causing unexpected terminations in some
cases.

  • Configurations/WebKit.xcconfig:
  • Platform/spi/ios/RunningBoardServicesSPI.h: Added.
  • Scripts/process-entitlements.sh:
  • Shared/DependencyProcessAssertion.cpp: Added.

(WebKit::DependencyProcessAssertion::DependencyProcessAssertion):
(WebKit::DependencyProcessAssertion::~DependencyProcessAssertion):

  • Shared/DependencyProcessAssertion.h: Added.
  • Shared/ios/DependencyProcessAssertionIOS.mm: Added.

(WebKit::DependencyProcessAssertion::DependencyProcessAssertion):
(WebKit::DependencyProcessAssertion::~DependencyProcessAssertion):

  • Sources.txt:
  • SourcesCocoa.txt:
  • UIProcess/Cocoa/WebProcessProxyCocoa.mm:
  • UIProcess/WebProcessProxy.h:
  • UIProcess/WebProcessProxy.messages.in:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::initializeConnection):

  • WebProcess/WebProcess.h:
  • WebProcess/cocoa/WebProcessCocoa.mm:
Location:
trunk
Files:
5 added
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r258174 r258180  
     12020-03-09  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Replace "unexpectedly resumed" observer with RunningBoard suspendible assertions
     4        https://bugs.webkit.org/show_bug.cgi?id=205687
     5        <rdar://problem/57890246>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adopt new RunningBoard process assertion to indicate that WebContent processes depend on their
     10        UIProcess (and therefore, the UIProcess must be running if the WebContent process is). This
     11        replaces our "Unexpectedly resumed" assertion which was causing unexpected terminations in some
     12        cases.
     13
     14        * Configurations/WebKit.xcconfig:
     15        * Platform/spi/ios/RunningBoardServicesSPI.h: Added.
     16        * Scripts/process-entitlements.sh:
     17        * Shared/DependencyProcessAssertion.cpp: Added.
     18        (WebKit::DependencyProcessAssertion::DependencyProcessAssertion):
     19        (WebKit::DependencyProcessAssertion::~DependencyProcessAssertion):
     20        * Shared/DependencyProcessAssertion.h: Added.
     21        * Shared/ios/DependencyProcessAssertionIOS.mm: Added.
     22        (WebKit::DependencyProcessAssertion::DependencyProcessAssertion):
     23        (WebKit::DependencyProcessAssertion::~DependencyProcessAssertion):
     24        * Sources.txt:
     25        * SourcesCocoa.txt:
     26        * UIProcess/Cocoa/WebProcessProxyCocoa.mm:
     27        * UIProcess/WebProcessProxy.h:
     28        * UIProcess/WebProcessProxy.messages.in:
     29        * WebKit.xcodeproj/project.pbxproj:
     30        * WebProcess/WebProcess.cpp:
     31        (WebKit::WebProcess::initializeConnection):
     32        * WebProcess/WebProcess.h:
     33        * WebProcess/cocoa/WebProcessCocoa.mm:
     34
    1352020-03-09  Per Arne Vollan  <pvollan@apple.com>
    236
  • trunk/Source/WebKit/Configurations/WebKit.xcconfig

    r257085 r258180  
    5151WK_ASSERTION_SERVICES_LDFLAGS = $(WK_ASSERTION_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH));
    5252WK_ASSERTION_SERVICES_LDFLAGS_cocoatouch = -framework AssertionServices;
     53
     54WK_RUNNINGBOARD_SERVICES_LDFLAGS = $(WK_RUNNINGBOARD_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH));
     55WK_RUNNINGBOARD_SERVICES_LDFLAGS_cocoatouch = -framework RunningBoardServices;
    5356
    5457WK_CARBON_LDFLAGS = $(WK_CARBON_LDFLAGS_$(WK_PLATFORM_NAME));
     
    121124WK_AUTHKIT_LDFLAGS_MACOS_SINCE_1015 = -framework AuthKit;
    122125
    123 FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS);
     126FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_ASSERTION_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS);
    124127
    125128// Prevent C++ standard library basic_stringstream, operator new, delete and their related exception types from being exported as weak symbols.
  • trunk/Source/WebKit/Scripts/process-entitlements.sh

    r258013 r258180  
    141141    plistbuddy Add :com.apple.private.webinspector.allow-remote-inspection bool YES
    142142    plistbuddy Add :com.apple.private.webinspector.proxy-application bool YES
     143    plistbuddy Add :com.apple.runningboard.assertions.webkit bool YES
    143144    plistbuddy Add :dynamic-codesigning bool YES
    144145
  • trunk/Source/WebKit/Shared/DependencyProcessAssertion.h

    r258178 r258180  
    11/*
    2  * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "WebEvent.h"
    29 
    30 #if ENABLE(TOUCH_EVENTS)
     28#include <wtf/ProcessID.h>
     29#include <wtf/RetainPtr.h>
     30#include <wtf/text/ASCIILiteral.h>
    3131
    3232#if PLATFORM(IOS_FAMILY)
    33 #if defined(__OBJC__)
    34 #include <UIKit/UIKit.h>
    35 struct _UIWebTouchEvent;
     33OBJC_CLASS RBSAssertion;
    3634#endif
    37 #elif PLATFORM(GTK)
    38 #include <WebCore/GUniquePtrGtk.h>
    39 #elif USE(LIBWPE)
    40 #include <wpe/wpe.h>
    41 #endif
    42 
    43 #endif // ENABLE(TOUCH_EVENTS)
    4435
    4536namespace WebKit {
    4637
    47 #if ENABLE(TOUCH_EVENTS)
    48 
    49 class NativeWebTouchEvent : public WebTouchEvent {
     38class DependencyProcessAssertion {
     39    WTF_MAKE_FAST_ALLOCATED;
    5040public:
    51 #if PLATFORM(IOS_FAMILY)
    52 #if defined(__OBJC__)
    53     explicit NativeWebTouchEvent(const _UIWebTouchEvent*, UIKeyModifierFlags);
    54 #endif
    55 #elif PLATFORM(GTK)
    56     NativeWebTouchEvent(GdkEvent*, Vector<WebPlatformTouchPoint>&&);
    57     NativeWebTouchEvent(const NativeWebTouchEvent&);
    58     const GdkEvent* nativeEvent() const { return m_nativeEvent.get(); }
    59 #elif USE(LIBWPE)
    60     NativeWebTouchEvent(struct wpe_input_touch_event*, float deviceScaleFactor);
    61     const struct wpe_input_touch_event_raw* nativeFallbackTouchPoint() const { return &m_fallbackTouchPoint; }
    62 #elif PLATFORM(WIN)
    63     NativeWebTouchEvent();
    64 #endif
     41    DependencyProcessAssertion(ProcessID targetPID, ASCIILiteral description);
     42    ~DependencyProcessAssertion();
    6543
    6644private:
    67 #if PLATFORM(IOS_FAMILY) && defined(__OBJC__)
    68     Vector<WebPlatformTouchPoint> extractWebTouchPoint(const _UIWebTouchEvent*);
    69 #endif
    70 
    71 #if PLATFORM(GTK)
    72     GUniquePtr<GdkEvent> m_nativeEvent;
    73 #elif USE(LIBWPE)
    74     struct wpe_input_touch_event_raw m_fallbackTouchPoint;
     45#if PLATFORM(IOS_FAMILY)
     46    RetainPtr<RBSAssertion> m_assertion;
    7547#endif
    7648};
    7749
    78 #endif // ENABLE(TOUCH_EVENTS)
    79 
    80 #if PLATFORM(IOS_FAMILY) && defined(__OBJC__)
    81 OptionSet<WebEvent::Modifier> webEventModifierFlags(UIKeyModifierFlags);
    82 #endif
    83 
    8450} // namespace WebKit
  • trunk/Source/WebKit/Shared/NativeWebTouchEvent.h

    r255189 r258180  
    2828#include "WebEvent.h"
    2929
     30#if PLATFORM(IOS_FAMILY) && defined(__OBJC__)
     31#include <UIKit/UIKit.h>
     32#endif
     33
    3034#if ENABLE(TOUCH_EVENTS)
    3135
    3236#if PLATFORM(IOS_FAMILY)
    3337#if defined(__OBJC__)
    34 #include <UIKit/UIKit.h>
    3538struct _UIWebTouchEvent;
    3639#endif
  • trunk/Source/WebKit/Sources.txt

    r258122 r258180  
    157157Shared/ContextMenuContextData.cpp
    158158Shared/DebuggableInfoData.cpp
     159Shared/DependencyProcessAssertion.cpp
    159160Shared/EditingRange.cpp
    160161Shared/EditorState.cpp
  • trunk/Source/WebKit/SourcesCocoa.txt

    r258109 r258180  
    175175
    176176Shared/ios/AuxiliaryProcessIOS.mm
     177Shared/ios/DependencyProcessAssertionIOS.mm
    177178Shared/ios/InteractionInformationAtPosition.mm
    178179Shared/ios/InteractionInformationRequest.cpp
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm

    r258064 r258180  
    195195#endif
    196196
    197 #if PLATFORM(IOS_FAMILY)
    198 void WebProcessProxy::processWasResumed(CompletionHandler<void()>&& completionHandler)
    199 {
    200     CompletionHandlerCallingScope exitScope(WTFMove(completionHandler));
    201 
    202     if (m_throttler.shouldBeRunnable()) {
    203         // The process becoming unsuspended was not unexpected.
    204         return;
    205     }
    206 
    207     // The WebProcess was awakened by something other than the UIProcess. Take out an assertion for a
    208     // limited duration to allow whatever task needs to be accomplished time to complete.
    209     RELEASE_LOG(ProcessSuspension, "%p - WebProcessProxy::processWasResumed() Process was unexpectedly resumed, starting background activity", this);
    210     auto backgroundActivityTimeoutHandler = [activity = m_throttler.backgroundActivity("WebProcess was unexpectedly resumed"_s), weakThis = makeWeakPtr(this)] {
    211         RELEASE_LOG(ProcessSuspension, "%p - WebProcessProxy::processWasResumed() - lambda, background activity timed out", weakThis.get());
    212     };
    213     m_unexpectedActivityTimer = makeUnique<WebCore::DeferrableOneShotTimer>(WTFMove(backgroundActivityTimeoutHandler), unexpectedActivityDuration);
    214 }
    215 #endif
    216 
    217197#if ENABLE(REMOTE_INSPECTOR)
    218198void WebProcessProxy::enableRemoteInspectorIfNeeded()
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r258064 r258180  
    342342#endif
    343343
    344 #if PLATFORM(IOS_FAMILY)
    345     void processWasResumed(CompletionHandler<void()>&&);
    346 #endif
    347 
    348344    void webPageMediaStateDidChange(WebPageProxy&);
    349345
     
    532528    ForegroundWebProcessToken m_foregroundToken;
    533529    BackgroundWebProcessToken m_backgroundToken;
    534 #if PLATFORM(IOS_FAMILY)
    535     std::unique_ptr<WebCore::DeferrableOneShotTimer> m_unexpectedActivityTimer;
    536 #endif
    537530
    538531#if PLATFORM(COCOA)
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in

    r255189 r258180  
    7373#endif
    7474
    75 #if PLATFORM(IOS_FAMILY)
    76     ProcessWasResumed() -> () Async
    77 #endif
    78 
    7975    # Plug-in messages.
    8076    void AddPlugInAutoStartOriginHash(String pageOrigin, uint32_t hash)
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r258122 r258180  
    953953                46CE3B1123D8C8490016A96A /* WebBackForwardListCounts.h in Headers */ = {isa = PBXBuildFile; fileRef = 46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */; };
    954954                46DF063C1F3905F8001980BB /* NetworkCORSPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */; };
     955                46F38E8C2416E6730059375A /* RunningBoardServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 46F38E8B2416E66D0059375A /* RunningBoardServicesSPI.h */; };
    955956                46F9B26323526EF3006FE5FA /* WebBackForwardCacheEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 46F9B26223526ED0006FE5FA /* WebBackForwardCacheEntry.h */; };
    956957                4960A3BD23C52AFD00961842 /* WebViewCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 4960A3BC23C5286400961842 /* WebViewCategory.h */; };
     
    35533554                46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCORSPreflightChecker.cpp; sourceTree = "<group>"; };
    35543555                46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCORSPreflightChecker.h; sourceTree = "<group>"; };
     3556                46F38E882416D9630059375A /* DependencyProcessAssertion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DependencyProcessAssertion.cpp; sourceTree = "<group>"; };
     3557                46F38E892416D9630059375A /* DependencyProcessAssertion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DependencyProcessAssertion.h; sourceTree = "<group>"; };
     3558                46F38E8A2416D9A70059375A /* DependencyProcessAssertionIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DependencyProcessAssertionIOS.mm; path = ios/DependencyProcessAssertionIOS.mm; sourceTree = "<group>"; };
     3559                46F38E8B2416E66D0059375A /* RunningBoardServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunningBoardServicesSPI.h; sourceTree = "<group>"; };
    35553560                46F9B26223526ED0006FE5FA /* WebBackForwardCacheEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardCacheEntry.h; sourceTree = "<group>"; };
    35563561                4960A3BC23C5286400961842 /* WebViewCategory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewCategory.h; sourceTree = "<group>"; };
     
    59665971                                99036AE823A970870000B06A /* DebuggableInfoData.cpp */,
    59675972                                99036AE723A970870000B06A /* DebuggableInfoData.h */,
     5973                                46F38E882416D9630059375A /* DependencyProcessAssertion.cpp */,
     5974                                46F38E892416D9630059375A /* DependencyProcessAssertion.h */,
    59685975                                2D7FD190223C730F007887F1 /* DocumentEditingContext.h */,
    59695976                                2D7FD191223C7310007887F1 /* DocumentEditingContext.mm */,
     
    68926899                        children = (
    68936900                                A7E93CEB192531AA00A1DC48 /* AuxiliaryProcessIOS.mm */,
     6901                                46F38E8A2416D9A70059375A /* DependencyProcessAssertionIOS.mm */,
    68946902                                2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */,
    68956903                                2DA9449D1884E4F000ED86DB /* GestureTypes.h */,
     
    1028310291                                3178AF9720E2A7F80074DE94 /* PDFKitSPI.h */,
    1028410292                                2DC18FAF218912640025A88D /* PencilKitSPI.h */,
     10293                                46F38E8B2416E66D0059375A /* RunningBoardServicesSPI.h */,
    1028510294                                CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */,
    1028610295                                CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */,
     
    1097610985                                1A30066E1110F4F70031937C /* ResponsivenessTimer.h in Headers */,
    1097710986                                410482CE1DDD324F00F006D0 /* RTCNetwork.h in Headers */,
     10987                                46F38E8C2416E6730059375A /* RunningBoardServicesSPI.h in Headers */,
    1097810988                                0E97D74D200E900400BF6643 /* SafeBrowsingSPI.h in Headers */,
    1097910989                                5CA9854A210BEB640057EB6B /* SafeBrowsingWarning.h in Headers */,
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r258160 r258180  
    3232#include "AuthenticationManager.h"
    3333#include "AuxiliaryProcessMessages.h"
     34#include "DependencyProcessAssertion.h"
    3435#include "DrawingArea.h"
    3536#include "EventDispatcher.h"
     
    187188#define RELEASE_LOG_SESSION_ID (m_sessionID ? m_sessionID->toUInt64() : 0)
    188189#define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [sessionID=%" PRIu64 "] WebProcess::" fmt, this, RELEASE_LOG_SESSION_ID, ##__VA_ARGS__)
     190#define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [sessionID=%" PRIu64 "] WebProcess::" fmt, this, RELEASE_LOG_SESSION_ID, ##__VA_ARGS__)
    189191
    190192// This should be less than plugInAutoStartExpirationTimeThreshold in PlugInAutoStartProvider.
     
    296298#if PLATFORM(IOS_FAMILY)
    297299    m_viewUpdateDispatcher->initializeConnection(connection);
     300
     301    ASSERT(!m_uiProcessDependencyProcessAssertion);
     302    if (auto remoteProcessID = connection->remoteProcessID())
     303        m_uiProcessDependencyProcessAssertion = makeUnique<DependencyProcessAssertion>(remoteProcessID, "WebContent process dependency on UIProcess"_s);
     304    else
     305        RELEASE_LOG_ERROR_IF_ALLOWED(ProcessSuspension, "Unable to create a process depending assertion on UIProcess because remoteProcessID is 0");
    298306#endif // PLATFORM(IOS_FAMILY)
     307
    299308    m_webInspectorInterruptDispatcher->initializeConnection(connection);
    300309
     
    307316
    308317    m_webConnection = WebConnectionToUIProcess::create(this);
    309 
    310 #if PLATFORM(IOS_FAMILY)
    311     // Make sure we have an IPC::Connection before creating the ProcessTaskStateObserver since it may call
    312     // WebProcess::processTaskStateDidChange() on a background thread and deference the IPC connection.
    313     m_taskStateObserver = ProcessTaskStateObserver::create(*this);
    314 #endif
    315318}
    316319
     
    20452048#undef RELEASE_LOG_SESSION_ID
    20462049#undef RELEASE_LOG_IF_ALLOWED
     2050#undef RELEASE_LOG_ERROR_IF_ALLOWED
  • trunk/Source/WebKit/WebProcess/WebProcess.h

    r258064 r258180  
    6767#endif
    6868
    69 #if PLATFORM(IOS_FAMILY)
    70 #include "ProcessTaskStateObserver.h"
    71 OBJC_CLASS BKSProcessAssertion;
    72 #endif
    73 
    7469#if PLATFORM(WAYLAND) && USE(WPE_RENDERER)
    7570#include <WebCore/PlatformDisplayLibWPE.h>
     
    107102namespace WebKit {
    108103
     104class DependencyProcessAssertion;
    109105class EventDispatcher;
    110106class GamepadData;
     
    143139#endif
    144140
    145 class WebProcess
    146     : public AuxiliaryProcess
    147 #if PLATFORM(IOS_FAMILY)
    148     , ProcessTaskStateObserver::Client
    149 #endif
     141class WebProcess : public AuxiliaryProcess
    150142{
    151143    WTF_MAKE_FAST_ALLOCATED;
     
    502494
    503495#if PLATFORM(IOS_FAMILY)
    504     void processTaskStateDidChange(ProcessTaskStateObserver::TaskState) final;
    505496    bool shouldFreezeOnSuspension() const;
    506497    void updateFreezerStatus();
    507 
    508     void releaseProcessWasResumedAssertions();
    509498#endif
    510499
     
    594583#if PLATFORM(IOS_FAMILY)
    595584    WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker;
    596     RefPtr<ProcessTaskStateObserver> m_taskStateObserver;
    597     Lock m_processWasResumedAssertionsLock;
    598     RetainPtr<BKSProcessAssertion> m_processWasResumedUIAssertion;
    599     RetainPtr<BKSProcessAssertion> m_processWasResumedOwnAssertion;
     585    std::unique_ptr<DependencyProcessAssertion> m_uiProcessDependencyProcessAssertion;
    600586#endif
    601587
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r258168 r258180  
    101101#import "AccessibilitySupportSPI.h"
    102102#import "AssertionServicesSPI.h"
     103#import "RunningBoardServicesSPI.h"
    103104#import "UserInterfaceIdiom.h"
    104105#import "WKAccessibilityWebPageObjectIOS.h"
     
    377378
    378379#if PLATFORM(IOS_FAMILY)
    379 void WebProcess::processTaskStateDidChange(ProcessTaskStateObserver::TaskState taskState)
    380 {
    381     // NOTE: This will be called from a background thread.
    382     RELEASE_LOG(ProcessSuspension, "%p - WebProcess::processTaskStateDidChange() - taskState(%d)", this, taskState);
    383     if (taskState != ProcessTaskStateObserver::Running)
    384         return;
    385 
    386     LockHolder holder(m_processWasResumedAssertionsLock);
    387     if (m_processWasResumedUIAssertion && m_processWasResumedOwnAssertion)
    388         return;
    389 
    390     // We were awakened from suspension unexpectedly. Notify the WebProcessProxy, but take a process assertion on our parent PID
    391     // to ensure that it too is awakened.
    392     RELEASE_LOG(ProcessSuspension, "%p - WebProcess::processTaskStateChanged() Taking 'WebProcess was resumed' assertion on behalf on UIProcess", this);
    393     m_processWasResumedUIAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:parentProcessConnection()->remoteProcessID() flags:BKSProcessAssertionPreventTaskSuspend reason:BKSProcessAssertionReasonFinishTask name:@"WebProcess was resumed" withHandler:^(BOOL acquired) {
    394         if (!acquired)
    395             RELEASE_LOG_ERROR(ProcessSuspension, "%p - WebProcess::processTaskStateDidChange() failed to take 'WebProcess was resumed' assertion for parent process", this);
    396     }]);
    397     m_processWasResumedUIAssertion.get().invalidationHandler = [this] {
    398         RELEASE_LOG_ERROR(ProcessSuspension, "%p - WebProcess::processTaskStateChanged() Releasing 'WebProcess was resumed' assertion on behalf on UIProcess due to invalidation", this);
    399         releaseProcessWasResumedAssertions();
    400     };
    401     m_processWasResumedOwnAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:getpid() flags:BKSProcessAssertionPreventTaskSuspend reason:BKSProcessAssertionReasonFinishTask name:@"WebProcess was resumed" withHandler:^(BOOL acquired) {
    402         if (!acquired)
    403             RELEASE_LOG_ERROR(ProcessSuspension, "%p - WebProcess::processTaskStateDidChange() failed to take 'WebProcess was resumed' assertion for WebContent process", this);
    404     }]);
    405     m_processWasResumedOwnAssertion.get().invalidationHandler = [this] {
    406         RELEASE_LOG_ERROR(ProcessSuspension, "%p - WebProcess::processTaskStateChanged() Releasing 'WebProcess was resumed' assertion on behalf on WebContent process due to invalidation", this);
    407         releaseProcessWasResumedAssertions();
    408     };
    409 
    410     parentProcessConnection()->sendWithAsyncReply(Messages::WebProcessProxy::ProcessWasResumed(), [this] {
    411         RELEASE_LOG(ProcessSuspension, "%p - WebProcess::processTaskStateDidChange() Parent process handled ProcessWasResumed IPC, releasing our assertions", this);
    412         releaseProcessWasResumedAssertions();
    413     });
    414 }
    415 
    416 void WebProcess::releaseProcessWasResumedAssertions()
    417 {
    418     LockHolder holder(m_processWasResumedAssertionsLock);
    419     if (m_processWasResumedUIAssertion) {
    420         RELEASE_LOG(ProcessSuspension, "%p - WebProcess::releaseProcessWasResumedAssertions() Releasing parent process 'WebProcess was resumed' assertion", this);
    421         [m_processWasResumedUIAssertion invalidate];
    422         m_processWasResumedUIAssertion = nullptr;
    423     }
    424     if (m_processWasResumedOwnAssertion) {
    425         RELEASE_LOG(ProcessSuspension, "%p - WebProcess::releaseProcessWasResumedAssertions() Releasing WebContent process 'WebProcess was resumed' assertion", this);
    426         [m_processWasResumedOwnAssertion invalidate];
    427         m_processWasResumedOwnAssertion = nullptr;
    428     }
    429 }
    430 
    431 #endif
    432 
    433 #if PLATFORM(IOS_FAMILY)
    434380static NSString *webProcessLoaderAccessibilityBundlePath()
    435381{
Note: See TracChangeset for help on using the changeset viewer.