Skip to content

fix(webview): enable WebGL on OffscreenCanvas in WebKitGTK views - #268

Merged
zackees merged 2 commits into
release/0.1.3from
fix/offscreen-canvas-webgl
Sep 15, 2026
Merged

zackees merged 2 commits into
release/0.1.3from
fix/offscreen-canvas-webgl

Conversation

@zackees

@zackees zackees commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

WebKitGTK ships its AllowWebGLInWorkers runtime feature disabled. Despite the name, it gates WebGL on every OffscreenCanvas, including canvases a document creates. As a result, new OffscreenCanvas(1, 1).getContext('webgl2') returns null in Linux webviews, while Chromium, Firefox and Safari 17+ expose these contexts by default. This blocked FastLED's viewer (FastLED/cli#247), whose browser-compatibility gate requires OffscreenCanvas WebGL2.

The Linux adapter now enables the feature on each new view's settings, after bridge removal and before the first navigation.

  • The WebKitGTK 2.42+ feature API (webkit_settings_get_all_features, webkit_settings_set_feature_enabled, …) is resolved at run time with dlsym(RTLD_DEFAULT). The published webkit2gtk bindings stop at 2.40, and linking the symbols directly would prevent older WebKitGTK hosts from loading. Those hosts keep the engine default.
  • The change is private to src/tauri/linux_webkitgtk.rs plus one call in src/tauri.rs; no public API changes.

Evidence

Check Result
New offscreen-webgl smoke scenario, facade call disabled (RED) webgl2=0, fails
Same scenario with the fix (GREEN) passes
Existing smoke scenarios: close, bootstrap, redirect, timeout, cancel, window-close pass
webkit_settings_enable_offscreen_canvas_webgl unit test (display-free settings, enable + read back) pass
cargo clippy --features tauri-webview-test-support --all-targets -D warnings, cargo fmt --check pass

All smoke runs used the CI lane's environment: Xvfb, GDK_BACKEND=x11, LIBGL_ALWAYS_SOFTWARE=1, WEBKIT_DISABLE_COMPOSITING_MODE=1, WebKitGTK 2.52.5. The scenario is added to the tauri-webview-smoke CI job.

Known limitation (not addressed here)

With the feature enabled, WebKitGTK 2.52 still lets only the first thread to create a WebGL context succeed; a later context on another thread returns null. On NVIDIA 595.99.02 under Wayland, a document WebGL2 context followed by worker rendering on a transferred canvas breaks the UI process (Error 71 (Protocol error) dispatching to Wayland display) and crashes the web process in NVIDIA EGL during GL context teardown. This reproduces in the stock MiniBrowser, so it is an engine/driver issue to report upstream, not something this facade should work around. Tracked in FastLED/cli#247.

This PR targets release/0.1.3 for the v0.1.4 release. A matching PR against main follows.

Refs FastLED/cli#247, FastLED/cli#229.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG

WebKitGTK ships its AllowWebGLInWorkers runtime feature disabled. That feature
gates WebGL on every OffscreenCanvas, including canvases a document creates,
so pages that probe or render through OffscreenCanvas get no WebGL context in
Linux webviews. Chromium, Firefox and Safari 17+ enable these contexts by
default.

The Linux adapter now enables the feature on each view's settings before its
first navigation. The WebKitGTK 2.42+ feature API is resolved at run time from
the loaded library, because the published bindings stop at 2.40 and a direct
link would stop older hosts from loading. Those hosts keep the engine default.

Tests:
- Unit test enables the feature on a display-free WebKitSettings object and
  reads it back.
- New offscreen-webgl smoke scenario (added to the Xvfb CI lane) reports
  webgl2=0 with the facade call disabled and passes with it enabled.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
Creating a WebKitSettings object initializes GTK style and settings state,
which aborts the whole test binary when no display connection exists. The
rust-native job runs `cargo test --all-features` without a display, so the
test is now ignored there and run explicitly with `--ignored` in the
tauri-webview-smoke job under xvfb-run.

Reproduced locally by hiding every display and the default Wayland socket:
the test binary segfaulted in GTK style-provider assertions. With the
attribute, the headless run reports the test as ignored and the Xvfb run
passes it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
@zackees
zackees merged commit 2b605c3 into release/0.1.3 Sep 15, 2026
54 checks passed
zackees added a commit that referenced this pull request Sep 15, 2026
Release on release/0.1.3 containing #268 (enable WebGL on OffscreenCanvas in
WebKitGTK views) on top of v0.1.3.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
zackees added a commit to FastLED/cli that referenced this pull request Sep 15, 2026
kernal-api v0.1.4 enables WebKitGTK's AllowWebGLInWorkers runtime feature in
its Linux webview adapter (forge-ci/kernal-api#268). WebKitGTK ships it
disabled, and it gates WebGL on every OffscreenCanvas, so the viewer's WebGL2
compatibility gate always failed on Linux. The fix lives in kernal-api; no
local workaround is added here.

- Pin the workspace dependency to the v0.1.4 tag and require it in the
  boundary test.
- Log the frontend's OffscreenCanvas WebGL2 probe as unavailable when
  getContext returns null, instead of reporting SUCCESS unconditionally.
- Correct the migration audit: the shared #247 failure was the WebKitGTK
  feature flag, not host GL. A WebKitGTK 2.52 + NVIDIA Wayland crash with
  document plus worker WebGL still blocks real rendering and is tracked
  upstream in #247.

Refs #229, #247

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
zackees added a commit that referenced this pull request Sep 15, 2026
Release on release/0.1.3 containing #272, which reverts #268 (forced
WebGL on OffscreenCanvas in WebKitGTK views). Code-wise this is v0.1.3.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
zackees added a commit to FastLED/cli that referenced this pull request Sep 15, 2026
kernal-api v0.1.5 reverts forge-ci/kernal-api#268, so WebKitGTK views keep
their default of no WebGL on OffscreenCanvas. The viewer now renders on
the main thread in that case (previous commit), which is the path the
pre-migration viewer used. Forcing worker WebGL froze the canvas on NVIDIA
Wayland.

The migration record now corrects the earlier claim that #247 was an
upstream WebKitGTK/driver crash. It records the renderer comparison and
the Linux --test results.

Refs #247

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VfXV1EpgAvMZzXJfbGZPRG
@zackees
zackees deleted the fix/offscreen-canvas-webgl branch November 5, 2026 05:51
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.

1 participant