server example not working on Deno 2 and OS X
It seems like the webview causes the program to hang and not serve any HTTP responses, nor show any output in the wevbiew.
Steps to reproduce:
$ deno -version
deno 2.0.2
$ uname -a
Darwin studio.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
$ deno run -Ar --unstable examples/server.ts
Listening on http://localhost:8080/
The webview window shows a blank screen. Furthermore the server is unresponsive:
$ curl http://localhost:8080/
<hangs>
Same here! It would be awesome to sort out to build and serve mini Vue apps.
same here on windows
Same here on Linux. I am currently using WebUI as an alternative, which isn't ideal for my purposes but works.
This is most likely due to https://github.com/webview/webview_deno/issues/149#issuecomment-1357942188 and has been an issue for a while. Could also be because the webview run method is blocking on the main thread (never allowing the JS event loop to step), and therefor a potential server needs to be run on a separate worker (thread).
That's a helpful pointer! Would you perhaps have an example of how to run the server on a worker thread to get it to work?
This is most likely due to https://github.com/webview/webview_deno/issues/149#issuecomment-1357942188 and has been an issue for a while. Could also be because the webview run method is blocking on the main thread (never allowing the JS event loop to step), and therefor a potential server needs to be run on a separate worker (thread).
This wouldn't explain the problem existing on Windows or Linux platforms, since they're not bound by that requirement to have UI code on the main thread. I understand the issue's title relates to macOS specifically, however. Maybe a separate issue should be created for the other operating systems too?
As for having a worker, that would only be a hackfix for what is essentially a regression (in the case of Windows and Linux operating systems). webview_deno used to work in the past without having to run anything in a worker. The library should be updated to include this boilerplate worker code if it's inevitable (so that existing projects consuming it won't have to significantly alter their codebase), or the underlying issue corrected if the use of a worker is actually unnecessary.
I'm of the opinion that a worker is unnecessary, and that Deno 2 (or maybe a newer version of the webview library?) simply introduced breaking changes, so the library should be updated accordingly.
As for having a worker, that would only be a hackfix for what is essentially a regression (in the case of Windows and Linux operating systems). webview_deno used to work in the past without having to run anything in a worker. The library should be updated to include this boilerplate worker code if it's inevitable (so that existing projects consuming it won't have to significantly alter their codebase), or the underlying issue corrected if the use of a worker is actually unnecessary.
Agreed, but it is an issue with the underlying webview library: https://github.com/webview/webview/issues/578