slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.

Home Page:https://slint.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

high cpu usage on idle

sigmaSd opened this issue · comments

linux fedora 40 wayland

import * as slint from "npm:slint-ui@1.7.1";
const ui = slint.loadSource(
  "export component Window { }",
  "main.js",
);
new ui.Window().run();
deno run -A a.ts # uses 100 % of one cpu core

if I force the app to run on xwayalnd the cpu usage becomes normal

WAYLAND_DISPLAY="" deno run -A a.ts #normal cpu usage

This is also reproducible with Node.js on Linux with Wayland. I'm not sure what's causing the constant activity, but I strongly suspect that it's related to the event loop polling.

This is not fixable with Deno, but with Node.js there is a way with #4469

I'll close this as Duplicate of #4469 as we can't fix this with Deno, but with Node.js I'm sure there's a way. This remains a valid issue of course, but it belongs to #4469.

When I increase the timeout https://github.com/slint-ui/slint/blob/master/api/node/index.ts#L994 the issue remains, but instead of 100%cpu all the time, it becomes 100 % for couple of seconds then normal then 100 % for a couple of seconds, etc

only if I comment out processEvents, it disappears

Right, this is the winit event loop pumping at full speed with wayland, for some reason.