Skip to content

Commit 7bfb37a

Browse files
authored
Implement GTK event processing in while javascript call (Gtk WebView)
Add GTK event handling for webview on Linux when a call is made to javascript. Reason: If no Gtk Events are processed during javascript calls, the application can lock up. A very simple use case to make the GtkWebView lock up: ```c char response[64]; webui_script(win, "alert('hi');return 4 + 6;", 0, response, 64); ```
1 parent 3093057 commit 7bfb37a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/webui.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,13 @@ bool webui_script_client(webui_event_t* e, const char* script, size_t timeout,
953953
_webui_mutex_lock(&_webui.mutex_js_run);
954954
js_status = _webui.run_done[run_id];
955955
_webui_mutex_unlock(&_webui.mutex_js_run);
956+
#if __linux__
957+
if (_webui.is_webview) {
958+
while (gtk_events_pending()) {
959+
gtk_main_iteration_do(0);
960+
}
961+
}
962+
#endif
956963
if (js_status)
957964
break;
958965
}
@@ -966,6 +973,13 @@ bool webui_script_client(webui_event_t* e, const char* script, size_t timeout,
966973
_webui_mutex_lock(&_webui.mutex_js_run);
967974
js_status = _webui.run_done[run_id];
968975
_webui_mutex_unlock(&_webui.mutex_js_run);
976+
#if __linux__
977+
if (_webui.is_webview) {
978+
while (gtk_events_pending()) {
979+
gtk_main_iteration_do(0);
980+
}
981+
}
982+
#endif
969983
if (js_status)
970984
break;
971985
if (_webui_timer_is_end(&timer, (timeout * 1000)))

0 commit comments

Comments
 (0)