tauri: [bug] Bad performance on linux

Describe the bug

I’m experiencing very bad performance on linux when handling lots of DOM elements. In my project you can drag select items, and selecting lots of them causes ui to lag/freeze on linux.

I made repo that demonstrates the problem: https://github.com/aalhitennf/tauri-performance

Reproduction

  1. Clone the repo
  2. Install packages with npm install
  3. Build with npm run build
  4. Run the executable from src-tauri/target/release
  5. Start drag selecting items with left mouse button (default file manager behaviour) from up to down and let the autoscroll happen on window border
  6. UI starts to lag a lot

Expected behavior

App runs flawlessly in firefox (linux), electron (linux) and when built on windows, problem happens only on my linux installation.

Platform and versions

Environment
  › OS: Arch Linux Rolling Release X64
  › Node.js: 17.9.0
  › npm: 8.5.5
  › pnpm: 6.32.11
  › yarn: Not installed!
  › rustup: 1.24.3
  › rustc: 1.60.0
  › cargo: 1.60.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu  

webkit2gtk 2.36.1-1

Stack trace

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 25 (8 by maintainers)

Most upvoted comments

I don’t think this issue should be closed.

I don’t mean to sound rude, but performance on linux is currently atrocious due to webkitgtk.

I have a very basic app, interacting with a content editable in the app causes paints to take between 70-300ms, just to enter a single character. I’m using a 2021 Dell XPS, needless to say anything else performs just fine. It also performs great on all other platforms, never dropping below 60fps, never a dropped frame. (Including macOS which is also webkit 😕 )

I think there are a couple possible paths forward:

  1. Using gtk4 and webkitgtk5 (A lot of people are saying big performance improvements there)
  2. Use a different webview (Qt WebEngine, CEF, other…)

Hey @LifeIsStrange - we are not planning on making Servo into a browser. The research right now is to turn it into a webview, which is a much different value proposition.

At first glance at your code, you’re creating about 3000 DOM element and that is expected to have lags and ui freezes for two reasons:

  1. DOM operations are slow and expensive
  2. you’re using react which performs the worst among frameworks in terms of performance

What you should do:

  1. test your app on some browsers, like epiphany (especially this one), firefox and chrome and see if you still have lags or not. If not, please let me know.
  2. When dealing with these humongous number of DOM elements, it is my recommendation to always use a virtual scroller. It greatly helps performance.
  3. (Highly optional and a mere suggestion) Choose a faster framework. I’d recommend preact or solidjs, they both has a similar style to react but much faster especially solidjs.

Any guides on how to improve the performance on linux?

I recently turned to Asahi linux on a MBP Max, the basic tauri app built with Solid.js is basically unusable on linux, even the css animation is laggy, while on macOS it’s all good.

Hi! I’m curious how the development of servo as an alternative target webview is going.

I don’t see any more mentions of servo in the github org or on twitter. There is a servo discussion where tauri was mentioned late last year, but nothing since.

Is this design still being considered? Is the development public?

WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS is the default value (and it’s also not an env var if i got that right). I guess it’s just webkit(gtk) not holding up that well🤷 Oh and hardware acceleration in a browser context was/is generally in a bad state on linux, so maybe that adds up too.

SolidJS actually improved performance greatly. There is still slight “lag” or choppiness, doesn’t feel as smooth as in other browsers/platforms but i guess that is fine for now since handling that large amount of elements is very rare case. I’ll look into the virtual scroller too.