Skip to content

script: Dispatch touch compatibility mouse events synchronously in ScriptThread - #48671

Merged
Narfinger merged 3 commits into
servo:mainfrom
yezhizhen:update-the-rendering
Oct 6, 2026
Merged

Narfinger merged 3 commits into
servo:mainfrom
yezhizhen:update-the-rendering

Conversation

@yezhizhen

@yezhizhen yezhizhen commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Compatibility mouse events for a tap were synthesized by the paint thread as new
input events after confirmed by script->constellation->embedder->paint,
so they were processed on a later rendering tick than the touchend that triggered them, making touch tests racy/flaky.
One particular serious case is, the hit-test for compat mouse events happened when the layout state has already changed.

This simplifies API as well, by removing unused render_api in notify_input_event_handled and point in PendingClick.
It also simplifies messaging: simulate_mouse_click is now removed from paint, which was like
paint -> constellation -> script -> embedder -> paint, and repeated 3 times as we had duplicate hit-test 3 times!

Testing: mouseevents-after-touchend.tentative.html and /touch-events/hover-state-caused-by-compatibility-mouse-events.tentative.html has new passing and no longer intermittent.
WebDriver perform_actions/pointer_touch.py has 4 more new failures: this is newly filed #48619 which has
always been there, but previously hidden.

Fixes: #36957 (review), performance related concern
Fixes: #40233, incorrect behaviour

Intermittent ones

Fixes: #46497
Fixes: #42813
Fixes: #46781
Fixes: #46277
Fixes: #41175
Fixes: #44693

And probably some I'm not aware of yet.

@yezhizhen
yezhizhen requested a review from xiaochengh October 6, 2026 06:44
@yezhizhen
yezhizhen requested a review from gterzian as a code owner October 6, 2026 06:44
@yezhizhen yezhizhen added I-perf-slow Unnecessary performance degredation. B-high-value Represents work that would have a big impact labels Oct 6, 2026
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 6, 2026
@yezhizhen yezhizhen added the I-race A race between two concurrent pieces of code. label Oct 6, 2026

@mrobinson mrobinson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems reasonable to me.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 6, 2026
@mrobinson mrobinson changed the title script: Dispatch touch compatibility mouse events synchronously script: Dispatch touch compatibility mouse events synchronously in ScriptThread Oct 6, 2026
@yezhizhen yezhizhen added the T-linux-wpt Do a try run of the WPT label Oct 6, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

🔨 Triggering try run (#37444305552) for Linux (WPT)

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Test results for linux-wpt from try job (#37444305552):

Flaky unexpected result (19)
  • CRASH [expected OK] /IndexedDB/idbcursor_advance_objectstore.any.worker.html
  • CRASH [expected OK] /_webgl/conformance2/wasm/readpixels-2gb-in-4gb-wasm-memory.html
  • OK /beacon/beacon-basic.https.window.html (#41723)
    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = string

      assert_false: expected false got true
      

    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = arraybuffer

      assert_false: expected false got true
      

  • CRASH [expected OK] /content-security-policy/frame-ancestors/frame-ancestors-nested-same-in-same-star-allow.html
  • OK /css/CSS2/linebox/inline-negative-margin-001.html (#43763)
    • FAIL [expected PASS] subtest: [data-expected-height] 3

      assert_equals: 
      <div class="w4" data-expected-height="10">123 <span style="margin-left: -4ch">1234 </span></div>
      height expected 10 but got 20
      

    • FAIL [expected PASS] subtest: [data-expected-height] 4

      assert_equals: 
      <div class="w4" data-expected-height="10">123 <span style="margin-left: -4ch">123 </span></div>
      height expected 10 but got 20
      

    • FAIL [expected PASS] subtest: [data-expected-height] 5

      assert_equals: 
      <div class="w4" data-expected-height="10"><img class="w4"><span style="margin-left: -4ch">123</span></div>
      height expected 10 but got 20
      

    • FAIL [expected PASS] subtest: [data-expected-height] 6

      assert_equals: 
      <div class="w4" data-expected-height="10"><img class="w5"><span style="margin-left: -5ch">123</span></div>
      height expected 10 but got 20
      

    • FAIL [expected PASS] subtest: [data-expected-height] 8

      assert_equals: 
      <div class="w4" data-expected-height="10"><img class="w4"><img class="w1" style="margin-left: -1ch"></div>
      height expected 10 but got 20
      

    • FAIL [expected PASS] subtest: [data-expected-height] 10

      assert_equals: 
      <div class="w4" data-expected-height="10"><img class="w5"><img class="w1" style="margin-left: -2ch"></div>
      height expected 10 but got 20
      

  • FAIL [expected PASS] /css/css-fonts/font-feature-settings-descriptor-01.html (#45418)
  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/cross-origin-top-navigation-with-user-activation-in-parent.window.html (#48205)
    • TIMEOUT [expected FAIL] subtest: Cross-origin top navigation is blocked without user activation, even if the parent has user activation

      Test timed out
      

  • TIMEOUT [expected OK] /html/browsers/windows/consume-user-activation/window-open-multi-global.html (#47399)
    • TIMEOUT [expected FAIL] subtest: window.open() and consuming user activation with multiple globals in play

      Test timed out
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/autoplay-disabled-by-permissions-policy.https.sub.html (#46012, #46804)
    • FAIL [expected TIMEOUT] subtest: Permissions-Policy header: autoplay "none" disallows same-origin iframes.

      assert_false: autoplay expected false got true
      

  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-assign.html (#32863)
  • OK /html/semantics/forms/form-submission-0/jsurl-form-submit.tentative.html (#36489)
    • PASS [expected FAIL] subtest: Verifies that form submissions scheduled inside javascript: urls take precedence over the javascript: url's return value.
  • CRASH [expected ERROR] /html/semantics/forms/the-select-element/customizable-select/select-appearance-button-after-span.html
  • OK /html/semantics/interactive-elements/the-summary-element/interactive-content.html
    • FAIL [expected PASS] subtest: Clicking on non-interactive child of a <summary> opens its <details>

      assert_true: expected true got false
      

  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • OK /mixed-content/tentative/autoupgrades/audio-upgrade.https.sub.html (#41697)
    • FAIL [expected PASS] subtest: Audio autoupgraded

      assert_equals: Length expected 1 but got Infinity
      

  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html (#44693)
    • NOTRUN [expected PASS] subtest: touch two-finger pan on 'touch-action: pan-x pan-y'
    • NOTRUN [expected FAIL] subtest: touch two-finger pan on 'touch-action: pinch-zoom'
  • OK /sanitizer-api/sanitizer-inert-document.html (#45260)
    • PASS [expected FAIL] subtest: Test whether setHTML loads the image.
    • FAIL [expected PASS] subtest: Test whether setHTMLUnsafe loads the image.

      promise_test: Unhandled rejection with value: "The server observed a request. It shouldn't have."
      

  • OK /upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

  • OK /webdriver/tests/classic/set_window_rect/user_prompts.py
    • ERROR [expected PASS] subtest: test_accept[alert-None]

      teardown error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept[confirm-True]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept[prompt-]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[confirm-True]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[prompt-]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[confirm-False]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[prompt-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss_and_notify[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • And 8 more unexpected results...
Stable unexpected results that are known to be intermittent (9)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window-resize-event.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/refresh/same-document-refresh.html (#34597)
    • PASS [expected FAIL] subtest: Same-Document Referrer from Refresh
  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/autoplay-allowed-by-permissions-policy.https.sub.html (#46803)
    • TIMEOUT [expected PASS] subtest: Permissions-Policy header: autoplay * allows same-origin iframes.

      Test timed out
      

  • OK /html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html (#43671)
    • PASS [expected FAIL] subtest: document.write external script into iframe write back into parent
  • OK /resource-timing/buffer-full-add-then-clear.html (#40819)
    • PASS [expected FAIL] subtest: Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one
  • OK /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (iframe)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (img)
    • FAIL [expected PASS] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (link)

      assert_equals: expected 5.560000000000002 but got 5.55
      

    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (xmlhttprequest)
  • OK /touch-events/mouseevents-after-touchend.tentative.html (#46497)
    • FAIL [expected PASS] subtest: Double tap should cause single-click twice or a double-click

      assert_in_array: value "[ { type: touchend, target: child, changedTouches: 1, touches: 0 }, { type: mousemove, target: child, detail: 0, button: 0, buttons: 0 }, { type: mousedown, target: child, detail: 2, button: 0, buttons: 1 }, { type: mouseup, target: child, detail: 2, button: 0, buttons: 0 }, { type: click, target: child, detail: 2, button: 0, buttons: 0 }, { type: dblclick, target: child, detail: 2, button: 0, buttons: 0 }, { type: touchend, target: child, changedTouches: 1, touches: 0 }, { type: mousemove, target: child, detail: 0, button: 0, buttons: 0 }, { type: mousedown, target: child, detail: 3, button: 0, buttons: 1 }, { type: mouseup, target: child, detail: 3, button: 0, buttons: 0 }, { type: click, target: child, detail: 3, button: 0, buttons: 0 } ]" not in array ["[ { type: touchend, target: child, changedTouches: 1, touches: 0 }, { type: mousemove, target: child, detail: 0, button: 0, buttons: 0 }, { type: mousedown, target: child, detail: 1, button: 0, buttons: 1 }, { type: mouseup, target: child, detail: 1, button: 0, buttons: 0 }, { type: click, target: child, detail: 1, button: 0, buttons: 0 }, { type: touchend, target: child, changedTouches: 1, touches: 0 }, { type: mousemove, target: child, detail: 0, button: 0, buttons: 0 }, { type: mousedown, target: child, detail: 1, button: 0, buttons: 1 }, { type: mouseup, target: child, detail: 1, button: 0, buttons: 0 }, { type: click, target: child, detail: 1, button: 0, buttons: 0 } ]", "[ { type: touchend, target: child, changedTouches: 1, touches: 0 }, { type: mousemove, target: child, detail: 0, button: 0, buttons: 0 }, { type: mousedown, target: child, detail: 1, button: 0, buttons: 1 }, { type: mouseup, target: child, detail: 1, button: 0, buttons: 0 }, { type: click, target: child, detail: 1, button: 0, buttons: 0 }, { type: touchend, target: child, changedTouches: 1, touches: 0 }, { type: mousemove, target: child, detail: 0, button: 0, buttons: 0 }, { type: mousedown, target: child, detail: 2, button: 0, buttons: 1 }, { type: mouseup, target: child, detail: 2, button: 0, buttons: 0 }, { type: click, target: child, detail: 2, button: 0, buttons: 0 }, { type: dblclick, target: child, detail: 2, button: 0, buttons: 0 } ]"]
      

  • OK /webdriver/tests/classic/perform_actions/pointer_pen.py (#47618)
    • FAIL [expected PASS] subtest: test_pen_pointer_in_shadow_tree[outer-open]

      AssertionError
      

    • FAIL [expected PASS] subtest: test_pen_pointer_in_shadow_tree[outer-closed]

      AssertionError
      

    • FAIL [expected PASS] subtest: test_pen_pointer_in_shadow_tree[inner-open]

      AssertionError
      

    • FAIL [expected PASS] subtest: test_pen_pointer_in_shadow_tree[inner-closed]

      AssertionError
      

  • OK [expected TIMEOUT] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • FAIL [expected TIMEOUT] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe

      assert_true: about:blank window opened by 3P iframe does not inherit 3P iframe's StorageKey expected true got false
      

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

✨ Try run (#37444305552) succeeded.

@Narfinger
Narfinger added this pull request to the merge queue Oct 6, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 6, 2026
Merged via the queue into servo:main with commit 53f2a80 Oct 6, 2026
89 of 90 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 6, 2026
@yezhizhen
yezhizhen deleted the update-the-rendering branch October 6, 2026 14:52
hhhwsqhhh pushed a commit to hhhwsqhhh/servo that referenced this pull request Oct 12, 2026
…criptThread` (servo#48671)

Compatibility mouse events for a tap were synthesized by the paint
thread as new
input events after confirmed by script->constellation->embedder->paint, 
so they were processed on a later rendering tick than the touchend that
triggered them, making touch tests racy/flaky.
One particular serious case is, the hit-test for compat mouse events
happened when the layout state has already changed.

This simplifies API as well, by removing unused `render_api` in
`notify_input_event_handled` and point in `PendingClick`.
It also simplifies messaging: `simulate_mouse_click` is now removed from
paint, which was like
paint -> constellation -> script -> embedder -> paint, and repeated 3
times as we had duplicate hit-test 3 times!

Testing: `mouseevents-after-touchend.tentative.html` and
`/touch-events/hover-state-caused-by-compatibility-mouse-events.tentative.html`
has new passing and no longer intermittent.
WebDriver `perform_actions/pointer_touch.py` has 4 more new failures:
this is newly filed servo#48619 which has
always been there, but previously hidden.

Fixes:
servo#36957 (review),
performance related concern
Fixes: servo#40233, incorrect behaviour
### Intermittent ones
Fixes: servo#46497
Fixes: servo#42813
Fixes: servo#46781
Fixes: servo#46277
Fixes: servo#41175
Fixes: servo#44693

And probably some I'm not aware of yet.

---------

Signed-off-by: Euclid Ye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-high-value Represents work that would have a big impact I-perf-slow Unnecessary performance degredation. I-race A race between two concurrent pieces of code.

Projects

None yet

4 participants