Skip to content

Commit

Permalink
Unreviewed, reverting 275195@main.
Browse files Browse the repository at this point in the history
  • Loading branch information
webkit-commit-queue authored and pvollan committed Feb 23, 2024
1 parent 598136f commit 4d395e8
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 33 deletions.
12 changes: 1 addition & 11 deletions Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ static Seconds adjustedTimeoutForThermalState(Seconds timeout)
#endif
}

AuxiliaryProcessProxy::AuxiliaryProcessProxy(bool shouldTakeUIBackgroundAssertion, bool alwaysRunsAtBackgroundPriority, Seconds responsivenessTimeout)
AuxiliaryProcessProxy::AuxiliaryProcessProxy(bool alwaysRunsAtBackgroundPriority, Seconds responsivenessTimeout)
: m_responsivenessTimer(*this, adjustedTimeoutForThermalState(responsivenessTimeout))
, m_alwaysRunsAtBackgroundPriority(alwaysRunsAtBackgroundPriority)
, m_throttler(*this, shouldTakeUIBackgroundAssertion)
#if USE(RUNNINGBOARD)
, m_timedActivityForIPC(3_s)
#endif
Expand Down Expand Up @@ -349,15 +348,6 @@ void AuxiliaryProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::C
else
connection->sendMessage(WTFMove(pendingMessage.encoder), pendingMessage.sendOptions);
}

#if USE(RUNNINGBOARD)
m_throttler.didConnectToProcess(*this);
#if USE(EXTENSIONKIT)
ASSERT(launcher);
if (launcher)
launcher->releaseLaunchGrant();
#endif // USE(EXTENSIONKIT)
#endif // USE(RUNNINGBOARD)
}

void AuxiliaryProcessProxy::outgoingMessageQueueIsGrowingLarge()
Expand Down
7 changes: 3 additions & 4 deletions Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AuxiliaryProcessProxy
WTF_MAKE_NONCOPYABLE(AuxiliaryProcessProxy);

protected:
AuxiliaryProcessProxy(bool shouldTakeUIBackgroundAssertion, bool alwaysRunsAtBackgroundPriority = false, Seconds responsivenessTimeout = ResponsivenessTimer::defaultResponsivenessTimeout);
AuxiliaryProcessProxy(bool alwaysRunsAtBackgroundPriority = false, Seconds responsivenessTimeout = ResponsivenessTimer::defaultResponsivenessTimeout);

public:
using ResponsivenessTimer::Client::weakPtrFactory;
Expand All @@ -81,8 +81,8 @@ class AuxiliaryProcessProxy
void connect();
virtual void terminate();

ProcessThrottler& throttler() { return m_throttler; }
const ProcessThrottler& throttler() const { return m_throttler; }
virtual ProcessThrottler& throttler() = 0;
virtual const ProcessThrottler& throttler() const = 0;

template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions = { });

Expand Down Expand Up @@ -275,7 +275,6 @@ class AuxiliaryProcessProxy
WebCore::ProcessIdentifier m_processIdentifier { WebCore::ProcessIdentifier::generate() };
std::optional<UseLazyStop> m_delayedResponsivenessCheck;
MonotonicTime m_processStart;
ProcessThrottler m_throttler;
#if USE(RUNNINGBOARD)
ProcessThrottler::TimedActivity m_timedActivityForIPC;
#if PLATFORM(MAC)
Expand Down
13 changes: 12 additions & 1 deletion Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ static String gpuProcessCachesDirectory()
#endif

GPUProcessProxy::GPUProcessProxy()
: AuxiliaryProcessProxy(WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
: AuxiliaryProcessProxy()
, m_throttler(*this, WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
#if ENABLE(MEDIA_STREAM)
, m_useMockCaptureDevices(MockRealtimeMediaSourceCenter::mockRealtimeMediaSourceCenterEnabled())
#endif
Expand Down Expand Up @@ -588,6 +589,16 @@ void GPUProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connect
return;
}

#if USE(RUNNINGBOARD)
m_throttler.didConnectToProcess(*this);
#if USE(EXTENSIONKIT)
// FIXME: this should be moved to AuxiliaryProcessProxy::didFinishLaunching along with m_throttler.didConnectToProcess.
// This FIXME applies to all process proxy subclasses.
if (launcher)
launcher->releaseLaunchGrant();
#endif
#endif

#if PLATFORM(COCOA)
if (auto networkProcess = NetworkProcessProxy::defaultNetworkProcess())
networkProcess->sendXPCEndpointToProcess(*this);
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/UIProcess/GPU/GPUProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class GPUProcessProxy final : public AuxiliaryProcessProxy {

void createGPUProcessConnection(WebProcessProxy&, IPC::Connection::Handle&&, GPUProcessConnectionParameters&&);

ProcessThrottler& throttler() final { return m_throttler; }
const ProcessThrottler& throttler() const final { return m_throttler; }

void updateProcessAssertion();

#if ENABLE(MEDIA_STREAM)
Expand Down Expand Up @@ -179,6 +182,7 @@ class GPUProcessProxy final : public AuxiliaryProcessProxy {
GPUProcessCreationParameters processCreationParameters();
void platformInitializeGPUProcessParameters(GPUProcessCreationParameters&);

ProcessThrottler m_throttler;
ProcessThrottler::ActivityVariant m_activityFromWebProcesses;
#if ENABLE(MEDIA_STREAM)
bool m_useMockCaptureDevices { false };
Expand Down
11 changes: 10 additions & 1 deletion Source/WebKit/UIProcess/Model/ModelProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ ModelProcessProxy* ModelProcessProxy::singletonIfCreated()
}

ModelProcessProxy::ModelProcessProxy()
: AuxiliaryProcessProxy(WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
: AuxiliaryProcessProxy()
, m_throttler(*this, WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
{
connect();

Expand Down Expand Up @@ -218,6 +219,14 @@ void ModelProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Conne
return;
}

#if USE(RUNNINGBOARD)
m_throttler.didConnectToProcess(*this);
#if USE(EXTENSIONKIT)
if (launcher)
launcher->releaseLaunchGrant();
#endif
#endif

#if PLATFORM(COCOA)
if (auto networkProcess = NetworkProcessProxy::defaultNetworkProcess())
networkProcess->sendXPCEndpointToProcess(*this);
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/UIProcess/Model/ModelProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class ModelProcessProxy final : public AuxiliaryProcessProxy {

void createModelProcessConnection(WebProcessProxy&, IPC::Connection::Handle&& connectionIdentifier, ModelProcessConnectionParameters&&);

ProcessThrottler& throttler() final { return m_throttler; }
const ProcessThrottler& throttler() const final { return m_throttler; }

void updateProcessAssertion();

void terminateForTesting();
Expand Down Expand Up @@ -103,6 +106,7 @@ class ModelProcessProxy final : public AuxiliaryProcessProxy {

ModelProcessCreationParameters processCreationParameters();

ProcessThrottler m_throttler;
ProcessThrottler::ActivityVariant m_activityFromWebProcesses;

HashSet<PAL::SessionID> m_sessionIDs;
Expand Down
13 changes: 11 additions & 2 deletions Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,16 @@ static bool anyProcessPoolAlwaysRunsAtBackgroundPriority()
}

NetworkProcessProxy::NetworkProcessProxy()
: AuxiliaryProcessProxy(WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion(), anyProcessPoolAlwaysRunsAtBackgroundPriority(), networkProcessResponsivenessTimeout)
: AuxiliaryProcessProxy(anyProcessPoolAlwaysRunsAtBackgroundPriority(), networkProcessResponsivenessTimeout)
#if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
, m_customProtocolManagerClient(makeUniqueRef<LegacyCustomProtocolManagerClient>())
, m_customProtocolManagerProxy(*this)
#else
, m_customProtocolManagerClient(makeUniqueRef<API::CustomProtocolManagerClient>())
#endif
, m_throttler(*this, WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
#if PLATFORM(MAC)
, m_backgroundActivityToPreventSuspension(throttler().backgroundActivity("Prevent suspension"_s))
, m_backgroundActivityToPreventSuspension(m_throttler.backgroundActivity("Prevent suspension"_s))
#endif
{
RELEASE_LOG(Process, "%p - NetworkProcessProxy::NetworkProcessProxy", this);
Expand Down Expand Up @@ -576,6 +577,14 @@ void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Con
networkProcessDidTerminate(ProcessTerminationReason::Crash);
return;
}

#if USE(RUNNINGBOARD)
m_throttler.didConnectToProcess(*this);
#if USE(EXTENSIONKIT)
if (launcher)
launcher->releaseLaunchGrant();
#endif
#endif
}

void NetworkProcessProxy::logDiagnosticMessage(WebPageProxyIdentifier pageID, const String& message, const String& description, WebCore::ShouldSample shouldSample)
Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ class NetworkProcessProxy final : public AuxiliaryProcessProxy {

void requestTermination();

ProcessThrottler& throttler() final { return m_throttler; }
const ProcessThrottler& throttler() const final { return m_throttler; }

void updateProcessAssertion();

#if ENABLE(CONTENT_EXTENSIONS)
Expand Down Expand Up @@ -423,6 +426,7 @@ class NetworkProcessProxy final : public AuxiliaryProcessProxy {
LegacyCustomProtocolManagerProxy m_customProtocolManagerProxy;
#endif

ProcessThrottler m_throttler;
ProcessThrottler::ActivityVariant m_activityFromWebProcesses;

#if ENABLE(CONTENT_EXTENSIONS)
Expand Down
34 changes: 21 additions & 13 deletions Source/WebKit/UIProcess/WebProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,12 @@ class UIProxyForCapture final : public UserMediaCaptureManagerProxy::ConnectionP
#endif

WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed, CrossOriginMode crossOriginMode, LockdownMode lockdownMode)
: AuxiliaryProcessProxy(processPool.shouldTakeUIBackgroundAssertion(), processPool.alwaysRunsAtBackgroundPriority())
: AuxiliaryProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
, m_backgroundResponsivenessTimer(*this)
, m_processPool(processPool, isPrewarmed == IsPrewarmed::Yes ? IsWeak::Yes : IsWeak::No)
, m_mayHaveUniversalFileReadSandboxExtension(false)
, m_numberOfTimesSuddenTerminationWasDisabled(0)
, m_throttler(*this, processPool.shouldTakeUIBackgroundAssertion())
, m_isResponsive(NoOrMaybe::Maybe)
, m_visiblePageCounter([this](RefCounterEvent) { updateBackgroundResponsivenessTimer(); })
, m_websiteDataStore(websiteDataStore)
Expand Down Expand Up @@ -669,7 +670,7 @@ void WebProcessProxy::shutDown()
m_activityForHoldingLockedFiles = nullptr;
m_audibleMediaActivity = std::nullopt;
m_mediaStreamingActivity = std::nullopt;
throttler().didDisconnectFromProcess();
m_throttler.didDisconnectFromProcess();

for (Ref page : pages())
page->disconnectFramesFromPage();
Expand Down Expand Up @@ -801,8 +802,8 @@ void WebProcessProxy::addExistingWebPage(WebPageProxy& webPage, BeginsUsingDataS
m_pageMap.set(webPage.identifier(), webPage);
globalPageMap().set(webPage.identifier(), webPage);

throttler().setShouldTakeNearSuspendedAssertion(shouldTakeNearSuspendedAssertion());
throttler().setShouldDropNearSuspendedAssertionAfterDelay(shouldDropNearSuspendedAssertionAfterDelay());
m_throttler.setShouldTakeNearSuspendedAssertion(shouldTakeNearSuspendedAssertion());
m_throttler.setShouldDropNearSuspendedAssertionAfterDelay(shouldDropNearSuspendedAssertionAfterDelay());

updateRegistrationWithDataStore();
updateBackgroundResponsivenessTimer();
Expand Down Expand Up @@ -1310,15 +1311,22 @@ void WebProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connect
protectedConnection()->setIgnoreInvalidMessageForTesting();
#endif

#if USE(RUNNINGBOARD) && PLATFORM(MAC)
#if USE(RUNNINGBOARD)
m_throttler.didConnectToProcess(*this);
#if USE(EXTENSIONKIT)
if (launcher)
launcher->releaseLaunchGrant();
#endif
#if PLATFORM(MAC)
for (Ref page : pages()) {
if (page->preferences().backgroundWebContentRunningBoardThrottlingEnabled())
setRunningBoardThrottlingEnabled();
}
#endif // USE(RUNNINGBOARD) && PLATFORM(MAC)
#endif // PLATFORM(MAC)
#endif // USE(RUNNINGBOARD)

throttler().setShouldTakeNearSuspendedAssertion(shouldTakeNearSuspendedAssertion());
throttler().setShouldDropNearSuspendedAssertionAfterDelay(shouldDropNearSuspendedAssertionAfterDelay());
m_throttler.setShouldTakeNearSuspendedAssertion(shouldTakeNearSuspendedAssertion());
m_throttler.setShouldDropNearSuspendedAssertionAfterDelay(shouldDropNearSuspendedAssertionAfterDelay());

#if PLATFORM(COCOA)
unblockAccessibilityServerIfNeeded();
Expand Down Expand Up @@ -1882,7 +1890,7 @@ void WebProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
}
if (!m_activityForHoldingLockedFiles) {
WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "setIsHoldingLockedFiles: UIProcess is taking a background assertion because the WebContent process is holding locked files");
m_activityForHoldingLockedFiles = throttler().backgroundActivity("Holding locked files"_s).moveToUniquePtr();
m_activityForHoldingLockedFiles = m_throttler.backgroundActivity("Holding locked files"_s).moveToUniquePtr();
}
}

Expand Down Expand Up @@ -2268,7 +2276,7 @@ void WebProcessProxy::startBackgroundActivityForFullscreenInput()
if (m_backgroundActivityForFullscreenFormControls)
return;

m_backgroundActivityForFullscreenFormControls = throttler().backgroundActivity("Fullscreen input"_s).moveToUniquePtr();
m_backgroundActivityForFullscreenFormControls = m_throttler.backgroundActivity("Fullscreen input"_s).moveToUniquePtr();
WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "startBackgroundActivityForFullscreenInput: UIProcess is taking a background assertion because it is presenting fullscreen UI for form controls.");
}

Expand Down Expand Up @@ -2329,7 +2337,7 @@ void WebProcessProxy::updateRemoteWorkerProcessAssertion(RemoteWorkerType worker
});
if (shouldTakeForegroundActivity) {
if (!ProcessThrottler::isValidForegroundActivity(workerInformation->activity))
workerInformation->activity = throttler().foregroundActivity("Worker for foreground view(s)"_s);
workerInformation->activity = m_throttler.foregroundActivity("Worker for foreground view(s)"_s);
return;
}

Expand All @@ -2338,14 +2346,14 @@ void WebProcessProxy::updateRemoteWorkerProcessAssertion(RemoteWorkerType worker
});
if (shouldTakeBackgroundActivity) {
if (!ProcessThrottler::isValidBackgroundActivity(workerInformation->activity))
workerInformation->activity = throttler().backgroundActivity("Worker for background view(s)"_s);
workerInformation->activity = m_throttler.backgroundActivity("Worker for background view(s)"_s);
return;
}

if (workerType == RemoteWorkerType::ServiceWorker && m_hasServiceWorkerBackgroundProcessing) {
WEBPROCESSPROXY_RELEASE_LOG(ProcessSuspension, "Service Worker for background processing");
if (!ProcessThrottler::isValidBackgroundActivity(workerInformation->activity))
workerInformation->activity = throttler().backgroundActivity("Service Worker for background processing"_s);
workerInformation->activity = m_throttler.backgroundActivity("Service Worker for background processing"_s);
return;
}

Expand Down
4 changes: 4 additions & 0 deletions Source/WebKit/UIProcess/WebProcessProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class WebProcessProxy : public AuxiliaryProcessProxy {

void setIsHoldingLockedFiles(bool);

ProcessThrottler& throttler() final { return m_throttler; }
const ProcessThrottler& throttler() const final { return m_throttler; }

void isResponsive(CompletionHandler<void(bool isWebProcessResponsive)>&&);
void isResponsiveWithLazyStop();
void didReceiveBackgroundResponsivenessPing();
Expand Down Expand Up @@ -676,6 +679,7 @@ class WebProcessProxy : public AuxiliaryProcessProxy {
WeakHashSet<WebUserContentControllerProxy> m_webUserContentControllerProxies;

int m_numberOfTimesSuddenTerminationWasDisabled;
ProcessThrottler m_throttler;
std::unique_ptr<ProcessThrottler::BackgroundActivity> m_activityForHoldingLockedFiles;
ForegroundWebProcessToken m_foregroundToken;
BackgroundWebProcessToken m_backgroundToken;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
});
}

throttler().setAllowsActivities(!m_processPool->processesShouldSuspend());
m_throttler.setAllowsActivities(!m_processPool->processesShouldSuspend());
}

void WebProcessProxy::platformDestroy()
Expand Down

0 comments on commit 4d395e8

Please sign in to comment.