tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
82.59k stars 2.48k forks source link

[bug] WebKit2GTK 2.40 causes Tauri app to render slowly #7021

Closed X-m7 closed 11 months ago

X-m7 commented 1 year ago

Describe the bug

After my system got an update to WebKit2GTK 2.40 I noticed my Tauri+Preact app felt incredibly sluggish at some moments, and after some digging it appears that it's because after clicking on links (which is handled by the router from preact-iso) sometimes the contents of the webview does not refresh after I click on said link, giving the impression that the app froze, until I either hover over another item in the header bar or click anywhere in the app.

Here is a screen recording of the issue (notice for example how when I click on the "General" button the app doesn't switch to the proper page until after I hover over the "Home" button):

https://github.com/tauri-apps/tauri/assets/18729369/fcc6d145-486f-4a2b-8a05-e59c3b0a3a0d

Reproduction

This is a version of said app stripped down to just the headerbar and placeholders for each page, like in the recording: https://github.com/X-m7/scuffcommander/tree/stripped/configurator

Expected behavior

The app should be quite responsive, for example here is the same app after I downgraded WebKit2GTK back to 2.38.5:

https://github.com/tauri-apps/tauri/assets/18729369/f7ff9609-92d1-426e-bc0e-29791582be09

Platform and versions

[✔] Environment
    - OS: Arch Linux Rolling Release X64
    ✔ webkit2gtk-4.0: 2.40.1
    ✔ rsvg2: 2.56.0
    ✔ rustc: 1.69.0 (84c898d65 2023-04-16)
    ✔ Cargo: 1.69.0 (6e9a83356 2023-04-12)
    ✔ rustup: 1.26.0 (2023-05-04)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 20.2.0
    - npm: 8.19.2

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.1
    - @tauri-apps/api [NPM]: 1.3.0
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:8080/
    - framework: React

Stack trace

No response

Additional context

The code shown in the recordings has had all the Tauri specific code removed from the frontend so using a normal browser to connect directly to the dev web server works as well (via npm run serve), I tried Firefox 113.0.1 and Epiphany/GNOME Web 44.2 and the app works fine on those so it seems like a Tauri specific issue to me.

I also tried Epiphany after clearing all its data and cache to be sure, and the issue still does not occur there.

FabianLars commented 1 year ago

I'll still mark this as upstream since it works after downgrading to 2.38 without us having any 2.38/2.40 specific code. Maybe it works fine in Epiphany because they switched to gtk4 iirc 🤔

Thanks for the report and reproduction repo btw :)

X-m7 commented 1 year ago

Maybe it works fine in Epiphany because they switched to gtk4 iirc

That gave me the idea to try it with Midori since that still uses GTK3 and the webkit2gtk-4.0 API like Tauri according to its dependencies, and yep the bug is reproducible there too.

Should I close this and report it to upstream then? If so, do you happen to have a better idea of what I should name the upstream bug report?

FabianLars commented 1 year ago

I think keeping this here open for now i alright, just link to the upstream issue if you end up opening one.

If so, do you happen to have a better idea of what I should name the upstream bug report?

Not at all tbh.

cc @wusyong because he did a bit of upstream stuff with webkitgtk already.

wusyong commented 1 year ago

I have 2.40 but it looks fine to me. Let's see if anyone can reproduce it with 2.40 version.

X-m7 commented 1 year ago

For what it's worth I'm using KDE Plasma 5.27.5 on Wayland, but making the app or Midori run under XWayland (via GDK_BACKEND=x11) as well as switching to X11 entirely didn't solve the issue.

Also, I'm using an AMD GPU (Radeon 680M, included with the Ryzen 7 6800H CPU) and Mesa 23.0.3 in case that matters.

X-m7 commented 11 months ago

I'm no longer able to reproduce this issue, notably webkit2gtk is now at version 2.42.1 (among other system updates), but I haven't changed the app's code nor dependency versions at all, so it definitely seems like an upstream bug that's now fixed.

Current output of npm run tauri info for reference:

[✔] Environment
    - OS: Arch Linux Rolling Release X64
    ✔ webkit2gtk-4.0: 2.42.1
    ✔ rsvg2: 2.57.0
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (2023-05-04)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 20.8.1
    - npm: 10.2.1

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.1
    - @tauri-apps/api [NPM]: 1.3.0 (outdated, latest: 1.5.1)
    - @tauri-apps/cli [NPM]: 1.3.1 (outdated, latest: 1.5.5)

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:8080/
    - framework: React