Skip to content

Implement the Origin-Agent-Cluster header#66162

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
annevk:eng/Implement-the-Origin-Agent-Cluster-header
Jun 2, 2026
Merged

Implement the Origin-Agent-Cluster header#66162
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
annevk:eng/Implement-the-Origin-Agent-Cluster-header

Conversation

@annevk
Copy link
Copy Markdown
Contributor

@annevk annevk commented Jun 1, 2026

b4c4069

Implement the Origin-Agent-Cluster header
https://bugs.webkit.org/show_bug.cgi?id=216618
rdar://69452369

Reviewed by Alex Christensen.

This implements origin-keyed agent clusters and gates it behind
OriginAgentClusterEnabled (set to preview). It is standardized here:

https://html.spec.whatwg.org/multipage/browsers.html#origin-isolation

This new keying does not impact process allocation, although we could
decide to make it impact that in the future if we wanted to. It impacts
document.domain, serialization and deserialization of certain objects,
and the new window.originAgentCluster getter.

We add a new test that is upstreamed at
web-platform-tests/wpt#60311 that catches an
issue with our existing agent cluster implementation for opaque
origins and we also fix that issue.

As the test infrastructure continues to use the same browsing context
group for each test, we add a way to reset the browsing context group
state so it appears as if you are getting a fresh browsing context
group when you start a new test.

The subtest failures of regression-1399759.https.sub.html are due to
about:blank inheriting from the parent instead of the initiator of the
navigation. That's a distinct issue from this new feature.

going-back.sub.https.html is skipped because it times out on some bots
at the history.back() step, while the feature-related assertions pass.
I suspect it's related to the bfcache. I could not reproduce it locally
(1000 iterations of the test as well as 10 full-directory runs).

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

b06eacb

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🛠 🧪 jsc-x86-64 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 🛠 jsc-armv7
✅ 🛠 tv ✅ 🛠 mac-safer-cpp 🧪 jsc-armv7-tests
✅ 🛠 tv-sim ✅ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@annevk annevk self-assigned this Jun 1, 2026
@annevk annevk added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Jun 1, 2026
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

macOS Safer C++ Build #111505 (f5dd211)

❌ Found 3 failing files with 5 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

iOS Safer C++ Build #30153 (f5dd211)

❌ Found 3 failing files with 4 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
@annevk annevk force-pushed the eng/Implement-the-Origin-Agent-Cluster-header branch from f5dd211 to a910c5e Compare June 1, 2026 11:09
@annevk annevk marked this pull request as ready for review June 1, 2026 12:39
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
@@ -101,6 +111,8 @@ class BrowsingContextGroup : public RefCountedAndCanMakeWeakPtr<BrowsingContextG
HashMap<WebCore::Site, WeakPtr<FrameProcess>> m_processMap;
WeakListHashSet<WebPageProxy> m_pages;
WeakHashMap<WebPageProxy, HashSet<Ref<RemotePageProxy>>> m_remotePages;

HashMap<WebCore::SecurityOriginData, WebCore::OriginKeyed> m_historicalAgentClusterKeyMap;
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.

Could this just be a HashSet of origins that are origin keyed?
Are origins ever removed, or does this just grow for the lifetime of the BrowsingContextGroup?

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.

It grows for the lifetime of the BCG.

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.

And we can't use a set because we need to track:

  1. Not seen at all.
  2. Seen and origin-keyed.
  3. Seen and not origin-keyed.

Because we don't want to flip on the prior keying.

void clearBrowsingContextGroupForTesting()
{
m_identifier = WebCore::BrowsingContextGroupIdentifier::generate();
m_historicalAgentClusterKeyMap.clear();
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.

If we put this in BrowsingContextGroup.cpp we can probably remove the additional headers included from this header and use forward declarations instead.

Copy link
Copy Markdown
Contributor Author

@annevk annevk Jun 1, 2026

Choose a reason for hiding this comment

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

I will stop inlining it, but I can't forward declare anything new unless we wrap the HashMap in a unique_ptr which I suspect we don't want to do.

Comment thread Source/WebCore/loader/OriginAgentClusterPolicy.h Outdated
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
@annevk annevk force-pushed the eng/Implement-the-Origin-Agent-Cluster-header branch from a910c5e to 3cfe28c Compare June 1, 2026 15:46
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 1, 2026
});
}

void WKPageClearBrowsingContextGroupForTesting(WKPageRef pageRef)
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.

I wonder if this would be better just added as part of WKPageResetStateBetweenTests

Comment on lines +40 to +41
OriginAgentClusterPolicy isolatedCopy() const & { return { isOriginKeyed }; }
OriginAgentClusterPolicy isolatedCopy() && { return { isOriginKeyed }; }
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.

There doesn't seem to be a good reason to have a separate function for if it's an l-value or an r-value if they both are identical. Maybe we're planning to add strings here, I'm not sure.

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.

Yeah, I realized we can remove the entire struct for now so I went ahead and did that. Perhaps we need something more involved when we flip the default, but maybe not.

@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Jun 2, 2026
@annevk annevk force-pushed the eng/Implement-the-Origin-Agent-Cluster-header branch from 3cfe28c to b06eacb Compare June 2, 2026 06:01
@annevk annevk added the merge-queue Applied to send a pull request to merge-queue label Jun 2, 2026
https://bugs.webkit.org/show_bug.cgi?id=216618
rdar://69452369

Reviewed by Alex Christensen.

This implements origin-keyed agent clusters and gates it behind
OriginAgentClusterEnabled (set to preview). It is standardized here:

https://html.spec.whatwg.org/multipage/browsers.html#origin-isolation

This new keying does not impact process allocation, although we could
decide to make it impact that in the future if we wanted to. It impacts
document.domain, serialization and deserialization of certain objects,
and the new window.originAgentCluster getter.

We add a new test that is upstreamed at
web-platform-tests/wpt#60311 that catches an
issue with our existing agent cluster implementation for opaque
origins and we also fix that issue.

As the test infrastructure continues to use the same browsing context
group for each test, we add a way to reset the browsing context group
state so it appears as if you are getting a fresh browsing context
group when you start a new test.

The subtest failures of regression-1399759.https.sub.html are due to
about:blank inheriting from the parent instead of the initiator of the
navigation. That's a distinct issue from this new feature.

going-back.sub.https.html is skipped because it times out on some bots
at the history.back() step, while the feature-related assertions pass.
I suspect it's related to the bfcache. I could not reproduce it locally
(1000 iterations of the test as well as 10 full-directory runs).

Canonical link: https://commits.webkit.org/314346@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Implement-the-Origin-Agent-Cluster-header branch from b06eacb to b4c4069 Compare June 2, 2026 07:41
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 314346@main (b4c4069): https://commits.webkit.org/314346@main

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

@webkit-commit-queue webkit-commit-queue merged commit b4c4069 into WebKit:main Jun 2, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 2, 2026
@annevk annevk deleted the eng/Implement-the-Origin-Agent-Cluster-header branch June 2, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants