From e01fb646663d561f193e7f2acef9566c6fedcaa7 Mon Sep 17 00:00:00 2001 From: Albert Date: Fri, 22 Nov 2024 15:40:28 -0500 Subject: [PATCH] Fix macOS WebView CPU Usage --- src/webui.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/webui.c b/src/webui.c index f9a21d57d..709abbc48 100644 --- a/src/webui.c +++ b/src/webui.c @@ -11413,32 +11413,26 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) { while (true) { - // Messages ... + // 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) { _webui_macos_wv_close(win->webView->index); 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; @@ -11446,6 +11440,12 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) { } } } + else { + + // At this moment, there is no WebUI messages + // let's IDLE for 250ms in this current thread. + _webui_sleep(250); + } } }