webui-dev / zig-webui

Use any web browser or WebView as GUI, with Zig in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me/
MIT License
437 stars 15 forks source link

WebUI on MacOS 14.6 doesn't quit the app after closing last Webview window #71

Open marad opened 4 weeks ago

marad commented 4 weeks ago

I think the title says it all. I'm running the on hash 1220f7cb9608ca0b5946bee76bb9fe3867aa5cab47990d9cf02339d89dc7ae1d9a32.

I'm trying to think of any other way to capture the window closing event but can't figure it out.

// Edit I did some tests. I checked that Firefox and Chrome work fine. Safari doesn't start at all. And the "no quitting" problem seems to be related to webui.Brrowser.Webview.

I've also noticed that if I bind all events (with "") in Webview it doesn't pass through any - this might be connected.

Anyway - I'm going to use webui.Browser.ChromiumBased and it should work for my use case.

jinzhongjia commented 4 weeks ago

Sorry, I can't debug this problem at the moment because I don't have a mac But we can temporarily mark the issue as

marad commented 4 weeks ago

I think that there is a value in having this just hanging here for now. If anyone encounters the same problem the description also outlines the "workaround" so might be helpful in that way.

AlbertShown commented 4 weeks ago

if I bind all events (with "") in Webview it doesn't pass through any

webui use websockets, it does not use webview APIs, so you need to make sure you are including webui.js in your webview HTML, and also hit F12 and make sure the webui.js http request is 200.

doesn't quit the app after closing last Webview window

webui does not track webview window using APIs, but it tracks how many websocket clients are connected, so when you close the window, maybe macOS keep websocket connection open or something... Another thing, webui will always stay connected if you set timeout to 0 (webui_set_timeout(0);).

I'm trying to think of any other way to capture the window closing event

All events including open and close are inside bind all events (with ""), but it seems you don't get any for some reason.

AlbertShown commented 4 weeks ago

Can you use the debug version of webui to see logs?

marad commented 3 weeks ago

@AlbertShown should I change something in the dependencies to use the debug version?

AlbertShown commented 3 weeks ago

I don't know if Zig build have a debug option, but you can manually download webui lib, then copy the one from debug folder and replace your Zig project with it.

mochalins commented 2 weeks ago

should I change something in the dependencies to use the debug version?

This is actually quite a good point, the Zig webui wrapper should support building and using the debug version of the library. I'll create a separate issue to track this.

mochalins commented 1 week ago

Update: after #70, webui will now show logs when building in debug mode.