Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b369e72
Show the WebKitGTK window at its first frame, add a window background…
ambroise-leclerc Nov 18, 2026
b18c064
Initialize GStreamer only for applications with media; trace start-up…
ambroise-leclerc Nov 18, 2026
8b54fd5
Defer WebView2 window presentation until first frame
ambroise-leclerc Nov 18, 2026
f79a219
Fix Windows test discovery and release workflow checks
ambroise-leclerc Nov 18, 2026
b3eb879
Detect native CUDA architectures for the host loop
ambroise-leclerc Nov 18, 2026
564b1bb
Address review: GStreamer opt-out kept for the session and off by def…
ambroise-leclerc Nov 18, 2026
59ccfe7
Include NativeFS in the WKWebView lifecycle test (#611)
ambroise-leclerc Nov 18, 2026
84783ab
Let WKWebView's first-layout probe fall back to a timer when animatio…
ambroise-leclerc Nov 18, 2026
dacba8d
Reveal the WKWebView window when the document has loaded instead of a…
ambroise-leclerc Nov 18, 2026
8980082
Give the WKWebView first-load test a delay longer than a cold web con…
ambroise-leclerc Nov 18, 2026
5dd5d13
Scope the GStreamer opt-out to the start of the session and test that…
ambroise-leclerc Nov 18, 2026
6dd54f9
Arm the WebView2 presentation delay with the window; state the proces…
ambroise-leclerc Nov 18, 2026
0cd4b00
Stop WKWebView painting its own white behind a transparent page and t…
ambroise-leclerc Nov 18, 2026
a5c5a39
Report the pixel read by the WKWebView background test (#611)
ambroise-leclerc Nov 18, 2026
cdf5dbf
Check the WKWebView background through its state, not through unrelia…
ambroise-leclerc Nov 18, 2026
d4db210
Give the developer environment's window its dark colour by default to…
ambroise-leclerc Nov 18, 2026
50db2fe
Address review follow-ups: changelog wording, late first-frame milest…
ambroise-leclerc Nov 18, 2026
896d52b
Make the WKWebView window non-opaque for a translucent background and…
ambroise-leclerc Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmake/BoingCuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# default one, CMAKE_CUDA_HOST_COMPILER (or the CUDAHOSTCXX environment variable) names another.
set(WEBFRONT_HOST_LOOP_CUDA "AUTO" CACHE STRING "CUDA renderer of the host-loop example: AUTO (when a working toolkit is found), ON or OFF")
set_property(CACHE WEBFRONT_HOST_LOOP_CUDA PROPERTY STRINGS AUTO ON OFF)
set(_WEBFRONT_BOING_CUDA_DIR "${CMAKE_CURRENT_LIST_DIR}")

# A macro: enable_language() must run in the scope of the top-level CMakeLists.txt, above every directory whose
# targets link the CUDA unit. Defines WebFront_boing, which a target computing the scene links: nothing on a CPU-only
Expand All @@ -15,6 +16,11 @@ macro(webfront_enable_host_loop_cuda)
message(FATAL_ERROR "WEBFRONT_HOST_LOOP_CUDA must be AUTO, ON or OFF, not '${WEBFRONT_HOST_LOOP_CUDA}'")
endif()
set(WEBFRONT_HOST_LOOP_CUDA_ENABLED OFF)
# Record the choice before enable_language initializes its own compiler-dependent default.
set(_webfront_cuda_architectures_explicit FALSE)
if(DEFINED CMAKE_CUDA_ARCHITECTURES OR (DEFINED ENV{CUDAARCHS} AND NOT "$ENV{CUDAARCHS}" STREQUAL ""))
set(_webfront_cuda_architectures_explicit TRUE)
endif()
if(WEBFRONT_HOST_LOOP_CUDA STREQUAL "ON")
enable_language(CUDA)
set(WEBFRONT_HOST_LOOP_CUDA_ENABLED ON)
Expand All @@ -27,6 +33,10 @@ macro(webfront_enable_host_loop_cuda)
endif()
endif()
if(WEBFRONT_HOST_LOOP_CUDA_ENABLED)
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
include("${_WEBFRONT_BOING_CUDA_DIR}/BoingCudaArchitectures.cmake")
webfront_cuda_select_default("${_webfront_cuda_architectures_explicit}" "${CMAKE_CUDA_COMPILER}")
endif()
message(STATUS "Host-loop example: CUDA ${CMAKE_CUDA_COMPILER_VERSION} renderer enabled (${CMAKE_CUDA_COMPILER})")
else()
message(STATUS "Host-loop example: CPU renderer only (WEBFRONT_HOST_LOOP_CUDA=${WEBFRONT_HOST_LOOP_CUDA}, no working CUDA compiler)")
Expand Down
51 changes: 51 additions & 0 deletions cmake/BoingCudaArchitectures.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Select only installed GPUs for which nvcc can emit native machine code. A matching cubin avoids depending on the
# driver's PTX compiler, which may be older than the toolkit. Empty means detection could not make a safe choice.
function(webfront_cuda_native_architectures devices compiler_codes output)
string(REPLACE "\r" "" devices "${devices}")
string(REPLACE "\n" ";" devices "${devices}")
string(REPLACE "\r" "" compiler_codes "${compiler_codes}")
string(REPLACE "\n" ";" compiler_codes "${compiler_codes}")
set(architectures)
foreach(device IN LISTS devices)
string(STRIP "${device}" device)
if(device MATCHES "^([0-9]+)\\.([0-9]+)$")
set(arch "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
if("sm_${arch}" IN_LIST compiler_codes)
list(APPEND architectures "${arch}")
endif()
endif()
endforeach()
list(REMOVE_DUPLICATES architectures)
set(${output} "${architectures}" PARENT_SCOPE)
endfunction()

function(webfront_cuda_detect_native compiler output)
set(${output} "" PARENT_SCOPE)
if(CMAKE_CROSSCOMPILING)
return()
endif()
find_program(_webfront_nvidia_smi NAMES nvidia-smi)
if(NOT _webfront_nvidia_smi)
return()
endif()
execute_process(COMMAND "${_webfront_nvidia_smi}" --query-gpu=compute_cap --format=csv,noheader
RESULT_VARIABLE device_result OUTPUT_VARIABLE devices ERROR_QUIET TIMEOUT 5)
execute_process(COMMAND "${compiler}" --list-gpu-code
RESULT_VARIABLE compiler_result OUTPUT_VARIABLE codes ERROR_QUIET TIMEOUT 5)
if(device_result STREQUAL "0" AND compiler_result STREQUAL "0")
webfront_cuda_native_architectures("${devices}" "${codes}" architectures)
set(${output} "${architectures}" PARENT_SCOPE)
endif()
endfunction()

function(webfront_cuda_select_default explicit_choice compiler)
if(explicit_choice OR CMAKE_CROSSCOMPILING)
return()
endif()
webfront_cuda_detect_native("${compiler}" architectures)
if(architectures)
set(CMAKE_CUDA_ARCHITECTURES "${architectures}" CACHE STRING "CUDA architectures" FORCE)
set(CMAKE_CUDA_ARCHITECTURES "${architectures}" PARENT_SCOPE)
message(STATUS "Host-loop example: native CUDA architectures ${architectures}")
endif()
endfunction()
2 changes: 1 addition & 1 deletion cmake/WKWebViewSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function(webfront_add_wkwebview_tests)
add_executable(wkwebview_lifecycle "${webtest_source_dir}/WKWebViewLifecycle.cpp"
"${webtest_source_dir}/WKWebViewHeaderConsumer.cpp")
target_link_libraries(wkwebview_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options)
foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings hidden-scheduling redirect-policy missing-response committed-navigation agent-application download choose-file cancel-choose replaced-download choose-in-blank choose-in-srcdoc close-with-open-panel close-with-save-panel script-dialogs close-with-script-dialog sandboxed-script-dialog)
foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings translucent-background hidden-scheduling redirect-policy missing-response committed-navigation agent-application download choose-file cancel-choose replaced-download choose-in-blank choose-in-srcdoc close-with-open-panel close-with-save-panel script-dialogs close-with-script-dialog sandboxed-script-dialog load-reveal present-timeout)
add_test(NAME WKWebViewLifecycle-${mode} COMMAND wkwebview_lifecycle ${mode})
webfront_set_browser_test_properties("WKWebViewLifecycle-${mode}" "${webtest_source_dir}" 90)
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion cmake/WebKitGTKSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function(webfront_add_webkitgtk_tests)
target_link_libraries(webkitgtk_lifecycle PRIVATE WebFront_test_hardening WebFront WebFront_warnings WebFront_options)
add_dependencies(webtest webkitgtk_lifecycle)
webfront_find_xvfb(display_runner)
foreach(mode sandbox-environment sandbox-recheck no-display worker-thread native-close repeated-show http-error pre-run-failure poll-failure profile-permissions window-title download download-user-dir choose-file cancel-choose close-with-dialog script-dialogs close-with-script-dialog)
foreach(mode sandbox-environment sandbox-recheck no-display worker-thread native-close repeated-show http-error pre-run-failure poll-failure profile-permissions window-title download download-user-dir choose-file cancel-choose close-with-dialog script-dialogs close-with-script-dialog first-frame present-timeout media-scoped)
if(mode MATCHES "^(no-display|worker-thread|pre-run-failure|profile-permissions)$")
add_test(NAME WebKitGTKAdapter-${mode} COMMAND webkitgtk_lifecycle ${mode})
elseif(display_runner)
Expand Down
4 changes: 2 additions & 2 deletions cmake/WebView2Support.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ target_include_directories(WebFront SYSTEM INTERFACE "${WebView2SDK_SOURCE_DIR}/
target_compile_definitions(WebFront INTERFACE WEBFRONT_EMBED_WEBVIEW2)
target_link_libraries(WebFront INTERFACE
"${WebView2SDK_SOURCE_DIR}/build/native/${_webview2_arch}/WebView2LoaderStatic.lib"
ole32 oleaut32 user32 shell32 shlwapi version)
ole32 oleaut32 user32 gdi32 shell32 shlwapi version)

# Register lifecycle coverage once, alongside the shared Jasmine runner; paths are module-relative.
function(webfront_add_webview2_tests)
Expand All @@ -66,7 +66,7 @@ function(webfront_add_webview2_tests)
target_link_libraries(webview2_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options)
foreach(mode repeated-show native-early-close navigation-diagnostic mta missing-runtime
closed-startup-timeout failed-startup-timeout late-navigation-failure runtime-ready
file-choose file-cancel file-download script-dialogs)
file-choose file-cancel file-download script-dialogs first-frame present-timeout)
add_test(NAME WebView2Lifecycle-${mode} COMMAND webview2_lifecycle ${mode})
webfront_set_browser_test_properties("WebView2Lifecycle-${mode}" "${webtest_source_dir}" 45)
endforeach()
Expand Down
15 changes: 15 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ these entries stays in the GitHub releases and the Git history.

## Unreleased

### Added
- Skip GStreamer's initialization, and its plugin scan, in WebKitGTK for an application whose pages never use audio or video, with `WindowOptions::media = false`; the default keeps media (#611, `docs/WEBKITGTK.md`).
- WKWebView supports `WindowOptions::background`, translucent colours included, and `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WKWEBVIEW.md`).
- WebView2 supports `WindowOptions::background` and `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WEBVIEW2.md`).
- Choose the colour of the WebKitGTK view under the page with `WindowOptions::background` (WebKitGTK; WebView2 and WKWebView are listed above; CEF ignores it), and read the start-up milestones of a WebKitGTK view with `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WEBKITGTK.md`).

### Changed
- Reveal the WKWebView window when the document has loaded or after one second (#611, `docs/WKWEBVIEW.md`).
- Reveal the WebView2 window after the first frame or one second (#611, `docs/WEBVIEW2.md`).
- Show the WebKitGTK window when the page reports its first frame, or when a one-second timer fires, even if the page has not painted, instead of at once; the embedded pages, the starter and the examples use the cheap `sans-serif` and `monospace` font stacks (#611, `docs/WEBKITGTK.md`).

### Fixed
- Remove the white flash of an embedded view between the developer environment's bootstrap page and the project's page, by giving the window the environment's dark colour (`#141821`) when the application sets none; on macOS the view then no longer paints its own white behind it (#611, `docs/WKWEBVIEW.md`).
- Select detected GPU architectures supported by nvcc by default for the host-loop CUDA renderer (`docs/HOST_LOOP_EXAMPLE.md`).

## [1.0.0] - 2026-11-17

WebFront 1.0 ships with developer environment 1.0.0. This release adds host-loop integration, developer tools and
Expand Down
9 changes: 9 additions & 0 deletions docs/HOST_LOOP_EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ working CUDA compiler, and the example is complete without one. `ON` makes a mis
`.cu` unit compiled at C++17, and `CMAKE_CUDA_HOST_COMPILER` names another host compiler when nvcc refuses the default
one. At run time the engine is offered only when a device answers.

On a fresh native build, CMake selects installed NVIDIA GPUs that `nvcc` supports and embeds native code for them. This
avoids depending on the driver's PTX compiler, which may be older than the toolkit. If detection is unavailable, CMake
keeps the compiler's default. Explicit `CMAKE_CUDA_ARCHITECTURES` and `CUDAARCHS` choices take precedence; select all
target architectures for a distribution or cross-build. A previous build retains its cached choice: remove that cache
entry to redetect the local GPU. If the redetection fails (`nvidia-smi` unavailable), CMake keeps no architecture in an
already configured build directory: give `CMAKE_CUDA_ARCHITECTURES` explicitly or start from a fresh build directory
before generating `WebFront_boing_cuda`. With a Visual Studio generator, rebuild `WebFront_boing_cuda` after changing it, since
MSBuild may otherwise retain the previous CUDA object.

**The window.** With the platform's native engine in the build (WebKitGTK on Linux, autodetected), the example opens
a native window; otherwise, or with `--browser`, it opens the system browser. On a Jetson Orin (L4T R39.2.1,
Ubuntu 24.04) the native window opens with no change to the system: no AppArmor profile, no sysctl, no package.
Expand Down
42 changes: 42 additions & 0 deletions docs/WEBKITGTK.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,48 @@ unit tests cover the policy decision table, null error diagnostics, preserving
the first failure when a timeout or callback reports a later error, and the
sandbox launcher check described below.

## Startup and first display

The window is mapped at once, but almost transparent, and becomes opaque when the page reports its first frame (two
animation frames after `DOMContentLoaded`). If no frame is reported, a one-second timer shows it anyway, even when the
server has sent nothing yet, so a window may still appear empty (in the colour of `background`, if any) when the load is
slow; GLib can also run the timer late when other events keep the main loop busy. Without a compositing manager the
opacity is ignored and the window appears immediately, as before. The navigation timeout and its diagnostics are
unchanged. `WindowOptions::background` (`"#rgb"`, `"#rrggbb"` or `"#rrggbbaa"`) is the colour of the view under the page,
so a dark interface does not flash white once the window is shown; only WebKitGTK applies it so far.
`WEBFRONT_STARTUP_TRACE=1` prints the view's milestones (session creation, view created, load started, first frame,
window shown) on standard error, in milliseconds since the process was executed; only the first frame notification of
the session is a milestone (a late one is marked as such), a reload is not. A close request (`requestClose()`) made
before the window is shown still ends the session.

### Skipping GStreamer

WebKitGTK initializes GStreamer in the page's process shortly after a page loads, even if it never uses media, and scans
every plugin when the registry is cold (the first launch of a user, and after each update of the system's plugins): up to
1.7 s during which the WebSocket handshake and the frames of the page are blocked. Disabling the media settings of the
view does not prevent it, and WebFront cannot know in advance whether a page will use media. An application whose pages
never use `<audio>`, `<video>` or Web Audio therefore opts out with `WebFrontConfig::window.media = false`: WebKit's
processes are launched with an empty `GST_PLUGIN_SYSTEM_PATH_1_0` and `GST_PLUGIN_PATH_1_0` and a registry of the
application's profile (`no-media-registry.bin`, so that the user's own registry is never rewritten). The variables are set from the creation of the view, which makes
WebKit launch a spare web process, until the page reports that its load started (or the one-second delay expires), then
restored. WebKitGTK offers no per-process environment, so **the variables are process-wide during that window**, a few
hundred milliseconds at the start of the session: a thread that initializes GStreamer in the application during it
reads the empty plugin directory and keeps that configuration after the restoration, and a process the application
starts during it inherits the variables. An application that starts GStreamer or child processes from other threads
at startup must keep `media = true` or wait for its page before doing so. A web process launched later in the session
(a process swap) runs without the restriction: it initializes GStreamer as usual, only slower. **A page that does use media
after the opt-out terminates its web process** (WebKitGTK cannot create its media elements without the plugins, and the
session fails with "web process terminated"), which is why the default is `true`. Other frontends ignore the option.

The cost of the first layout depends on the fonts of the page: fontconfig walks every installed font for each family it
cannot find or that is a CSS generic such as `system-ui` or `ui-monospace`, for each weight and style. A page that
lists several absent families (`"Segoe UI"`, `Inter`, `"JetBrains Mono"`, `Menlo`) can spend hundreds of milliseconds
before its first paint on a machine with thousands of fonts (hundreds of milliseconds measured on Ubuntu 26.04 with
WebKitGTK 2.52 and 2 333 installed fonts, for the stacks of one application). Even a generic or an installed family is
looked up once per variant, so a short stack does not make the first family free: it avoids the lookups of every family
that follows it. Keep stacks to a generic (`sans-serif`, `monospace`) or to a family you know to be installed, with no
absent families after it; the embedded pages, the starter and the examples do.

## Development and distribution

WebKitGTK has two **build modes**, independent of Debug/Release, `NDEBUG`,
Expand Down
6 changes: 6 additions & 0 deletions docs/WEBVIEW2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# WebView2 frontend

The native window starts nearly transparent while WebView2 loads the page. It becomes opaque after two animation frames
following `DOMContentLoaded`, or after one second if the page does not report a frame. The runtime startup deadline and
navigation diagnostics still apply. `WindowOptions::background` accepts `#rgb`, `#rrggbb` and `#rrggbbaa`; invalid or
empty values keep the default. The Win32 window uses the RGB components. WebView2 supports only alpha 0 or 255 for its
background, so nonzero alpha values are treated as opaque. Set `WEBFRONT_STARTUP_TRACE=1` to log startup milestones to stderr.

This page covers what is specific to WebView2. The rules shared by every frontend are in [Frontends](FRONTENDS.md).

[Back to the README](../README.md#choose-how-your-interface-opens)
Expand Down
8 changes: 8 additions & 0 deletions docs/WKWEBVIEW.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# WKWebView frontend (macOS)

The native window starts nearly transparent (alpha 0.01) while WKWebView loads the page. It becomes opaque when the initial document has finished loading
(`didFinishNavigation`; a page's animation frames are throttled in a window that is nearly transparent, so they cannot be
awaited as on the other frontends), or after one second if it has not; the timer runs in
the common run-loop modes, so it also fires while the system tracks a window move or resize. The startup deadline and
the navigation diagnostics still apply. `WindowOptions::background` accepts `#rgb`, `#rrggbb` and `#rrggbbaa`: it is the
colour of the window, shown through the view (which stops painting its own white behind a page that does not paint, through its `drawsBackground` key, which WebKit does not document) and, from macOS 12, of the area under the page when scrolling past its edge. A page that paints its own background covers it. A colour with an alpha below `ff` makes the window non-opaque, so that what is behind it shows through a transparent page. Hidden sessions (`visible = false`) skip the
presentation. Set `WEBFRONT_STARTUP_TRACE=1` to log the milestones to stderr.

`WKWebViewFrontend` opens a native AppKit window with the WebKit engine supplied by macOS.
It is optional and never changes `webfront::WebFront`'s system-browser default.

Expand Down
Loading
Loading