webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
3.06k stars 184 forks source link

Linux WebView high CPU usage #511

Open Hejsil opened 1 week ago

Hejsil commented 1 week ago

When running webui with WebView as the browser the program ends in the following busy loop:

https://github.com/webui-dev/webui/blob/d5b25ca1a827d3ec07be9607232edb0c27172918/src/webui.c#L3099-L3101

This causes high CPU usage. Is there a reason why blocking = false is passed to gtk_main_iteration_do?

AlbertShown commented 1 week ago

the program ends

You mean unwanted exit, like a crash? Or a normal exit?

Is there a reason why blocking = false is passed to gtk_main_iteration_do?

I guess if blocking = true the websocket server will be blocked or something... you can easily test it to be sure. just change the line, and run make.

Hejsil commented 1 week ago

the program ends

You mean unwanted exit, like a crash? Or a normal exit?

Aaah no. I guess that is bad phrasing. The program will spin on this loop (100% CPU usage) after opening a window. So the program "ends up" here once the window has been opened.

Hejsil commented 1 week ago

I guess if blocking = true the websocket server will be blocked or something... you can easily test it to be sure. just change the line, and run make.

Aah ok. Just tested a little further. It does not seem this is the loop that causes 100% CPU usage. I just assumed (my bad)