Skip to content

Commit

Permalink
Fix macOS WebView CPU Usage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertShown committed Nov 22, 2024
1 parent 984de15 commit e01fb64
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/webui.c
Original file line number Diff line number Diff line change
Expand Up @@ -11413,39 +11413,39 @@ 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;
_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 e01fb64

Please sign in to comment.