Skip to content

Commit

Permalink
Cherry-pick 3ef8682. rdar://problem/113557767
Browse files Browse the repository at this point in the history
    Low end devices should not prewarm Web process on provisional load
    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
Identifier: 265423.766@safari-7616.1.27.10-branch
  • Loading branch information
pvollan authored and MyahCobbs committed Aug 9, 2023
1 parent fffe00f commit 995de11
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 @@ -904,3 +904,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 @@ -5373,6 +5373,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 @@ -5403,7 +5414,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 @@ -5912,6 +5924,9 @@ void WebPageProxy::didFinishLoadForFrame(FrameIdentifier frameID, FrameInfoData&

resetRecentCrashCountSoon();

if (!shouldPrewarmWebProcessOnProvisionalLoad())
notifyProcessPoolToPrewarm();

callLoadCompletionHandlersIfNecessary(true);
}

Expand Down

0 comments on commit 995de11

Please sign in to comment.