From d3ee7c70f9f2877a31012be55b513e32509127d8 Mon Sep 17 00:00:00 2001 From: kiennt Date: Thu, 30 Jul 2026 13:35:28 +0700 Subject: [PATCH] Fix dead GUI on Windows: serve UI over HTTP and prefer the Qt backend On Windows the GUI opened but was completely inert: every button did nothing, the status bar was stuck on "CUDA: OFF" and no translation ever loaded. Two independent causes, both needed fixing. 1. The UI is loaded from a file:// URL. pywebview 5+ does not expose the js_api bridge to file:// pages, and Chromium blocks fetch() there too, so ui/config.json and ui/lang/*.json never loaded either. Tracing every js_api method showed zero calls arriving from JS over 25s. Serving the same page through pywebview's local HTTP server fixes both. 2. Even over HTTP, the default WebView2 backend wires up the bridge only about half the time. Measured over repeated cold launches: WebView2 4/8 runs healthy (the rest render the page but never connect, some hanging the UI thread outright), pywebview 5.4 0/6, Qt backend 7/7. So prefer the Qt backend on Windows when PySide6 is available, and fall back to the previous behaviour when it is not. requirements.txt: add PySide6 on Windows for the Qt backend, and mark PyGObject as Linux-only - it needs GTK/girepository plus Python dev libs, which the embedded Python from setup.ps1 does not ship, so it always fails there. Verified on Windows 11 with an RTX 3050: status bar reports CUDA/FFmpeg on, config and translations load, and Start Processing runs a file end to end from the GUI. Co-Authored-By: Claude Opus 5 (1M context) --- remwmgui.py | 17 ++++++++++++++++- requirements.txt | 7 ++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/remwmgui.py b/remwmgui.py index 1a15725..04b8ed4 100644 --- a/remwmgui.py +++ b/remwmgui.py @@ -482,7 +482,22 @@ def main(): ) api.set_window(window) - webview.start() + + # On Windows the default WebView2 backend only wires up the js_api bridge + # about half the time: the UI renders but no call ever reaches Python, so + # every button is dead. The Qt backend does it reliably, so prefer it. + gui = None + if sys.platform == 'win32': + try: + import PySide6 # noqa: F401 + gui = 'qt' + except ImportError: + pass + + # Serve the UI over a local HTTP server: pywebview 5+ does not expose the + # js_api bridge to pages loaded from file://, and fetch() of the config and + # language files is blocked there too. + webview.start(http_server=True, gui=gui) if __name__ == '__main__': diff --git a/requirements.txt b/requirements.txt index 4481e89..3117612 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,6 +14,9 @@ Pillow>=10.0.0 # GUI (PyWebview for brainrot HTML UI) pywebview>=4.0 +# Windows: the default WebView2 backend wires up the js_api bridge only about +# half the time, so remwmgui.py runs pywebview on its Qt backend instead. +PySide6; sys_platform == "win32" # Utilities loguru @@ -23,5 +26,7 @@ psutil pyyaml # qt and gtk gui -PyGObject +# PyGObject needs GTK/girepository and Python dev libs, neither of which exist +# in the embedded Python that setup.ps1 installs, so keep it off Windows. +PyGObject; sys_platform == "linux" qtpy