Skip to content

Commit

Permalink
Fix Linux WebView CPU Usage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertShown committed Nov 22, 2024
1 parent 3084ff3 commit 984de15
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/webui.c
Original file line number Diff line number Diff line change
Expand Up @@ -11190,36 +11190,38 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {

while (true) {

if (_webui_mutex_is_webview_update(win, WEBUI_MUTEX_NONE)) {
// Check if there is any WebUI Messages

if (_webui_mutex_is_webview_update(win, WEBUI_MUTEX_NONE)) {
_webui_mutex_is_webview_update(win, WEBUI_MUTEX_FALSE);

if (win->webView) {

// Stop this thread
if (win->webView->stop) {
break;
}

// Window Size
if (win->webView->size) {
win->webView->size = false;
_webui_wv_set_size(win->webView, win->webView->width, win->webView->height);
}

// Window Position
if (win->webView->position) {
win->webView->position = false;
_webui_wv_set_position(win->webView, win->webView->x, win->webView->y);
}

// Navigation
if (win->webView->navigate) {
win->webView->navigate = false;
_webui_wv_navigate(win->webView, win->webView->url);
}
}
}
else {

// At this moment, there is no WebUI messages
// let's IDLE for 250ms in this current thread.
_webui_sleep(250);
}
}
}

Expand Down

0 comments on commit 984de15

Please sign in to comment.