Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 181a547a020ac7a95c32709adfeb519257ce7a8a
https://github.com/WebKit/WebKit/commit/181a547a020ac7a95c32709adfeb519257ce7a8a
Author: Richard Robinson <[email protected]>
Date: 2026-08-12 (Wed, 12 Aug 2026)
Changed paths:
M Source/WebKit/Modules/Internal/module.modulemap
M Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm
M Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItemInternal.h
M Source/WebKit/UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h
M Source/WebKit/UIProcess/API/Swift/WebPage+BackForwardList.swift
M Source/WebKit/UIProcess/API/Swift/WebPage.swift
M Source/WebKit/UIProcess/Cocoa/WKNavigationDelegateAdapter.swift
M Tools/TestWebKitAPI/Tests/WebKit/WebPage/WebPageNavigationTests.swift
Log Message:
-----------
[SwiftUI WebKit API] WebPage.backForwardList is extremely unreliable
https://bugs.webkit.org/show_bug.cgi?id=321578
rdar://184634983
Reviewed by Abrar Rahman Protyasha.
The value-type-ness of WebPage.BackForwardList was flawed, since it was
essentially just forwarding
everything to a Objective-C class type. Consequently, the `Equatable`
conformance was also flawed,
which made observing changes to the list unreliable and incorrect.
Fix this by addressing multiple issues:
1. Change `backForwardList` from a stored property to a computed one that
snapshots the live list
on each read, so that the contents are captured eagerly.
2. In addition to listening to `_webView:backForwardListItemAdded:removed:` to
update the list, also
listen to `_webView:didUpdateHistoryTitle:forURL:`, since the title gets
updated independently of the
rest of the list.
3. Make the id of each item use the actual identifier of the backing engine
type, so that identity
is no longer dependent on a pointer address nor needs to retain anything.
Test: Tools/TestWebKitAPI/Tests/WebKit/WebPage/WebPageNavigationTests.swift
* Source/WebKit/Modules/Internal/module.modulemap:
* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm:
(-[WKBackForwardListItem _identifier]):
(-[WKBackForwardListItem _identifierProcess]):
* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItemInternal.h:
* Source/WebKit/UIProcess/API/Cocoa/WKHistoryDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Swift/WebPage+BackForwardList.swift:
(backList): Deleted.
(currentItem): Deleted.
(forwardList): Deleted.
(wrapped): Deleted.
* Source/WebKit/UIProcess/API/Swift/WebPage.swift:
(backForwardList):
(backingWebView):
(didChangeBackForwardList):
* Source/WebKit/UIProcess/Cocoa/WKNavigationDelegateAdapter.swift:
(WKNavigationDelegateAdapter._webView(_:didUpdateHistoryTitle:for:)):
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/WebPageNavigationTests.swift:
(WebPageNavigationTests.backForwardListNotifiesObserversOfEveryChange):
(WebPageNavigationTests.navigatingToBackForwardListItemNotifiesObservers):
(WebPageNavigationTests.backForwardListItemIdentifiersAreStableAcrossSnapshots):
(WebPageNavigationTests.backForwardListItemsReflectUpdatesToTheirContents):
(WebPageNavigationTests.backForwardListsWithDifferingHistoriesAreNotEqual):
(WebPageNavigationTests.backForwardListSubscriptAccessesItemsRelativeToCurrentItem):
Canonical link: https://commits.webkit.org/319076@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications