slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.56k stars 604 forks source link

high cpu usage on idle #5780

Closed sigmaSd closed 3 months ago

sigmaSd commented 3 months ago

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
tronical commented 3 months ago

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

tronical commented 3 months ago

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.

sigmaSd commented 3 months ago

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

tronical commented 3 months ago

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