What’s wrong with webview_dispatcher ?
Hi Devs,
why disable "webview_dispatch"?
Btw, I am the author of some implementation of webview like julia & python.
https://github.com/congzhangzh/webview_python https://github.com/congzhangzh/Webview.jl
Tks, Cong
The major issue, which I believe is mentioned elsewhere in some issues in this repo, is that the JavaScript event loop is simply stalled by the webview event loop on the main thread. Even when registering functions as callbacks and calling from another thread wrapped in webview_dispatch deno will simply hang. I have not tried this in a while, and I know the deno FFI has changed a lot since I first implemented it. If you could provide a working proof-of-concept simply using the direct ffi.ts bindings using webview_dispatch from a worker thread that would be great and something which could then further be developed into the actual feature itself.
Yes, I know the internal trouble now! so the async binding will not work either if the deno event loop is hung by os event loop
So my Python binding & Julia binding is all ill-formed :), and all the async/await/future will not work!
Some related reference:
- [linux dispatcher]https://github.com/sunoru/Webviews.jl/blob/b28fb63300ac68a8f1a098e53237f1af46f99133/src/platforms/linux/Impl.jl#L127
- [win run]https://github.com/sunoru/Webviews.jl/blob/b28fb63300ac68a8f1a098e53237f1af46f99133/src/platforms/windows/Impl.jl#L72
- [win dispatcher]https://github.com/sunoru/Webviews.jl/blob/b28fb63300ac68a8f1a098e53237f1af46f99133/src/platforms/windows/Impl.jl#L99
- [mac os] https://github.com/sunoru/Webviews.jl/blob/b28fb63300ac68a8f1a098e53237f1af46f99133/src/platforms/apple/Impl.jl#L95
- [mac os] https://github.com/sunoru/Webviews.jl/blob/b28fb63300ac68a8f1a098e53237f1af46f99133/src/platforms/apple/Impl.jl#L16
- https://www.electronjs.org/blog/electron-internals-node-integration
- https://github.com/webview/webview_deno/issues/184
- https://github.com/congzhangzh/webview_python/issues/1
https://github.com/webview/webview/issues/578
More ref: https://ipython.readthedocs.io/en/stable/config/eventloops.html https://discuss.python.org/t/connecting-asyncio-and-tkinter-event-loops/14722 https://stackoverflow.com/questions/459083/how-do-you-run-your-own-code-alongside-tkinters-event-loop
more about how electron integration node event loop to native os part, hope this help others: https://docs.libuv.org/en/v1.x/loop.html#c.uv_backend_fd https://docs.libuv.org/en/v1.x/loop.html#c.uv_run_mode https://github.com/electron/electron/blob/8f00cc9c0e78b95e4de14b9b9e1a7df20935e948/shell/common/node_bindings.cc#L929 https://gist.github.com/bagder/ffb613e3c3c5f41813b31fc09ef1c261 https://docs.libuv.org/en/stable/guide/eventloops.html
More ref 4 python side:
https://github.com/MagicStack/uvloop/blob/7bb12a174884b2ec8b3162a08564e5fb8a5c6b39/uvloop/loop.pyx#L1152 https://discuss.python.org/t/connecting-asyncio-and-tkinter-event-loops/14722
I understand that Open Source means no expectations (thanks for your great work so far!) but does this mean that it's effectively impossible to currently use webview_deno in modern Deno? Unless I'm misunderstanding, It looks like webview.run() freezes deno up and makes it impossible to do anything.
I understand that Open Source means no expectations (thanks for your great work so far!) but does this mean that it's effectively impossible to currently use webview_deno in modern Deno? Unless I'm misunderstanding, It looks like webview.run() freezes deno up and makes it impossible to do anything.
I think so, but I haven’t test it myself
https://github.com/denoland/deno/discussions/25799
I found that's maybe possilbe, some work like webview_python need to be done in deno。
and deno, tokio and v8's single v8 thread is very helpful:
- https://github.com/denoland/deno/pull/3844
- https://choubey.gitbook.io/internals-of-deno/threading-model/default-threads
- https://docs.rs/tokio/latest/tokio/runtime/index.html#current-thread-runtime-behavior-at-the-time-of-writing
- https://questions.deno.com/m/1247553728001609729
- https://www.reddit.com/r/rust/comments/tln9nu/what_is_the_difference_between_tokio_singlethread/
maybe, this style works?
https://github.com/littledivy/deno_sdl2/blob/0e85bf1c5c7e591f908c152dc27de53c869b4b67/mod.ts#L1396
import { EventType, WindowBuilder } from "jsr:@divy/[email protected]";
const window = new WindowBuilder("Hello, Deno!", 640, 480).build(); const canvas = window.canvas();
for await (const event of window.events()) { if (event.type == EventType.Quit) { break; } else if (event.type == EventType.Draw) { // Rainbow effect const r = Math.sin(Date.now() / 1000) * 127 + 128; const g = Math.sin(Date.now() / 1000 + 2) * 127 + 128; const b = Math.sin(Date.now() / 1000 + 4) * 127 + 128; canvas.setDrawColor(Math.floor(r), Math.floor(g), Math.floor(b), 255); canvas.clear(); canvas.present(); } }