Skip to content

Implement cross-origin redirects when loading site-isolated iframes - #16383

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
achristensen07:eng/Implement-cross-origin-redirects-when-loading-site-isolated-iframes
Aug 10, 2023
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
achristensen07:eng/Implement-cross-origin-redirects-when-loading-site-isolated-iframes

Conversation

@achristensen07

@achristensen07 achristensen07 commented Aug 4, 2023 •

Copy link
Copy Markdown
Contributor

a9f7a67

Implement cross-origin redirects when loading site-isolated iframes
https://bugs.webkit.org/show_bug.cgi?id=259817
rdar://113377510

Reviewed by Chris Dumez.

In order to get this to work, I needed to do several things:
1. Implement some message handlers in RemotePageProxy to call WebPageProxy methods with the correct process.
2. Make 2 modifications to WebFrameProxy::prepareForProvisionalNavigationInProcess:
2.a. If we are redirected back to the WebFrameProxy's process, stop using a ProvisionalFrameProxy or RemotePageProxy.
     We are just doing a same-process navigation when this happens.
2.b. If we have a provisional frame but we are doing a cross-origin redirect, make a new provisional frame in the new process.
3. After preparing for a provisional navigation, skip the didCommitLoadForFrame call from the new process
   because we've already received it from the first page.  This is what YesAfterProvisionalLoadStarted does.
4. If we are redirecting, frameProcessBeforeNavigation needs to be the provisional frame's process for continueWithProcessForNavigation.
5. If site isolation is enabled, we can't reuse a process that hasn't seen a provisional navigation committed because we
   need a provisional load starting to a new domain to come from a new domain's process.  This may be optimized away when
   we implement redirect chain following without starting processes for each domain along the chain, but the change
   in WebProcessPool::processForNavigationInternal is needed until then.

Covered by testing a variety of same-domain and cross-domain redirects in addition to existing tests.

* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::load):
* Source/WebKit/UIProcess/API/APINavigation.cpp:
(API::Navigation::currentRequestIsCrossOriginRedirect const):
* Source/WebKit/UIProcess/API/APINavigation.h:
* Source/WebKit/UIProcess/RemotePageProxy.cpp:
(WebKit::RemotePageProxy::didReceiveMessage):
(WebKit::RemotePageProxy::decidePolicyForNavigationActionAsync):
(WebKit::RemotePageProxy::decidePolicyForNavigationActionSync):
(WebKit::RemotePageProxy::didChangeProvisionalURLForFrame):
(WebKit::RemotePageProxy::didReceiveSyncMessage):
* Source/WebKit/UIProcess/RemotePageProxy.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::prepareForProvisionalNavigationInProcess):
* Source/WebKit/UIProcess/WebFrameProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/266768@main

2ae6f5c

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug   🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🛠 gtk
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1   🧪 gtk-wk2
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🧪 api-gtk
✅ 🛠 tv   🧪 mac-AS-debug-wk2
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 🧪 unsafe-merge ✅ 🛠 watch-sim

@achristensen07
achristensen07 requested a review from cdumez as a code owner August 4, 2023 05:37
@achristensen07 achristensen07 self-assigned this Aug 4, 2023
@achristensen07 achristensen07 added the WebKit Process Model Bugs related to WebKit's multi-process architecture label Aug 4, 2023
@webkit-early-warning-system

webkit-early-warning-system commented Aug 4, 2023 •

Copy link
Copy Markdown
Collaborator

@achristensen07
achristensen07 force-pushed the eng/Implement-cross-origin-redirects-when-loading-site-isolated-iframes branch from d00077d to ef9ec97 Compare August 5, 2023 05:57
@webkit-early-warning-system

webkit-early-warning-system commented Aug 5, 2023 •

Copy link
Copy Markdown
Collaborator

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 5, 2023
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Aug 5, 2023
webkit-commit-queue pushed a commit to achristensen07/WebKit that referenced this pull request Aug 6, 2023
…ssage

https://bugs.webkit.org/show_bug.cgi?id=259864

Reviewed by Wenson Hsieh.

We are sending the response, and separately we are sending a bool indicating if the response is null.
This is unnecessary redundant information.

Also, I'm going to need the whole response on NavigationActionData for WebKit#16383
and this is a little piece of that change that is easy to separate into a non-behavior-changing PR.

* Source/WebKit/Shared/NavigationActionData.h:
* Source/WebKit/Shared/NavigationActionData.serialization.in:
* Source/WebKit/UIProcess/API/APINavigation.h:
(API::Navigation::currentRequestIsRedirect const):
* Source/WebKit/UIProcess/API/APINavigationAction.h:
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionAsync):
(WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionSync):
* Source/WebKit/UIProcess/ProvisionalPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationActionAsync):
(WebKit::WebPageProxy::decidePolicyForNavigationActionAsyncShared):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNavigationActionSync):
(WebKit::WebPageProxy::decidePolicyForNavigationActionSyncShared):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createWindow):
* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::didSameDocumentNavigationForFrameViaJSHistoryAPI):
(WebKit::WebLocalFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):

Canonical link: https://commits.webkit.org/266620@main
@achristensen07
achristensen07 force-pushed the eng/Implement-cross-origin-redirects-when-loading-site-isolated-iframes branch from ef9ec97 to e890393 Compare August 10, 2023 05:11
@webkit-early-warning-system

webkit-early-warning-system commented Aug 10, 2023 •

Copy link
Copy Markdown
Collaborator

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@achristensen07 achristensen07 removed the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the implementation, it sounds like you mean cross-site, not cross-origin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we disabling this optimization? This seems bad. I don't think this optimization is incompatible with site isolation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When redirecting multiple times, I was making a new RemotePageProxy before clearing the old one, which caused two RemotePageProxies to be using the same process with the same page ID at the same time. I'm fixing that by cleaning the old RemotePageProxy before making a new one instead of this.

@achristensen07
achristensen07 force-pushed the eng/Implement-cross-origin-redirects-when-loading-site-isolated-iframes branch from e890393 to 2ae6f5c Compare August 10, 2023 16:33
@achristensen07 achristensen07 added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 10, 2023
https://bugs.webkit.org/show_bug.cgi?id=259817
rdar://113377510

Reviewed by Chris Dumez.

In order to get this to work, I needed to do several things:
1. Implement some message handlers in RemotePageProxy to call WebPageProxy methods with the correct process.
2. Make 2 modifications to WebFrameProxy::prepareForProvisionalNavigationInProcess:
2.a. If we are redirected back to the WebFrameProxy's process, stop using a ProvisionalFrameProxy or RemotePageProxy.
     We are just doing a same-process navigation when this happens.
2.b. If we have a provisional frame but we are doing a cross-origin redirect, make a new provisional frame in the new process.
3. After preparing for a provisional navigation, skip the didCommitLoadForFrame call from the new process
   because we've already received it from the first page.  This is what YesAfterProvisionalLoadStarted does.
4. If we are redirecting, frameProcessBeforeNavigation needs to be the provisional frame's process for continueWithProcessForNavigation.
5. If site isolation is enabled, we can't reuse a process that hasn't seen a provisional navigation committed because we
   need a provisional load starting to a new domain to come from a new domain's process.  This may be optimized away when
   we implement redirect chain following without starting processes for each domain along the chain, but the change
   in WebProcessPool::processForNavigationInternal is needed until then.

Covered by testing a variety of same-domain and cross-domain redirects in addition to existing tests.

* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::load):
* Source/WebKit/UIProcess/API/APINavigation.cpp:
(API::Navigation::currentRequestIsCrossOriginRedirect const):
* Source/WebKit/UIProcess/API/APINavigation.h:
* Source/WebKit/UIProcess/RemotePageProxy.cpp:
(WebKit::RemotePageProxy::didReceiveMessage):
(WebKit::RemotePageProxy::decidePolicyForNavigationActionAsync):
(WebKit::RemotePageProxy::decidePolicyForNavigationActionSync):
(WebKit::RemotePageProxy::didChangeProvisionalURLForFrame):
(WebKit::RemotePageProxy::didReceiveSyncMessage):
* Source/WebKit/UIProcess/RemotePageProxy.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::prepareForProvisionalNavigationInProcess):
* Source/WebKit/UIProcess/WebFrameProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/266768@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/Implement-cross-origin-redirects-when-loading-site-isolated-iframes branch from 2ae6f5c to a9f7a67 Compare August 10, 2023 17:52
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 266768@main (a9f7a67): https://commits.webkit.org/266768@main

Reviewed commits have been landed. Closing PR #16383 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit a9f7a67 into WebKit:main Aug 10, 2023
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebKit Process Model Bugs related to WebKit's multi-process architecture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants