Repository navigation
servo/script: Add initial support for handling stopped loads - #49427
Conversation
e5ac0eb to
10dcb8e
Compare
|
🔨 Triggering try run (#41038739863) for Linux (WPT) |
7509893 to
7477eaa
Compare
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
7477eaa to
75580be
Compare
|
Test results for linux-wpt from try job (#41038739863): Flaky unexpected result (24)
Stable unexpected results that are known to be intermittent (8)
|
|
✨ Try run (#41038739863) succeeded. |
75580be to
ee01da4
Compare
| // 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 */); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]>
ee01da4 to
8b6c6a0
Compare
|
🔨 Triggering try run (#41210052377) for Linux (WPT) |
|
Test results for linux-wpt from try job (#41210052377): Flaky unexpected result (16)
Stable unexpected results that are known to be intermittent (11)
|
|
✨ Try run (#41210052377) succeeded. |
yezhizhen
left a comment
There was a problem hiding this comment.
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.
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]>
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]>
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]>
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]>
This change adds the necessary code to deal with stopped loads:
of completed.
lifecycle.
readystatetocompletewhen a load isstopped.
Documentwhen the load is stopped within it.
Still missing:
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.