Skip to content

Commit

Permalink
Low end devices should not prewarm Web process on provisional load
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259927
rdar://113557767

Reviewed by Chris Dumez.

After 266255@main, a Web process is prewarmed on provisional load instead of when the main frame load has finished.
This is a page load time progression on most iOS devices, except for the low end ones. For these devices, we should
still be prewarming when the main frame load has finished. The change in 266255@main is also performance neutral on
macOS, so we can also keep the original behavior there.

* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::shouldPrewarmWebProcessOnProvisionalLoad):
(WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared):
(WebKit::WebPageProxy::didFinishLoadForFrame):

Canonical link: https://commits.webkit.org/266717@main
  • Loading branch information
pvollan committed Aug 9, 2023
1 parent 66b9bc9 commit 3ef8682
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Source/WTF/wtf/PlatformEnableCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,3 +899,7 @@
|| PLATFORM(VISION))
#define ENABLE_SAMPLE_BUFFER_CONTENT_KEY_SESSION_SUPPORT 1
#endif

#if !defined(ENABLE_PREWARM_WEBPROCESS_ON_PROVISIONAL_LOAD) && PLATFORM(IOS)
#define ENABLE_PREWARM_WEBPROCESS_ON_PROVISIONAL_LOAD 1
#endif
17 changes: 16 additions & 1 deletion Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5389,6 +5389,17 @@ void WebPageProxy::didStartProvisionalLoadForFrame(FrameIdentifier frameID, Fram
didStartProvisionalLoadForFrameShared(m_process.copyRef(), frameID, WTFMove(frameInfo), WTFMove(request), navigationID, WTFMove(url), WTFMove(unreachableURL), userData);
}

static bool shouldPrewarmWebProcessOnProvisionalLoad()
{
#if ENABLE(PREWARM_WEBPROCESS_ON_PROVISIONAL_LOAD)
// With sufficient number of cores, page load times improve when prewarming a Web process when the provisional load starts.
// Otherwise, a Web process will be prewarmed when the main frame load is finished.
return WTF::numberOfProcessorCores() > 4;
#else
return false;
#endif
}

void WebPageProxy::didStartProvisionalLoadForFrameShared(Ref<WebProcessProxy>&& process, FrameIdentifier frameID, FrameInfoData&& frameInfo, ResourceRequest&& request, uint64_t navigationID, URL&& url, URL&& unreachableURL, const UserData& userData)
{
PageClientProtector protector(pageClient());
Expand Down Expand Up @@ -5416,7 +5427,8 @@ void WebPageProxy::didStartProvisionalLoadForFrameShared(Ref<WebProcessProxy>&&
internals().pageLoadState.clearPendingAPIRequest(transaction);

if (frame->isMainFrame()) {
notifyProcessPoolToPrewarm();
if (shouldPrewarmWebProcessOnProvisionalLoad())
notifyProcessPoolToPrewarm();
process->didStartProvisionalLoadForMainFrame(url);
reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
internals().pageLoadStart = MonotonicTime::now();
Expand Down Expand Up @@ -5935,6 +5947,9 @@ void WebPageProxy::didFinishLoadForFrame(FrameIdentifier frameID, FrameInfoData&

resetRecentCrashCountSoon();

if (!shouldPrewarmWebProcessOnProvisionalLoad())
notifyProcessPoolToPrewarm();

callLoadCompletionHandlersIfNecessary(true);
}

Expand Down

0 comments on commit 3ef8682

Please sign in to comment.