Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f08f67b1112e2308cff608b60fe6d3de1207a441
      
https://github.com/WebKit/WebKit/commit/f08f67b1112e2308cff608b60fe6d3de1207a441
  Author: Lily Spiniolas <[email protected]>
  Date:   2025-10-18 (Sat, 18 Oct 2025)

  Changed paths:
    A 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-expected.txt
    A 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-frames-expected.txt
    A 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-frames.html
    A 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-navigation-expected.txt
    A 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-navigation.html
    A 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information.html
    A LayoutTests/model-element/resources/finish-models-navigation.html
    A LayoutTests/model-element/resources/models-frame.html
    A LayoutTests/model-element/resources/no-models.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebCore/Modules/model-element/HTMLModelElement.cpp
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/page/ChromeClient.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h
    M Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  [visionOS] `ensurePositionInformationIsUpToDate` is called every time a 
scroll gesture occurs
https://bugs.webkit.org/show_bug.cgi?id=300964
rdar://157183410

Reviewed by Wenson Hsieh.

In visionOS 26, support for the <model> element was added, which includes a new 
pan gesture recognizer
for the purpose of rotating model elements. This new recognizer means that 
pinch to scroll gestures are
first recognized as a potential pan gesture, and to determine whether we should 
actually pan, we check
if the gesture is occuring over a model element. However, in order to do this, 
we have to call
`ensurePositionInformationIsUpToDate` in WKContentViewInteraction.

`ensurePositionInformationIsUpToDate` must fetch the information from the web 
process if valid information
is not already present, and since this occurs synchronously, it can cause 
hangs. Since it is now called
for every scroll gesture, the number of hangs has increased.

To mitigate this, we now track whether or not a model element is present on the 
page. If one is present,
we continue as we did before, and if one is not present, we immediately stop 
processing the gesture as
a pan gesture, avoiding the unnecessary call to 
`ensurePositionInformationIsUpToDate`.

To track the presence of a model element, each Document and Page now keep a 
count of their total number
of model elements. When an HTMLModelElement is inserted or removed, it notifies 
the document that the
count should increase. The document then notifies the Page that the count 
should increase. When the count
changes to 0 or 1, the Page notifies the UI process that we either do or do not 
have a model element.

During document teardown, HTMLModelElement::removedFromAncestor is called after 
the page has already
been disconnected, which means the Page has an inaccurate model element count 
unless it is notified
in another manner. To achieve this, we decrement the count in 
Document::destroyRenderTree so that
the page can still be notified.

Added multiple layout tests to ensure that 
`ensurePositionInformationIsUpToDate` is only called during
scroll gestures if a model element is present on the page. Added UIHelper 
methods
`didCallEnsurePositionInformationIsUpToDateSinceLastCheck` and
`clearEnsurePositionInformationIsUpToDateTracking` to achieve this.

Tests: 
model-element/model-element-determines-if-scroll-gesture-updates-position-information-frames.html
       
model-element/model-element-determines-if-scroll-gesture-updates-position-information-navigation.html
       
model-element/model-element-determines-if-scroll-gesture-updates-position-information.html
* 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-expected.txt:
 Added.
* 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-frames-expected.txt:
 Added.
* 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-frames.html:
 Added.
* 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-navigation-expected.txt:
 Added.
* 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information-navigation.html:
 Added.
* 
LayoutTests/model-element/model-element-determines-if-scroll-gesture-updates-position-information.html:
 Added.
* LayoutTests/model-element/resources/finish-models-navigation.html: Added.
* LayoutTests/model-element/resources/models-frame.html: Added.
* LayoutTests/model-element/resources/no-models.html: Added.
* LayoutTests/resources/ui-helper.js:
(window.UIHelper.didCallEnsurePositionInformationIsUpToDateSinceLastCheck.return.new.Promise):
(window.UIHelper.didCallEnsurePositionInformationIsUpToDateSinceLastCheck):
(window.UIHelper.clearEnsurePositionInformationIsUpToDateTracking.return.new.Promise):
(window.UIHelper.clearEnsurePositionInformationIsUpToDateTracking):
* Source/WebCore/Modules/model-element/HTMLModelElement.cpp:
(WebCore::HTMLModelElement::insertedIntoAncestor):
(WebCore::HTMLModelElement::removedFromAncestor):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::destroyRenderTree):
(WebCore::Document::incrementModelElementCount):
(WebCore::Document::decrementModelElementCount):
* Source/WebCore/dom/Document.h:
(WebCore::Document::hasModelElement const):
* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::setHasModelElement):
* Source/WebCore/page/Page.cpp:
(WebCore::Page::incrementModelElementCount):
(WebCore::Page::decrementModelElementCount):
* Source/WebCore/page/Page.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView didEnsurePositionInformationIsUpToDate]):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setHasModelElement):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView ensurePositionInformationIsUpToDate:]):
(-[WKContentView gestureRecognizerShouldBegin:]):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::setHasModelElement):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setHasModelElement):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::didCallEnsurePositionInformationIsUpToDateSinceLastCheck
 const):
(WTR::UIScriptController::clearEnsurePositionInformationIsUpToDateTracking):
* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView didEnsurePositionInformationIsUpToDate]):
(-[TestRunnerWKWebView 
didCallEnsurePositionInformationIsUpToDateSinceLastCheck]):
(-[TestRunnerWKWebView clearEnsurePositionInformationIsUpToDateTracking]):
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::didCallEnsurePositionInformationIsUpToDateSinceLastCheck
 const):
(WTR::UIScriptControllerIOS::clearEnsurePositionInformationIsUpToDateTracking):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to