webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.63k stars 157 forks source link

Chromium headless mode on Windows #222

Closed fibodevy closed 10 months ago

fibodevy commented 10 months ago

I have a few quick questions for someone who can confirm:

Does WebUI in headless mode webui_set_hide(window, true) on Chromium based browsers (Chrome/Edge especially) on Windows OS work for you? Did new processes spawned? How long they lived?

hassandraga commented 10 months ago
[Loop] webui_wait()...
[Loop] webui_wait() -> Timeout in 30 seconds
[Loop] webui_wait() -> Waiting for connected UI...
[Core]          [Thread] _webui_server_start([1]) -> Listening success
[Core]          [Thread] _webui_server_start([1]) -> Infinite loop...

I'm investigating this right now.

hassandraga commented 10 months ago

Thank you for reporting this. The issue was that --headless is deprecated. Now we should use --headless=new. Fixed https://github.com/webui-dev/webui/commit/edc8617e96c260ec4153b7408c73f4a1053d2c1e

fibodevy commented 10 months ago

GJ. I will test tomorrow. I have more issues, maybe you want to take a look at this:

Edge

Processes does not exist

   0s * parent PID = 1332
   0s *  child PID = 7340
   0s * window URL = http://localhost:37134
   0s doing ping, interval 1s...
   0s webui_script() call with: return "pong"
  30s webui_script() failed
  31s webui_script() call with: return "pong"
  63s webui_script() failed

In webui_script I specified timeout as 1 second, yet it takes 30s.

Firefox

Processes do exist

   0s doing ping, interval 1s...
   0s webui_script() call with: return "pong"
  31s webui_script() failed
  32s webui_script() call with: return "pong"
  32s webui_script() result = pong
  33s webui_script() call with: return "pong"
  34s webui_script() result = pong

The first call will fail because webui.js is not yet loaded. This is okay, but why timeout is 30s? Adding little sleep to allow browser to parse all files and connect to WS solves it.

hassandraga commented 10 months ago

In webui_script I specified timeout as 1 second, yet it takes 30s.

Good reports! 👍 I forgot to implement _webui_timer_t in webui_script(). Fixed https://github.com/webui-dev/webui/commit/5e17a037c11e977acde6640ed58428bc04acf7a2

fibodevy commented 10 months ago

GJ! Chromium fixed and timeout fixed.