[webkit-changes] [WebKit/WebKit] 6c6b1e: Safari can't open the page when navigating back fr...
Chris Dumez
noreply at github.com
Wed Aug 23 13:20:51 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6c6b1e0f4c367656d18d45a8b4f6d2ec60ec128c
https://github.com/WebKit/WebKit/commit/6c6b1e0f4c367656d18d45a8b4f6d2ec60ec128c
Author: Chris Dumez <cdumez at apple.com>
Date: 2023-08-23 (Wed, 23 Aug 2023)
Changed paths:
M Source/WebKit/CMakeLists.txt
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources.make
A Source/WebKit/Shared/GoToBackForwardItemParameters.h
A Source/WebKit/Shared/GoToBackForwardItemParameters.serialization.in
M Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebProcessProxy.cpp
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Log Message:
-----------
Safari can't open the page when navigating back from a remote HTTP URL to a local html file
https://bugs.webkit.org/show_bug.cgi?id=260504
rdar://103697846
Reviewed by Brent Fulgham.
When calling loadFile on a WKWebView, we create a sandbox extension in the UIProcess
and send it to the WebProcess. In turn the WebProcess uses this to create a temporary
extension for the network process.
Without this, sandboxed apps such as Safari would be unable to load such local files.
When doing a back/forward navigation to a history item for a file URL, we often get
lucky and load the page from the back/forward cache.
However, if the page was evicted from the cache (or wasn't cached in the first place),
we end up using a fresh new process for the navigation. However, we were not issuing
a sandbox extension and the load would fail.
To address the issue, we now create a sandbox extension in
ProvisionalPageProxy::goToBackForwardItem(), whenever we process-swap on back/forward
navigation to a file URL.
Note that Cocoa ports are only able to create sandbox extensions once the process has
finished launching (and we have its PID). As a result, the call to
maybeInitializeSandboxExtensionHandle() may fail when calling ProvisionalPageProxy::goToBackForwardItem()
if the process is still launching. In this case, the sandbox extension gets created
later on, when the process has finished launching and we're sending the queued IPC.
This is the exact same approach that we were using for WebPage::LoadRequest, but I
am now applying it to WebPage::GoToBackForwardItem IPC too. If the process is not
done launching, we send a WebPage::GoToBackForwardItemWaitingForProcessLaunch IPC
instead, which gets handled in WebProcessProxy::shouldSendPendingMessage(), similarly
to WebPage::LoadRequestWaitingForProcessLaunch. At this point, we create the sandbox
extensions and convert the IPC message into a regular WebPage::GoToBackForwardItem
one.
To simplify the code, I moved all the parameters for the WebPage::GoToBackForwardItem
IPC to a new GoToBackForwardItemParameters structure with its generated IPC coders.
I also added the new sandbox extension handle to this structure.
* Source/WebKit/CMakeLists.txt:
* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Shared/GoToBackForwardItemParameters.h: Added.
* Source/WebKit/Shared/GoToBackForwardItemParameters.serialization.in: Added.
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::goToBackForwardItem):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::launchProcessForReload):
(WebKit::WebPageProxy::goToBackForwardItem):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shouldSendPendingMessage):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::goToBackForwardItem):
(WebKit::WebPage::goToBackForwardItemWaitingForProcessLaunch):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
Canonical link: https://commits.webkit.org/267199@main
More information about the webkit-changes
mailing list