Skip to content

[X11] WebView2 crash on Linux #23159

Description

@jonpryor

Current behavior 🐛

Splitting out from: #23142 (comment)

Use of WebView2 within Uno.Gallery crashes:

git clone https://github.com/unoplatform/Uno.Gallery.git
cd Uno.Gallery
git checkout 54a08b1587aa020a5651d61eb3a3023a79e89d72
sed -i '' 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.6.0-dev.216"/g' global.json
dotnet publish -c Release -r linux-arm64 -f net10.0-desktop -p:TargetFrameworkOverride=net10.0-desktop \
  -bl Uno.Gallery/Uno.Gallery.csproj -p:SelfContained=true -p:UseSkiaRendering=true
./Uno.Gallery/bin/Release/net10.0-desktop/linux-arm64/publish/Uno.Gallery 

Navigate to UI components > WebView in the left-hand tree, and the app immediately crashes:

fail: Uno.WinUI.Runtime.Skia.X11.X11NativeOverlappedPresenter[0]
      Couldn't get OverlappedPresenterState: _NET_WM_STATE does not exist on the window. Make sure you use an EWMH-compliant WM.
fail: Uno.WinUI.Runtime.Skia.X11.X11NativeOverlappedPresenter[0]
      Couldn't get OverlappedPresenterState: _NET_WM_STATE does not exist on the window. Make sure you use an EWMH-compliant WM.

(Uno.Gallery:8586): Gdk-CRITICAL **: 14:46:16.851: gdk_x11_window_get_xid: assertion 'GDK_IS_X11_WINDOW (window)' failed
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x0
  Serial number of failed request:  103
  Current serial number in output stream:  104

Expected behavior 🎯

No crash. WebView2 works.

How to reproduce it (as minimally and precisely as possible) 🔬

No response

Workaround 🛠️

No response

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Desktop (X11)

Uno.Sdk version (and other relevant versions) 📦

Uno.Sdk 6.6.0-dev.216.

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

This occurs on a Parallels VM, running an "Ubuntu 24.04.3 ARM64" image.

I also needed to run:

sudo apt install libwebkit2gtk-4.1-dev

in order to get the "unversioned" libwebkit2gtk-4.1.so which is used by a [DllImport]:

[DllImport("libwebkit2gtk-4.1.so", CallingConvention = CallingConvention.Cdecl)]

Activity

  1. added theissue type on Apr 29, 2026
  2. added
    triage/untriaged
    on Apr 29, 2026
  3. agneszitte commented on May 15, 2026

    @agneszitte
    Member

    @khaskoul, @jhanvi03 can you please validate the impact of this issue with the latest 6.6 Uno.Sdk stable versions please

    Don't hesitate to sync with @jonpryor, @Xiaoy312, and @ramezgerges to review the details, please

  4. khaskoul commented on May 15, 2026

    @khaskoul

    UnoApp1 (copy).zip

    @khaskoul, @jhanvi03 can you please validate the impact of this issue with the latest 6.6 Uno.Sdk stable versions please

    Don't hesitate to sync with @jonpryor, @Xiaoy312, and @ramezgerges to review the details, please

    I was able to reproduce the issue on both Uno Gallery and on an uno app with only a Webview

    fail: Uno.WinUI.Runtime.Skia.X11.LinuxSystemThemeHelper[0]
    System theme detection is only implemented for version 2 of the Settings portal, but version 1 was found
    
    fail: Uno.UI.WebView.Skia.X11.X11NativeWebView[0]
    libwebkit2gtk-4.1 was not found. Attempting to call ProcessNavigation with an HttpRequestMessage instance will crash the process.
    
    fail: Uno.UI.WebView.Skia.X11.X11NativeWebView[0]
    GLib exception
    System.DllNotFoundException: Unable to load shared library libgdk-3.so or one of its dependencies.
    
    Loader paths in the exception included:
    /home/khalil/UnoApp1/UnoApp1/bin/Debug/net10.0-desktop/linux-x64/libgdk-3.so: cannot open shared object file: No such file or directory
    /usr/lib/dotnet/shared/Microsoft.NETCore.App/10.0.7/libgdk-3.so: cannot open shared object file: No such file or directory
    
    Stack trace started at:
    Uno.UI.WebView.Skia.X11.X11NativeWebView.gdk_x11_window_get_xid(...)
    Uno.UI.WebView.Skia.X11.X11NativeWebView.<.ctor>b__13_0()
    GLib.Idle.IdleProxy.Handler()
    

    Copilot provided the following brief on the issue:

    What was happening
    The desktop app built successfully, but launching failed or crashed around WebView initialization.
    Runtime logs showed missing native dependencies for Linux WebView/X11, including:
    libwebkit2gtk-4.1 not found
    libgdk-3.so not found
    After installing those libraries, a second issue remained:
    X11 BadWindow / drawable is not a native X11 window under a Wayland session.
    Why it was happening
    Root cause 1: Missing Linux native packages required by Uno WebView on desktop.
    Root cause 2: Backend/display mismatch in the environment (Wayland session with X11-native WebView path), which caused invalid window-handle behavior.
    Root cause 3: Debug path/config drift after RID-specific output changes (desktop binary path needed linux-x64 folder).
    Proposed solution (implemented and validated)
    Install required Linux packages:
    libgtk-3-0
    libgtk-3-dev
    libwebkit2gtk-4.1-0
    libwebkit2gtk-4.1-dev
    Force desktop launch through X11 backend for stability in this environment:
    Added environment setting in UnoApp1/.vscode/launch.json
    Added environment setting in launchSettings.json
    Corrected desktop debug program path to RID output:
    UnoApp1/.vscode/launch.json
    Simplified Linux host backend setup to avoid mixed backend conflicts:
    Program.cs
    Added explicit runtime validation marker for WebView navigation:
    WebViewValidationPage.xaml.cs
    
  5. ramezgerges commented on May 15, 2026

    @ramezgerges
    Contributor

    This behaviour is documented in

    ### Wayland support
    When running on a Wayland environment, the `WebView` control requires the environment variable `GDK_BACKEND` to be set to `x11` to function correctly.
    ```bash
    export GDK_BACKEND=x11
    dotnet run
    ```
    . The issue is that, because the environment is actually Wayland masquerading as X11 through XWayland, libgdk will use the wayland backend by default and this doesn't work with out x11-centric logic. The fix is to force GDK to use X11.

    We should try setting this on startup instead of forcing users to figure this out. I've tried this before unsuccessfully through Environment.SetEnvorionmentVariable, which as @jonpryor mentioned to me, doesn't actually internally make the setenv call. More details at dotnet/runtime#4538 (comment). We would have to setenv ourselves.

  6. francoistanguay commented on Jul 1, 2026

    @francoistanguay
    Contributor
  7. khaskoul commented on Jul 20, 2026

    @khaskoul

    @jonpryor @ajpinedam @ramezgerges WebView2 no longer crashes however the site does not actually load.
    This issue only occurs on Linux.

    Tested using:
    Uno.Sdk/Templates: 6.7.0-dev.127
    Rider Plugin: 1.10.53

    Image
  8. self-assigned this
    on Jul 20, 2026
  9. jonpryor commented on Jul 21, 2026

    @jonpryor
    ContributorAuthor

    @khaskoul wrote:

    WebView2 no longer crashes however the site does not actually load.
    This issue only occurs on Linux.

    Tested using:
    Uno.Sdk/Templates: 6.7.0-dev.127
    Rider Plugin: 1.10.53

    Trying to repro:

    # because my VM is running low on disk space…
    rm -Rf ~/.nuget
    
    # repo setup
    git clone https://github.com/unoplatform/Uno.Gallery.git
    cd Uno.Gallery
    git checkout 1ee8365dbdfa59108481f1e0c2d717f5e1439583
    sed -i 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.7.0-dev.127"/g' global.json
    
    # debug build
    dotnet build -f net10.0-desktop Uno.Gallery/*.csproj

    Run the Debug build:

    ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.Gallery

    Once launched, click UI components > WebView.

    Right away, there's a problem: I cannot click UI components > WebView! I can't click anything in the left-hand "tree" panel!

    (Ruh roh.)

    Fortunately I can search. Click the Search 🔍 textbox, type WebView, and click the entry which is shown.

    The WebView page is shown.

    The WebView doesn't work, thus reproducing what @khaskoul has observed.

    App stdout contains:

    …
    fail: Uno.WinUI.Runtime.Skia.X11.X11NativeOverlappedPresenter[0]
          Couldn't get OverlappedPresenterState: _NET_WM_STATE does not exist on the window. Make sure you use an EWMH-compliant WM.
    …
    fail: Uno.UI.WebView.Skia.X11.X11NativeWebView[0]
          SetScrollingEnabled is not supported on the X11 target.
    

    As part of the When Did It Break? investigation, found a "workaround" for when the WebView contents aren't shown: scroll the UI components > WebView page. (Not the WebView within the page, but the right-most panel/page of the Uno.Gallery app.)

    This workaround does not work on 6.7.0-dev.127, showing how cursed this version is.

  10. jonpryor commented on Jul 21, 2026

    @jonpryor
    ContributorAuthor

    Given that everything is broken, can we narrow down what is broken?

    Let's use stable Uno.Sdk 6.6.29!

    sed -i 's/"Uno.Sdk": ".*"/"Uno.Sdk": "6.6.29"/g' global.json
    git clean -xdf
    dotnet build -f net10.0-desktop Uno.Gallery/*.csproj
    ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.Gallery

    The left-hand tree works! Yay!

    Clicking UI components > WebView immediately crashes the app.

    This is expected because #23635 isn't on 6.6.29, so export GDK_BACKEND and try again:

    export GDK_BACKEND=x11
    ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.Gallery

    This still results in the message:

    fail: Uno.WinUI.Runtime.Skia.X11.X11NativeOverlappedPresenter[0]
          Couldn't get OverlappedPresenterState: _NET_WM_STATE does not exist on the window. Make sure you use an EWMH-compliant WM.
    

    Click UI components > WebView, and two things of interest happen:

    Firstly, we get the same message to stdout about scrolling:

    fail: Uno.UI.WebView.Skia.X11.X11NativeWebView[0]
          SetScrollingEnabled is not supported on the X11 target.
    

    Secondly, the contents of the WebView are "wrong". The first time I tried this, it was blank, just as @khaskoul reported. My most recent time, it's "corrupted":

    Image

    Now, the "fun" thing: if I click a different item in the left-hand tree such as ViewBox, then click WebView again, it works!

    Image

    Note that this behavior is seen with current stable Uno.Sdk 6.6.29.

  11. jonpryor commented on Jul 21, 2026

    @jonpryor
    ContributorAuthor

    Time for my favorite activity: When Did It Break?

    Bad Uno.Sdk versions

    • 6.7.0-dev.123: Tree view does not work. Ctrl+F > "WebView" to navigate to UI Components > WebView works. WebView is initially empty; scrolling the WebView "panel" does not cause the WebView to be rendered.

    • 6.7.0-dev.127

    ¯\(ツ)/¯ versions:

    • 6.7.0-dev.10: behaves like "good-ish" 6.6.29, but worse: requires export GDK_BACKEND=x11. Have observed the "flakiness" with 6.6.29 in that sometimes it doesn't render until switching to a different UI component and back to WebView, have seen the WebView over the wrong part of the window entirely, and have seen it disappear and not get "refreshed" when returning to WebView:

      Image

      Scrolling the Gallery window often fixes rendering.

    • 6.7.0-dev.50: Similar to 6.7.0-dev.10: requires export GDK_BACKEND=x11. First time I viewed UI components > WebView, nothing was shown ("bad"), but after scrolling the WebView page, the WebView content was updated and shown.

    • 6.7.0-dev.70: Similar to 6.7.0-dev.10: requires export GDK_BACKEND=x11. Tree view works! First time I viewed UI components > WebView, nothing was shown ("bad"), but after scrolling the WebView page, the WebView content was updated and shown.

    • 6.7.0-dev.80: Similar to 6.7.0-dev.10: requires export GDK_BACKEND=x11. Tree view works! First time I viewed UI components > WebView, nothing was shown ("bad"), but after scrolling the WebView page, the WebView content was updated and shown.

    • 6.7.0-dev.88: The tree view works. The WebView is shown, but in the wrong part of the screen, the same as 6.7.0-dev.101.

    • 6.7.0-dev.93: The tree view works. The WebView is shown, but in the wrong part of the screen, the same as 6.7.0-dev.101.

    • 6.7.0-dev.95: The tree view works. The WebView is shown, but in the wrong part of the screen, the same as 6.7.0-dev.101.

    • 6.7.0-dev.97: Tree view does not work. The WebView is shown, but in the wrong part of the screen, the same as 6.7.0-dev.101.

    • 6.7.0-dev.101: Tree view does not work. The WebView is shown, but in the wrong part of the screen.
      Image

      stdout is full of "X11 protocol error" messages:

      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_ReparentWindow, MinorCode: 0, ResourceId: 0x0, Serial: 313
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_UnmapWindow, MinorCode: 0, ResourceId: 0x0, Serial: 314
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_GetWindowAttributes, MinorCode: 0, ResourceId: 0x0, Serial: 316
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_ChangeWindowAttributes, MinorCode: 0, ResourceId: 0x0, Serial: 318
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_ReparentWindow, MinorCode: 0, ResourceId: 0x0, Serial: 319
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: 131, MinorCode: 46, ResourceId: 0x0, Serial: 1181
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_MapWindow, MinorCode: 0, ResourceId: 0x0, Serial: 321
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_GetProperty, MinorCode: 0, ResourceId: 0x0, Serial: 323
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_ConfigureWindow, MinorCode: 0, ResourceId: 0x0, Serial: 325
      warn: Uno.WinUI.Runtime.Skia.X11.X11ApplicationHost[0]
            X11 protocol error — ErrorCode: 3, RequestCode: X_ConfigureWindow, MinorCode: 0, ResourceId: 0x0, Serial: 326
      
    • 6.7.0-dev.107: Tree view does not work. Ctrl+F > "WebView" to navigate to UI Components > WebView works. WebView is initially empty; scrolling the WebView "panel" causes the WebView to be rendered.

    • 6.7.0-dev.115: Tree view does not work. Ctrl+F > "WebView" to navigate to UI Components > WebView works. WebView is initially empty; scrolling the WebView "panel" causes the WebView to be rendered.

      Image
    • 6.7.0-dev.121: Tree view does not work. Ctrl+F > "WebView" to navigate to UI Components > WebView works. WebView is initially empty; scrolling the WebView "panel" causes the WebView to be rendered.

    Good (-ish?) Uno.Sdk versions:

  12. jonpryor commented on Jul 21, 2026

    @jonpryor
    ContributorAuthor

    Summary of When Did It Break?:

    The tree view broke between 6.7.0-dev.95 and 6.7.0-dev.97:

    The web view was "wonky" for quite some time, and was never necessarily "stable" or "reliable", but it stopped working between 6.7.0-dev.121 and 6.7.0-dev.123:

  13. jonpryor commented on Jul 21, 2026

    @jonpryor
    ContributorAuthor

    One oddity in theWebView2 breakage between 6.7.0-dev.121 and 6.7.0-dev.123: it's not only because of Uno.UI.WebView.Skia.X11.dll.

    Build Uno.Gallery using Uno.Sdk 6.7.0-dev.123, then:

    mv ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.UI.WebView.Skia.X11.dll ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.UI.WebView.Skia.X11.dll.bk
    cp $HOME/.nuget/packages/uno.winui.webview.skia.x11/6.7.0-dev.804/lib/net10.0/Uno.UI.WebView.Skia.X11.dll ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.UI.WebView.Skia.X11.dll
    ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.Gallery

    The WebView2 does not work! (This does not make sense to me.)

    Edited-to-add: to make this work we need to replace Uno.UI.Runtime.Skia.X11.dll, not Uno.UI.WebView.Skia.X11.dll:

    cp $HOME/.nuget/packages/uno.winui.runtime.skia.x11/6.7.0-dev.804/lib/net10.0/Uno.UI.Runtime.Skia.X11.dll  Uno.Gallery/bin/Debug/net10.0-desktop

    So try the opposite: build Uno.Gallery using Uno.Sdk 6.7.0-dev.121, verify that the WebView2 works 1, then:

    mv ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.UI.WebView.Skia.X11.dll ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.UI.WebView.Skia.X11.dll.bk
    cp $HOME/.nuget/packages/uno.winui.webview.skia.x11/6.7.0-dev.815/lib/net10.0/Uno.UI.WebView.Skia.X11.dll ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.UI.WebView.Skia.X11.dll
    ./Uno.Gallery/bin/Debug/net10.0-desktop/Uno.Gallery

    The WebView2 doesn't work. (This at least makes sense to me.)

    Footnotes

    1. note that "work" means "if the web page isn't shown, scroll the page to cause the WebView to render". ↩

  14. added a commit that references this issue on Jul 23, 2026
    3d4bf9d
  15. khaskoul commented on Aug 17, 2026

    @khaskoul

    Fix verified with:
    Templates/SDK: 6.7.10
    Platform(s): Desktop
    OS: Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

triage/untriaged

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions