tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Cannot run WebGL renders in the Tauri desktop app. WebGL: Context lost

Open AsgrimS opened this issue 1 year ago • 13 comments

Describe the bug

When I try to implement three.js scenes into my tuari app it doesn't work at all in the app window, but it works when I open the app in the browser directly.

My console of the desktop app is spammed with WebGL: context lost and my CPU usage skyrockets image

Reproduction

  1. Clone ~~https://github.com/AsgrimS/dice-nexus~~ -> https://github.com/AsgrimS/tauri-webgl
  2. pnpm install
  3. pnpm tauri dev

Expected behavior

Working WebGL render in both browser and desktop app

image

Platform and versions

Environment
  › OS: Arch Linux Unknown X64
  › Node.js: 18.12.1
  › npm: 8.19.2
  › pnpm: 7.30.3
  › yarn: 3.3.1
  › rustup: 1.25.2
  › rustc: 1.67.1
  › cargo: 1.67.1
  › Rust toolchain: stable-x86_64-unknown-linux-gnu

Stack trace

No response

Additional context

No response

AsgrimS avatar Mar 25 '23 16:03 AsgrimS

Could you also try it in the epiphany browser (also known as "gnome web")? Just to double check if it's tauri specific or webkitgtk as a whole.

FabianLars avatar Mar 25 '23 16:03 FabianLars

Could you also try it in the epiphany browser (also known as "gnome web")? Just to double check if it's tauri specific or webkitgtk as a whole.

Hi, thanks for the fast reply.

I opened it in epiphany and the issue is the same as in the desktop app, so it's probably an issue with webkitgtk. ( The previous attempt that worked was in Brave browser )

AsgrimS avatar Mar 25 '23 16:03 AsgrimS

Damn, that's unfortunate. They just introduced webgl2 support in webkitgtk 2.40 so it either broke something or their webgl2 implementation isn't quite compatible with threejs or something? 🤔 I'm gonna play around with your reproduction repo after the weekend when i have access to my Linux machine again!

FabianLars avatar Mar 25 '23 16:03 FabianLars

I checked and I had webkit2gtk=2.40.0-2 installed. I've downgraded it to webkit2gtk=2.38.5-1 and render inside the tauri desktop app window started to work. image

I think this pretty much confirms the fact that the update for webkitgtk broke things. In the epiphany it still doesn't work but it's probably bundled with the new webkitgtk or sth.

AsgrimS avatar Mar 25 '23 17:03 AsgrimS

a user having this issue also told me WEBKIT_DISABLE_COMPOSITING_MODE=1 helps

ImUrX avatar Aug 12 '23 18:08 ImUrX

Same issue here, I can't use MapLibre GL JS on Tauri. Any suggestions? Should I also downgrade the webkit2gtk version?

keremnymn avatar Sep 01 '23 11:09 keremnymn

I checked and I had webkit2gtk=2.40.0-2 installed. I've downgraded it to webkit2gtk=2.38.5-1 and render inside the tauri desktop app window started to work. image

I think this pretty much confirms the fact that the update for webkitgtk broke things. In the epiphany it still doesn't work but it's probably bundled with the new webkitgtk or sth.

how to downgrade to webkit2gtk=2.38.5-1 ?

qqkkwan avatar Nov 20 '23 03:11 qqkkwan

In my case the canvas does not even return a render context. It returns null with both WebGL and 2D.

I have reinstalled Ubuntu 22.04 from scratch and only configured the bare minimum needed to run my application, so I have a pretty clean install. With this configuration I have libwebkit2gtk installed like this:

$ dpkg -l | grep webkit2gtk
ii  libwebkit2gtk-4.0-37:amd64                 2.42.2-0ubuntu0.22.04.1                               amd64        Web content engine library for GTK
ii  libwebkit2gtk-4.0-dev:amd64                2.42.2-0ubuntu0.22.04.1                               amd64        Web content engine library for GTK - development files

How can I downgrade to webkit2gtk=2.38.5-1?

ferserc1 avatar Nov 24 '23 08:11 ferserc1

@ferserc1 I overcame this issue by installing Ubuntu Mantic release.

keremnymn avatar Nov 24 '23 08:11 keremnymn

same problem happens on Arch/EndeavourOS too, but no way to downgrade to 2.38.5-1 (to much to downgrade in a rolling release OS)

[⚠] Environment
    - OS: EndeavourOS Rolling Release X64
    ✔ webkit2gtk-4.1: 2.42.3
    ✔ rsvg2: 2.57.0
    ✔ rustc: 1.74.1 (a28077b28 2023-12-04) (Arch Linux rust 1:1.74.1-1)
    ✔ cargo: 1.74.1

image

Links2004 avatar Dec 11 '23 22:12 Links2004

Im also having the exact same issue as @Links2004.

What is curious is that in my desktop computer, which runs endeavourOS im having the issue (nvidia graphics card and no integrated GPU), but on my notebook running Ubuntu, also using the libwebkit2gtk version 2.42.4, it works flawlessly. Makes me wonder if it isn't related to the NVIDIA GPU in some way.

caprilesport avatar Feb 06 '24 19:02 caprilesport

Btw this only happens in nvidia x11 desktop environments

ImUrX avatar Feb 06 '24 20:02 ImUrX

What can we do as app developer to ensure end users can use our tauri app with webgl? This feels like a critical limitation of tauri delegating webview to the OS..

atinylittleshell avatar Feb 11 '24 03:02 atinylittleshell