Skip to content

servo/script: Add initial support for handling stopped loads - #49427

Merged
TimvdLippe merged 1 commit into
servo:mainfrom
mrobinson:stopping-the-load
Nov 1, 2026
Merged

TimvdLippe merged 1 commit into
servo:mainfrom
mrobinson:stopping-the-load

Conversation

@mrobinson

Copy link
Copy Markdown
Member

This change adds the necessary code to deal with stopped loads:

  • A new API state that represents when a load has been stopped instead
    of completed.
  • Proper handling of stopped loads at various times during the loading
    lifecycle.
  • Switching the Document readystate to complete when a load is
    stopped.
  • Informing an iframe to stop blocking the load of its parent Document
    when the load is stopped within it.

Still missing:

  • Stopping the load still does not cancel ongoing navigations
    in the Constellation.
  • stop() does not properly stop ongoing navigations for child
    <iframe>s. That's a bit more complex so will come in a followup.

Testing: This fixes one crashing WPT and improves another.

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 30, 2026
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Oct 30, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 30, 2026
@github-actions

Copy link
Copy Markdown

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

@mrobinson
mrobinson force-pushed the stopping-the-load branch 2 times, most recently from 7509893 to 7477eaa Compare October 30, 2026 10:19
@codecov-commenter

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1054 1 1053 0
View the top 1 failed test(s) by shortest run time
servo::largest_contentful_paint::test_largest_contentful_paint_js_api_with_mouse_click_and_reload
Stack Traces | 0.387s run time
thread 'test_largest_contentful_paint_js_api_with_mouse_click_and_reload' (86386) panicked at .../servo/tests/largest_contentful_paint.rs:235:5:
assertion `left == right` failed
  left: 2
 right: 1
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<usize, usize>
   4: <largest_contentful_paint::test_largest_contentful_paint_js_api_with_mouse_click_and_reload::{closure#0} as core::ops::function::FnOnce<()>>::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (24)
  • CRASH [expected OK] /IndexedDB/idbindex-rename-abort.any.worker.html
  • OK /IndexedDB/idbtransaction-oncomplete.any.sharedworker.html (#45911)
    • FAIL [expected PASS] subtest: IDBTransaction - complete event

      assert_array_equals: lengths differ, expected array ["upgradeneeded", "complete", "success", "opencursor"] length 4, got ["upgradeneeded", "complete", "success"] length 3
      

  • OK /css/CSS2/linebox/inline-negative-margin-001.html (#43763)
    • FAIL [expected PASS] subtest: [data-expected-height] 3

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

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

      assert_equals: 
      &lt;div class="w4" data-expected-height="10"&gt;123 &lt;span style="margin-left: -4ch"&gt;123 &lt;/span&gt;&lt;/div&gt;
      height expected 10 but got 20
      

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

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

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

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

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

      assert_equals: 
      &lt;div class="w4" data-expected-height="10"&gt;&lt;img class="w4"&gt;&lt;img class="w1" style="margin-left: -1ch"&gt;&lt;/div&gt;
      height expected 10 but got 20
      

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

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

  • OK /css/css-animations/event-order.tentative.html (#39000)
    • PASS [expected FAIL] subtest: Same events on pseudo-elements follow the prescribed order
  • FAIL [expected PASS] /css/css-backgrounds/background-size-041.html
  • TIMEOUT [expected PASS] /dom/nodes/moveBefore/moveBefore-range-iframe-crash.html
  • OK [expected ERROR] /focus/focus-event-after-switching-iframes.sub.html (#40368)
  • CRASH [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin-fragment.html (#20768)
    • PASS [expected FAIL] subtest: Tests that a fragment navigation in the unload handler will not block the initial navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • PASS [expected FAIL] subtest: aElement.click() before the load event must NOT replace
  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit.html (#44028)
  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • PASS [expected FAIL] subtest: traversing history must also traverse hash changes
  • CRASH [expected OK] /html/browsers/history/the-location-interface/assign-with-nested-iframe.html (#48200)
  • 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
      

  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-replace-set-src.html (#32697)
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-replace.html (#49186)
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-window-open.html (#32596)
  • CRASH [expected OK] /html/semantics/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
  • 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.
  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • TIMEOUT [expected OK] /pointerevents/pointerevent_touch-action-none-css_touch.html
  • OK /upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade 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 xhr to cross-http-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 xhr to cross-https origin and downgrade 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 xhr to same-http-downgrade origin and downgrade 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 xhr to same-http-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 xhr to same-https origin and downgrade redirection from https context.

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

  • TIMEOUT [expected OK] /webdriver/tests/classic/perform_actions/pointer_origin.py
  • 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 (8)
  • OK /beacon/beacon-basic.https.window.html (#41723)
    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = blob

      assert_false: expected false got true
      

  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-requestsubmit.html (#44098)
    • FAIL [expected TIMEOUT] subtest: Replace before load, triggered by formElement.requestSubmit()

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?thereplacement=" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/code-injector.html?pipe=sub(none)&amp;code=%0A%20%20%20%20const%20form%20%3D%20document.createElement(%22form%22)%3B%0A%20%20%20%20form.action%20%3D%20%22%2Fcommon%2Fblank.html%22%3B%0A%0A%20%20%20%20const%20input%20%3D%20document.createElement(%22input%22)%3B%0A%20%20%20%20input.type%20%3D%20%22hidden%22%3B%0A%20%20%20%20input.name%20%3D%20%22thereplacement%22%3B%0A%20%20%20%20form.append(input)%3B%0A%0A%20%20%20%20document.currentScript.before(form)%3B%0A%20%20%20%20form.requestSubmit()%3B%0A%20%20"
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/autoplay-allowed-by-permissions-policy.https.sub.html (#46803)
    • PASS [expected TIMEOUT] subtest: Permissions-Policy header: autoplay * allows same-origin iframes.
  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/autoplay-default-permissions-policy.https.sub.html (#46805)
    • PASS [expected TIMEOUT] subtest: Default "autoplay" feature policy ["self"] allows same-origin iframes.
  • 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
      

  • PASS [expected FAIL] /mathml/presentation-markup/operators/mo-form-dynamic-002.html (#49169)
  • FAIL [expected PASS] /mathml/presentation-markup/operators/operator-dictionary-empty-and-three-chars.html (#49173)
  • OK /user-timing/measure_associated_with_navigation_timing.html (#47273)
    • PASS [expected FAIL] subtest: loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a".

@github-actions

Copy link
Copy Markdown

✨ Try run (#41038739863) succeeded.

@yezhizhen
yezhizhen requested review from yezhizhen and removed request for yezhizhen October 31, 2026 10:05
// This is not in the specification, but when a load is aborted in a frame, parent
// frames need to be notified that this frame is no longer blocking the load.
// See <https://github.com/whatwg/html/issues/10252>.
self.notify_constellation_that_load_finished(true /* aborted */);

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.

The function this lives in, abort_a_document_and_its_descendants is called by both window.stop and navigate. Is it really correct to have this notification in second case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a good point. I think this wasn't causing problems due to further checks in the Constellation, but I've moved this to the caller Window::stop_loading which should ensure that this only happens for stop operations.

This change adds the necessary code to deal with stopped loads:

- A new API state that represents when a load has been stopped instead
  of completed.
- Proper handling of stopped loads at various times during the loading
  lifecycle.
- Switching the Document `readystate` to `complete` when a load is
  stopped.
- Informing an iframe to stop blocking the load of its parent `Document`
  when the load is stopped within it.

Still missing:
- Stopping the load still does not cancel ongoing navigations
  in the Constellation.
- `stop()` does not properly stop ongoing navigations for child
  `<iframe>`s. That's a bit more complex so will come in a followup.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Oct 31, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 31, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (16)
  • CRASH [expected OK] /IndexedDB/idb-binary-key-roundtrip.any.worker.html
  • CRASH [expected ERROR] /IndexedDB/idbindex_get.any.serviceworker.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] /css/css-backgrounds/background-size-041.html
  • FAIL [expected PASS] /css/css-image-animation/image-animation-img-running-to-normal.html (#46567)
  • TIMEOUT [expected PASS] /dom/nodes/moveBefore/moveBefore-range-iframe-crash.html
  • 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
      

  • CRASH [expected OK] /html/browsers/history/the-location-interface/assign-replace-from-iframe.html (#47679)
  • 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
      

  • CRASH [expected TIMEOUT] /html/canvas/element/manual/draw-element-image/compositing-op-non-opaque-element.tentative.html
  • CRASH [expected OK] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-replace.html (#49186)
  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • OK /mathml/presentation-markup/operators/operator-dictionary-combining.html (#49238)
    • FAIL [expected PASS] subtest: Spacing around =⃒

      assert_approx_equals: expected 58 +/- 1 but got 88
      

    • FAIL [expected PASS] subtest: Spacing around |⃒

      assert_approx_equals: expected 33 +/- 1 but got 63
      

    • FAIL [expected PASS] subtest: Spacing around ⋉⃒

      assert_approx_equals: expected 66 +/- 1 but got 96
      

    • FAIL [expected PASS] subtest: Spacing around ∃⃒

      assert_approx_equals: expected 43 +/- 1 but got 73
      

  • ERROR [expected TIMEOUT] /performance-timeline/not-restored-reasons/abort-block-bfcache.window.html (#42802)
  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
    • 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 /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"
      

Stable unexpected results that are known to be intermittent (11)
  • OK /css/CSS2/linebox/inline-negative-margin-001.html (#43763)
    • FAIL [expected PASS] subtest: [data-expected-height] 3

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

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

      assert_equals: 
      &lt;div class="w4" data-expected-height="10"&gt;123 &lt;span style="margin-left: -4ch"&gt;123 &lt;/span&gt;&lt;/div&gt;
      height expected 10 but got 20
      

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

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

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

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

  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 21deg' should prefer 'oblique 30deg 60deg' over 'oblique 40deg 50deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 10deg' should prefer 'oblique 0deg' over 'oblique -50deg -20deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 0deg' should prefer 'oblique 40deg 50deg' over 'oblique -50deg -20deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-button-click.html (#44099)
    • TIMEOUT [expected FAIL] subtest: Replace before load, triggered by submitButton.click()

      Test timed out
      

  • CRASH [expected TIMEOUT] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/autoplay-allowed-by-permissions-policy.https.sub.html (#46803)
    • PASS [expected TIMEOUT] subtest: Permissions-Policy header: autoplay * allows same-origin iframes.
  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/autoplay-default-permissions-policy.https.sub.html (#46805)
    • PASS [expected TIMEOUT] subtest: Default "autoplay" feature policy ["self"] allows same-origin iframes.
  • 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/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
  • OK /html/syntax/speculative-parsing/expect-no-linked-resources/no-speculative-fetch.tentative.optional.html (#47290)
    • PASS [expected FAIL] subtest: expect-no-linked-resources hint was ignored
  • CRASH [expected OK] /html/webappapis/dynamic-markup-insertion/opening-the-input-stream/remove-initial-about-blankness.window.html (#47638)
  • OK /html/webappapis/user-prompts/print-during-unload.html (#35944)
    • FAIL [expected PASS] subtest: print() during unload

      assert_array_equals: expected property 1 to be "destination" but got "error: window.print is not a function" (expected array ["start", "destination"] got ["start", "error: window.print is not a function"])
      

@github-actions

Copy link
Copy Markdown

✨ Try run (#41210052377) succeeded.

@yezhizhen yezhizhen 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.

There are many possible combinations may not be well considered yet. But since this is initial support and navigation related thing is always super complicated, let's improve incrementally.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 31, 2026
@TimvdLippe
TimvdLippe added this pull request to the merge queue Nov 1, 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 Nov 1, 2026
Merged via the queue into servo:main with commit 931271c Nov 1, 2026
76 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 Nov 1, 2026
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
Add ports/arkweb, a self-contained cdylib (libservo_arkweb.so) that
implements ArkWeb's NWeb C++ interfaces on top of libservo, so a stock ArkTS
`Web` component renders with Servo instead of the Chromium-based engine.
NWeb entry points arrive on ACE threads and are forwarded as actions to a
Servo event-loop thread (src/runtime.rs, cxx bridge in src/bridge.rs). The
hand-written NWeb subclasses in cpp/ sit on generated no-op stub bases, over
NWeb headers vendored in vendor/ohos_nweb (tools/sync-headers.sh,
tools/gen_stubs.py). ohos-patches/ holds the OpenHarmony webview diff that
makes nweb_helper.cpp dlopen the library when the system parameter
web.engine.enforce is 100, with apply/build instructions, and
tools/deploy.py (hdc-py based) installs the library on a device.

Bringing the shim up on an rk3568 needed:
- starting the servo thread in LibraryLoaded (CreateNWeb can precede
  InitializeWebEngine);
- setting opts.config_dir from --user-data-dir (the OHOS font cache unwraps
  it);
- buffering the initial load until the browsing context is registered;
- deferring WebView creation until the first real Resize, and setting the
  OHNativeWindow buffer geometry before creating the surfman surface
  (otherwise WebRender OOMs into ACE's 1x1/producer surface);
- letting WebView::resize own the rendering-context resize. Resizing the
  context directly first makes Painter::resize_rendering_context
  early-return (it is already at the target size), which skips the
  WebRender document-view update, the display-list resend and
  set_needs_repaint -- no new frame is scheduled and the old one persists
  until an unrelated event (a tap) forces a repaint. Most visible as a
  half-height page after the soft keyboard closes, once the IME is wired.
  Buffer geometry is still set first, before the surfman resize that
  resize() performs. With the context no longer held for that direct
  resize, BuiltWebView does not keep one: the painter and the delegate hold
  their own.

ACE's `OnPause`/`OnOccluded` hide the WebView and `OnContinue`/`OnUnoccluded` show it
again; a hidden WebView is neither painted nor animated. Focusing a web component, and
building its WebView, gives that WebView system focus (`WebView::set_focused`) and takes
it from the other WebViews of the process.

Move the port from OpenHarmony-7.0-Beta1 to OpenHarmony-v7.0-Release.

The NWeb headers are re-synced from web_webview 12cb9a37bbba. The release
inserts new virtuals in the middle of NWeb (GetSurfaceNodeId,
GetSurfaceRSHandle, ...) and removes OnTouchCancelById, so a shim built
against the Beta1 headers no longer matches the vtable of the 7.0
libraries. The stub bases are regenerated from the new headers.

The new ohos-patches/0002 fixes base/startup/init, which tests the
undefined macro __LP__ instead of __LP64__ and therefore looks up seccomp
filters under lib/seccomp on 64-bit builds: appspawn fails to install its
filter and exits, and init reboots the device in a loop. Every 64-bit
7.0-Release image needs it, with or without Servo. The rebase of 0001 is
in the RTLD_LOCAL patch, which edits that file later in the stack.

Validation: Test by building with ./mach check --ohos -p arkweb, then deploy (ports/arkweb/tools/deploy.py) and run uv run ports/arkweb/tools/test_render.py on a device; a webview resize must repaint immediately rather than leaving the previous frame. Move to OpenHarmony-v7.0-Release: Built a full rk3568 arm64 image from OpenHarmony-v7.0-Release with ohos-patches/0001 and 0002 applied (without 0002 it boot-loops on appspawn) and flashed a HiHope DAYU200 (OpenHarmony 7.0, API 26); `./mach build --ohos --release --no-package -p arkweb`, deployed with `tools/deploy.py`, test app installed with `tools/build_test_app.py`; `HDC_TARGET=<serial> uv run --with pytest --with hdc-py --with pillow python -m pytest ports/arkweb/tools`: 35 passed, 1 xfailed. `tools/gen_stubs.py --check` is clean. 2026-11-09 sync: `./mach build --ohos --release --no-package -p arkweb`; on a DAYU200 (OpenHarmony 7.0), deploy.py with this sync's library returned 67 s after it rebooted the board, with the board listed and booted, without a manual `hdc kill -r`; the arkweb-test suite of `ports/arkweb/tools` then passed (37 tests) once the board's hdcd had restarted on its own, between 403 and 470 s after boot, which a run at 403 s met as disconnects.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-10-08 sync -- adapted to upstream API removals: `WebView::set_throttled` (c974e3c) -> `hide()`/`show()` for OnPause/OnOccluded, `WebView::focus` (15aa067) -> `set_focused`, focusing one WebView and unfocusing the others; Cargo.lock regenerated from upstream's so that `cargo metadata --locked` passes at this commit)
AI-assisted: Yes (agent session; 2026-10-08 sync -- carried the focus change of the backend commit over to the deferred WebView: `focus_webview` reaches it through `entry.built`, and a new WebView takes focus once built)
AI-assisted: Yes (agent session; 2026-10-09 restack -- folded in "ports/arkweb: on-device render fixes, deploy.py, OHOS patches" and wrote the description of the port from its README)
AI-assisted: Yes (agent session; header sync, OpenHarmony image build and boot-loop fix, on-device testing)
AI-assisted: Yes (agent session; 2026-10-13 sync -- folded in "squash! ports/arkweb: Servo as an alternative ArkWeb webview backend" (the move to OpenHarmony-v7.0-Release))
AI-assisted: Yes (agent session; 2026-11-09 sync -- Cargo.lock: arkweb takes the workspace version, now 0.8.0 (servo#49467); seven Windows-only windows-sys edges back to upstream's resolution, found by the independent review)
AI-assisted: Yes (agent session; 2026-11-09 sync -- upstream added `LoadStatus::Stopped` (servo#49427): a stopped load finishes like a completed one, as a WebView reports `stop()` with a page-finished callback, found by the drift review; deploy.py waits after its reboot until the device is listed again and has finished booting, restarting the hdc server while the device is not listed, which the hdc server needs to enumerate a rebooted device again; the usage example names the OpenHarmony checkout with a placeholder)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
Wire the remaining MVP NWebHandler callbacks from the WebViewDelegate:
- show_console_message -> OnConsoleLog (with a concrete NWebConsoleLog),
  mapping the servo ConsoleLogLevel to NWebConsoleLogLevel.
- notify_load_status_changed -> OnLoadingProgress, approximating the
  0-100 progress ArkWeb expects from servo's discrete load stages.
- notify_crashed -> OnPageLoadError; servo has no per-load network-error
  callback, so a webview crash is the failure it does surface.

Validation: Test by running uv run ports/arkweb/tools/test_navigation.py and checking hilog for console/progress callback lines while it runs. 2026-11-09 sync: `./mach check --ohos -p arkweb`, and the arkweb-test suite on a DAYU200 as for the backend commit.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-11-09 sync -- upstream added `LoadStatus::Stopped` (servo#49427) and `ConsoleLogLevel::Table` (servo#49314): a stopped load reaches full progress, and `console.table()` is logged at the INFO level, as `console.log()` is; found by the drift review)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
Add ports/arkweb, a self-contained cdylib (libservo_arkweb.so) that
implements ArkWeb's NWeb C++ interfaces on top of libservo, so a stock ArkTS
`Web` component renders with Servo instead of the Chromium-based engine.
NWeb entry points arrive on ACE threads and are forwarded as actions to a
Servo event-loop thread (src/runtime.rs, cxx bridge in src/bridge.rs). The
hand-written NWeb subclasses in cpp/ sit on generated no-op stub bases, over
NWeb headers vendored in vendor/ohos_nweb (tools/sync-headers.sh,
tools/gen_stubs.py). ohos-patches/ holds the OpenHarmony webview diff that
makes nweb_helper.cpp dlopen the library when the system parameter
web.engine.enforce is 100, with apply/build instructions, and
tools/deploy.py (hdc-py based) installs the library on a device.

Bringing the shim up on an rk3568 needed:
- starting the servo thread in LibraryLoaded (CreateNWeb can precede
  InitializeWebEngine);
- setting opts.config_dir from --user-data-dir (the OHOS font cache unwraps
  it);
- buffering the initial load until the browsing context is registered;
- deferring WebView creation until the first real Resize, and setting the
  OHNativeWindow buffer geometry before creating the surfman surface
  (otherwise WebRender OOMs into ACE's 1x1/producer surface);
- letting WebView::resize own the rendering-context resize. Resizing the
  context directly first makes Painter::resize_rendering_context
  early-return (it is already at the target size), which skips the
  WebRender document-view update, the display-list resend and
  set_needs_repaint -- no new frame is scheduled and the old one persists
  until an unrelated event (a tap) forces a repaint. Most visible as a
  half-height page after the soft keyboard closes, once the IME is wired.
  Buffer geometry is still set first, before the surfman resize that
  resize() performs. With the context no longer held for that direct
  resize, BuiltWebView does not keep one: the painter and the delegate hold
  their own.

ACE's `OnPause`/`OnOccluded` hide the WebView and `OnContinue`/`OnUnoccluded` show it
again; a hidden WebView is neither painted nor animated. Focusing a web component, and
building its WebView, gives that WebView system focus (`WebView::set_focused`) and takes
it from the other WebViews of the process.

Move the port from OpenHarmony-7.0-Beta1 to OpenHarmony-v7.0-Release.

The NWeb headers are re-synced from web_webview 12cb9a37bbba. The release
inserts new virtuals in the middle of NWeb (GetSurfaceNodeId,
GetSurfaceRSHandle, ...) and removes OnTouchCancelById, so a shim built
against the Beta1 headers no longer matches the vtable of the 7.0
libraries. The stub bases are regenerated from the new headers.

The new ohos-patches/0002 fixes base/startup/init, which tests the
undefined macro __LP__ instead of __LP64__ and therefore looks up seccomp
filters under lib/seccomp on 64-bit builds: appspawn fails to install its
filter and exits, and init reboots the device in a loop. Every 64-bit
7.0-Release image needs it, with or without Servo. The rebase of 0001 is
in the RTLD_LOCAL patch, which edits that file later in the stack.

Validation: Test by building with ./mach check --ohos -p arkweb, then deploy (ports/arkweb/tools/deploy.py) and run uv run ports/arkweb/tools/test_render.py on a device; a webview resize must repaint immediately rather than leaving the previous frame. Move to OpenHarmony-v7.0-Release: Built a full rk3568 arm64 image from OpenHarmony-v7.0-Release with ohos-patches/0001 and 0002 applied (without 0002 it boot-loops on appspawn) and flashed a HiHope DAYU200 (OpenHarmony 7.0, API 26); `./mach build --ohos --release --no-package -p arkweb`, deployed with `tools/deploy.py`, test app installed with `tools/build_test_app.py`; `HDC_TARGET=<serial> uv run --with pytest --with hdc-py --with pillow python -m pytest ports/arkweb/tools`: 35 passed, 1 xfailed. `tools/gen_stubs.py --check` is clean. 2026-11-09 sync: `./mach build --ohos --release --no-package -p arkweb`; on a DAYU200 (OpenHarmony 7.0), deploy.py with this sync's library returned 67 s after it rebooted the board, with the board listed and booted, without a manual `hdc kill -r`; the arkweb-test suite of `ports/arkweb/tools` then passed (37 tests) once the board's hdcd had restarted on its own, between 403 and 470 s after boot, which a run at 403 s met as disconnects.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-10-08 sync -- adapted to upstream API removals: `WebView::set_throttled` (c974e3c) -> `hide()`/`show()` for OnPause/OnOccluded, `WebView::focus` (15aa067) -> `set_focused`, focusing one WebView and unfocusing the others; Cargo.lock regenerated from upstream's so that `cargo metadata --locked` passes at this commit)
AI-assisted: Yes (agent session; 2026-10-08 sync -- carried the focus change of the backend commit over to the deferred WebView: `focus_webview` reaches it through `entry.built`, and a new WebView takes focus once built)
AI-assisted: Yes (agent session; 2026-10-09 restack -- folded in "ports/arkweb: on-device render fixes, deploy.py, OHOS patches" and wrote the description of the port from its README)
AI-assisted: Yes (agent session; header sync, OpenHarmony image build and boot-loop fix, on-device testing)
AI-assisted: Yes (agent session; 2026-10-13 sync -- folded in "squash! ports/arkweb: Servo as an alternative ArkWeb webview backend" (the move to OpenHarmony-v7.0-Release))
AI-assisted: Yes (agent session; 2026-11-09 sync -- Cargo.lock: arkweb takes the workspace version, now 0.8.0 (servo#49467); seven Windows-only windows-sys edges back to upstream's resolution, found by the independent review)
AI-assisted: Yes (agent session; 2026-11-09 sync -- upstream added `LoadStatus::Stopped` (servo#49427): a stopped load finishes like a completed one, as a WebView reports `stop()` with a page-finished callback, found by the drift review; deploy.py waits after its reboot until the device is listed again and has finished booting, restarting the hdc server while the device is not listed, which the hdc server needs to enumerate a rebooted device again; the usage example names the OpenHarmony checkout with a placeholder)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
Wire the remaining MVP NWebHandler callbacks from the WebViewDelegate:
- show_console_message -> OnConsoleLog (with a concrete NWebConsoleLog),
  mapping the servo ConsoleLogLevel to NWebConsoleLogLevel.
- notify_load_status_changed -> OnLoadingProgress, approximating the
  0-100 progress ArkWeb expects from servo's discrete load stages.
- notify_crashed -> OnPageLoadError; servo has no per-load network-error
  callback, so a webview crash is the failure it does surface.

Validation: Test by running uv run ports/arkweb/tools/test_navigation.py and checking hilog for console/progress callback lines while it runs. 2026-11-09 sync: `./mach check --ohos -p arkweb`, and the arkweb-test suite on a DAYU200 as for the backend commit.
AI-assisted: Yes (agent session; implementation and on-device testing)
AI-assisted: Yes (agent session; 2026-11-09 sync -- upstream added `LoadStatus::Stopped` (servo#49427) and `ConsoleLogLevel::Table` (servo#49314): a stopped load reaches full progress, and `console.table()` is logged at the INFO level, as `console.log()` is; found by the drift review)
Signed-off-by: Jonathan Schwender <[email protected]>
@mrobinson
mrobinson deleted the stopping-the-load branch November 21, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants