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 5 years ago
  • Reactions: 12
  • Comments: 32 (9 by maintainers)

Most upvoted comments

Can we reopen this issue?

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…)

Just to let other here know, this is apparently something on the radar of the Tauri team, according to their blog:

Things on our radar for the future we feel we should mention at least:

  • Providing or Bundling Chromium Embedded Framework (CEF) for Linux as an alternative to WebKit2GTK
  • Servo as Tauri WebView (POC in Wry)

See also: https://github.com/tauri-apps/wry/issues/1064

I was hoping to use Tauri for a simple application, but the performance was so bad I had to port it over to Electron instead. Hope there’s some plan for improving this, since the rest of Tauri seemed nice.

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.

a lot of work needed

yeah that’s a lot of work indeed. I didn’t knew you had a billion dollar budget to spend on fundamental R&D.

This is not a trivial task

You must be joking, if you manage to make servo become a functional web standard compliant browser, integrating QT webengine should feel very easy

@amrbashir you can improve the performance and correctness situation by bringing support for a chromium webview in Linux. This would allow cross platform consistency with windows. You might leverage e.g the QT webengine

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.

Nah, all good. We don’t mind further examples of bad webkitgtk performance. It won’t change our plans though (we still want to replace it / offer alternatives, it just takes time especially with such a small team that’s busy elsewhere). I heard the gtk4 version performs slightly better though and that upgrade is also underway as a stepping stone so maybe that’ll help as well.

Same here. I have to virtualize a list of a couple thousand elements. On Windows it goes smooth as butter. Tested it on Chrome and Firefox, and smooth there too; on Linux (Fedora 40) it is atrocious: entries disappearing, lagging animations, even simple functions take a noticeable amount of time. Using webkit2gtk4.1

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?

Browser [Left] on both images Image Image

Experiencing direct 50% FPS drops on dev and build both on linux. tested on React tsx + Rust and Solid tsx + Rust.

72fps on Charge ((dev/build) binary) vs 144fps consistent on Browser (Zen) 32fps on battery vs 120fps on browser

Maybe it’s a issue specific to my laptop. But there seems to be no discussion about this being a thing besides this one. So i had to bring this to attention. Apologies if this was a dead bump and a silly mistake on my part.

I’ve encountered a similar situation as well. Our company initially started front-end development using Electron, but later on, we considered improving application performance with Tauri. However, when we ported the Tauri-developed application to ARM Linux, its smoothness was even worse than Electron. Additionally, I don’t believe the WebKit version on our system is very low; it’s webkit2gtk-4.0.

Have you tried it on windows? I think the issue is with webkit on Linux from what ive read so far but i don’t now first hand. In my case there’s stuttering or frame lag any time there’s any animation. Its very annoying and i have to turn animation off. The same application runs like butter on Linux Chrome.

I think the issue is with webkit on Linux. Is anyone experienceing lags because of animations?

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.

@amrbashir You can’t be serious… I’ve actively followed servo development since the day it was opensourced and while an interesting technical project it is nowhere near a real browser, it has broken rendering/funcionality on countless websites. Even its development has mostly stalled. Tauri has a real value proposition over electron, to not duplicate the webview per app and only download it if not already present on the system. the windows/linux webview inconsistency of using webkit is a major flaw for end users that brings so many limitations, missing features, inconsistencies, correctness and performance bugs. Using the qtwebengine would enable consistent chromium support, which is not a lot to ask, and you could retain support for webkit on linux optionally. Bringing support for servo will solve nothing for end users. Although I understand it is an opensource project and maybe a hobby project so if that’s what personally interest you, go for it! But as for end users needs, that’s not the actual need.

@lucasfernog friendly ping

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.