Closed brandonros closed 2 years ago
Does the test_ffi
example work from denoland/deno?
Can confirm doesn't work.
@lucsoft any idea where it might be failing? Not sure if we need to beef up some logs?
cc @littledivy
@lucsoft any idea where it might be failing? Not sure if we need to beef up some logs?
cc @littledivy
Nope no idea
Is it working for anybody else on
Windows
Linux
Mac Intel (non-arm64)?
It works for me both on windows and ubuntu (WSL).
Is it working for anybody else on
Windows
Linux
Mac Intel (non-arm64)?
Can confirm it also does not work on my Intel Mac.
do we have a guess on what to debug/where to add logs?
Aw snap, I was so hyped after hearing about the latest release. Doesn't work for me as well on this system:
deno 1.18.1 (release, x86_64-apple-darwin)
v8 9.8.177.6
typescript 4.5.2
@eliassjogreen I don't know a lot about rust so maybe I'm doing something wrong, anyways, after cloning https://github.com/denoland/deno I cd
'd into to the test_ffi
directory and ran cargo test
, this is the output (collapsed because it's a lot):
I believe that's wrong so now I ran cargo test
in the main directory, but that takes a while because it is still compiling...
Copying ./target/debug/libtest_ffi.dylib
to /usr/local/bin
and then running deno run -A --unstable ./test_ffi/tests/test.js
yields this (everything seems to be working):
something
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7, 8] [9, 10]
[1, 2, 3, 4, 5, 6, 7, 8]
[ 1, 2, 3, 4, 5, 6 ]
[ 4, 5, 6 ]
[ 4, 5, 6 ]
Hello from pointer!
pointer!
false
true
false
579
true
579
579
579
579
579
579
579.9119873046875
579.912
After sleep_blocking
true
Before
true
After
true
Correct number of resources
Ubuntu / POP!_OS 21.10 works so that pretty much confirms it's a mac-specific bug.
@eliassjogreen Sorry, I'm really nitpicking here but this isn't just a bug on aarch64 as I and @Julli4n have said above. I have an Intel MacBook Pro and encounter the exact same issue.
$ git clone git@github.com:webview/webview_deno.git
Cloning into 'webview_deno'...
remote: Enumerating objects: 999, done.
remote: Counting objects: 100% (303/303), done.
remote: Compressing objects: 100% (217/217), done.
remote: Total 999 (delta 163), reused 190 (delta 71), pack-reused 696
Receiving objects: 100% (999/999), 920.60 KiB | 6.14 MiB/s, done.
Resolving deltas: 100% (530/530), done.
Brandons-MacBook-Air:Desktop brandonros 2022-02-10 13:20:13 $ cd webview_deno/
Brandons-MacBook-Air:webview_deno brandonros 2022-02-10 13:20:14 $ make
cargo build
Compiling cc v1.0.58
Compiling pkg-config v0.3.18
Compiling once_cell v1.9.0
Compiling webview-official-sys v0.1.2
Compiling webview_deno v0.7.0-pre.0 (/Users/brandonros/Desktop/webview_deno)
Finished dev [unoptimized + debuginfo] target(s) in 5.60s
Brandons-MacBook-Air:webview_deno brandonros 2022-02-10 13:20:25 $ make example
PLUGIN_URL=target/debug/ deno run \
-A \
--unstable \
--no-check \
--config examples/ssr/tsconfig.json \
examples/ssr/ssr.jsx
Download https://crux.land/nanossr@0.0.1
Download https://deno.land/std@0.114.0/http/server.ts
Download https://deno.land/std@0.114.0/path/mod.ts
Download https://crux.land/api/get/nanossr@0.0.1
Download https://deno.land/std@0.114.0/_util/os.ts
Download https://deno.land/std@0.114.0/path/_interface.ts
Download https://deno.land/std@0.114.0/path/common.ts
Download https://deno.land/std@0.114.0/path/glob.ts
Download https://deno.land/std@0.114.0/path/posix.ts
Download https://deno.land/std@0.114.0/path/separator.ts
Download https://deno.land/std@0.114.0/path/win32.ts
Download https://deno.land/std@0.114.0/async/mod.ts
Download https://deno.land/std@0.114.0/async/deadline.ts
Download https://deno.land/std@0.114.0/async/debounce.ts
Download https://deno.land/std@0.114.0/async/deferred.ts
Download https://deno.land/std@0.114.0/async/delay.ts
Download https://deno.land/std@0.114.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.114.0/async/pool.ts
Download https://deno.land/std@0.114.0/async/tee.ts
Download https://deno.land/std@0.114.0/path/_constants.ts
Download https://deno.land/std@0.114.0/path/_util.ts
Download https://deno.land/std@0.114.0/_util/assert.ts
Download https://crux.land/api/get/4cfWmS
Download https://crux.land/api/get/4cfWmS.ts
Download https://cdn.skypack.dev/@twind/typography
Download https://cdn.skypack.dev/twind
Download https://cdn.skypack.dev/twind/sheets
Download https://deno.land/x/nano_jsx/mod.ts
Warning Implicitly using latest version (v0.0.29) for https://deno.land/x/nano_jsx/mod.ts
Download https://deno.land/x/nano_jsx@v0.0.29/mod.ts
Download https://deno.land/x/nano_jsx@v0.0.29/index.ts
Download https://deno.land/x/nano_jsx@v0.0.29/component.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/index.ts
Download https://deno.land/x/nano_jsx@v0.0.29/context.ts
Download https://deno.land/x/nano_jsx@v0.0.29/core.ts
Download https://deno.land/x/nano_jsx@v0.0.29/customElementsMode.ts
Download https://deno.land/x/nano_jsx@v0.0.29/fragment.ts
Download https://deno.land/x/nano_jsx@v0.0.29/helpers.ts
Download https://deno.land/x/nano_jsx@v0.0.29/jsx.ts
Download https://deno.land/x/nano_jsx@v0.0.29/lazy.ts
Download https://deno.land/x/nano_jsx@v0.0.29/ssr.ts
Download https://deno.land/x/nano_jsx@v0.0.29/store.ts
Download https://deno.land/x/nano_jsx@v0.0.29/version.ts
Download https://deno.land/x/nano_jsx@v0.0.29/withStyles.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/helmet.ts
Download https://deno.land/x/nano_jsx@v0.0.29/core.types.ts
Download https://deno.land/x/nano_jsx@v0.0.29/regexDom.ts
Download https://deno.land/x/nano_jsx@v0.0.29/state.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/img.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/link.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/router.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/suspense.ts
Download https://deno.land/x/nano_jsx@v0.0.29/components/visible.ts
Download https://deno.land/x/nano_jsx@v0.0.29/htm.ts
Download https://cdn.skypack.dev/-/twind@v0.16.16-w4CrbhFmJLdnylzKJGoJ/dist=es2019,mode=imports/optimized/twind.js
Download https://deno.land/x/nano_jsx@v0.0.29/htm/index.ts
Download https://cdn.skypack.dev/-/twind@v0.16.16-w4CrbhFmJLdnylzKJGoJ/dist=es2019,mode=imports/optimized/twind/sheets.js
Download https://deno.land/x/nano_jsx@v0.0.29/htm/build.ts
Download https://deno.land/x/nano_jsx@v0.0.29/htm/constants.ts
Download https://cdn.skypack.dev/-/style-vendorizer@v2.1.1-tUzSdjk5lqm41ZQmAIJ1/dist=es2019,mode=imports/optimized/style-vendorizer.js
Download https://cdn.skypack.dev/-/@twind/typography@v0.0.2-8DW2vLpYlpvZxmI13GVM/dist=es2019,mode=imports/optimized/@twind/typography.js
[runner] Listening on http://localhost:8000
[runner] worker started
2022-02-10 13:20:36.748 deno[65506:2210836] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00000001921b41cc __exceptionPreprocess + 240
1 libobjc.A.dylib 0x0000000191f057b8 objc_exception_throw + 60
2 CoreFoundation 0x00000001921dee24 _CFBundleGetValueForInfoKey + 0
3 AppKit 0x0000000194cb2224 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 380
4 AppKit 0x0000000194c9d0cc -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 948
5 AppKit 0x0000000194c9cd0c -[NSWindow initWithContentRect:styleMask:backing:defer:] + 56
6 8a8c0787f9ce488d86fdc761af81030728d 0x0000000107cbfc14 _ZN7webview22cocoa_wkwebview_engineC2EbPv + 640
7 8a8c0787f9ce488d86fdc761af81030728d 0x0000000107cbf970 _ZN7webview7webviewC2EbPv + 72
8 8a8c0787f9ce488d86fdc761af81030728d 0x0000000107cbe89c _ZN7webview7webviewC1EbPv + 56
9 8a8c0787f9ce488d86fdc761af81030728d 0x0000000107cbe834 webview_create + 56
10 8a8c0787f9ce488d86fdc761af81030728d 0x0000000107cbccf4 deno_webview_create + 28
11 deno 0x000000010342c04c ffi_call_SYSV + 76
12 deno 0x0000000103428e0c ffi_call_int + 1228
13 deno 0x0000000102bf7d1c _ZN8deno_ffi8ffi_call17h9d708ea02bba6a29E + 1328
14 deno 0x0000000102df4c28 _ZN9deno_core8ops_json7op_sync28_$u7b$$u7b$closure$u7d$$u7d$17h89895b0e40e92311E + 592
15 deno 0x0000000102b8517c _ZN86_$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..Fn$LT$Args$GT$$GT$4call17h6f7e6211145de192E + 64
16 deno 0x0000000102b7be38 _ZN9deno_core3ops7OpTable8route_op17h2a60f6529078143bE + 200
17 deno 0x0000000102b8b538 _ZN105_$LT$extern$u20$$u22$C$u22$$u20$fn$LP$A0$RP$$u20$.$GT$$u20$R$u20$as$u20$v8..support..CFnFrom$LT$F$GT$$GT$7mapping4c_fn17h9022fa7645b87dceE + 256
18 deno 0x00000001034ee1e0 _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE + 376
19 deno 0x00000001034ed89c _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE + 704
20 deno 0x00000001034ecfcc _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE + 248
21 deno 0x0000000104013f6c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 108
22 ??? 0x00000d9d000cb5c4 0x0 + 14967961859524
23 deno 0x0000000103f972d8 Builtins_InterpreterEntryTrampoline + 280
24 deno 0x0000000103f972d8 Builtins_InterpreterEntryTrampoline + 280
25 deno 0x0000000103f94118 construct_stub_create_deopt_addr + 340
26 deno 0x00000001040b288c Builtins_ConstructHandler + 716
27 deno 0x0000000103f972d8 Builtins_InterpreterEntryTrampoline + 280
28 deno 0x0000000103fcfc14 Builtins_GeneratorPrototypeNext + 148
29 deno 0x0000000103f94fac Builtins_JSEntryTrampoline + 172
30 deno 0x0000000103f94c48 Builtins_JSEntry + 168
31 deno 0x000000010359ca2c _ZN2v88internal12_GLOBAL__N_16InvokeEPNS0_7IsolateERKNS1_12InvokeParamsE + 2844
32 deno 0x000000010359cf8c _ZN2v88internal12_GLOBAL__N_118InvokeWithTryCatchEPNS0_7IsolateERKNS1_12InvokeParamsE + 88
33 deno 0x000000010359d11c _ZN2v88internal9Execution7TryCallEPNS0_7IsolateENS0_6HandleINS0_6ObjectEEES6_iPS6_NS1_15MessageHandlingEPNS0_11MaybeHandleIS5_EEb + 224
34 deno 0x000000010386cccc _ZN2v88internal16SourceTextModule13ExecuteModuleEPNS0_7IsolateENS0_6HandleIS1_EE + 296
35 deno 0x000000010386c6e0 _ZN2v88internal16SourceTextModule29AsyncModuleExecutionFulfilledEPNS0_7IsolateENS0_6HandleIS1_EE + 368
36 deno 0x00000001034f6000 _ZN2v88internal32Builtin_CallAsyncModuleFulfilledEiPmPNS0_7IsolateE + 80
37 deno 0x0000000104013f6c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 108
38 deno 0x00000001040630f8 Builtins_PromiseFulfillReactionJob + 56
39 deno 0x0000000103fbee28 Builtins_RunMicrotasks + 648
40 deno 0x0000000103f94e88 Builtins_JSRunMicrotasksEntry + 168
41 deno 0x000000010359c958 _ZN2v88internal12_GLOBAL__N_16InvokeEPNS0_7IsolateERKNS1_12InvokeParamsE + 2632
42 deno 0x000000010359cf8c _ZN2v88internal12_GLOBAL__N_118InvokeWithTryCatchEPNS0_7IsolateERKNS1_12InvokeParamsE + 88
43 deno 0x000000010359d178 _ZN2v88internal9Execution16TryRunMicrotasksEPNS0_7IsolateEPNS0_14MicrotaskQueueEPNS0_11MaybeHandleINS0_6ObjectEEE + 64
44 deno 0x00000001035c0888 _ZN2v88internal14MicrotaskQueue13RunMicrotasksEPNS0_7IsolateE + 420
45 deno 0x00000001035c06b0 _ZN2v88internal14MicrotaskQueue25PerformCheckpointInternalEPNS_7IsolateE + 84
46 deno 0x00000001035b273c _ZN2v88internal7Isolate33FireCallCompletedCallbackInternalEPNS0_14MicrotaskQueueE + 88
47 deno 0x00000001034ae388 _ZN2v88Function4CallENS_5LocalINS_7ContextEEENS1_INS_5ValueEEEiPS5_ + 1324
48 deno 0x0000000102b98978 _ZN9deno_core7runtime9JsRuntime15poll_event_loop17hed50a7726c370eadE + 2368
49 deno 0x0000000102d8fe50 _ZN12deno_runtime10web_worker9WebWorker15poll_event_loop17h435c8f4c193c93fcE + 216
50 deno 0x0000000102d8d8f4 _ZN12deno_runtime10web_worker14run_web_worker28_$u7b$$u7b$closure$u7d$$u7d$17h9b6a5805e63832b9E + 2580
51 deno 0x0000000102d8aa38 _ZN97_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h9b91a960ac469c96E + 316
52 deno 0x0000000102d887cc _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hd4d49fe75277b56cE + 3800
53 deno 0x0000000102d877e0 _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h32cc30ecd2b27a27E + 140
54 deno 0x0000000103115cf0 _ZN3std3sys4unix6thread6Thread3new12thread_start17h8d5e19fc4f27caacE + 48
55 libsystem_pthread.dylib 0x0000000192069240 _pthread_start + 148
56 libsystem_pthread.dylib 0x0000000192064024 thread_start + 8
)
libc++abi: terminating with uncaught exception of type NSException
make: *** [example] Abort trap: 6
make example
crashing
Note on macos windows can only be created on the main thread
I can't find webview-official-sys
dependency on GitHub.
https://docs.rs/crate/webview-official-sys/0.1.2/source/Cargo.toml
webview_create
seems to return UnsafePointer find. webview_run
seems to block but not create window but also not log an error/throw an exception. I will try to keep digging but I might hit brick wall as it is above my head.
Edit: found it, in here: https://github.com/webview/webview_rust/
The sample here works fine:
5 $ git clone --recurse-submodules -j8 git@github.com:webview/webview_rust.git
Cloning into 'webview_rust'...
remote: Enumerating objects: 486, done.
remote: Counting objects: 100% (50/50), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 486 (delta 19), reused 25 (delta 6), pack-reused 436
Receiving objects: 100% (486/486), 128.12 KiB | 2.07 MiB/s, done.
Resolving deltas: 100% (242/242), done.
Submodule 'webview-official' (https://github.com/webview/webview) registered for path 'webview-official-sys/webview-official'
Cloning into '/Users/brandonros/Desktop/webview_rust/webview-official-sys/webview-official'...
remote: Enumerating objects: 1736, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 1736 (delta 16), reused 19 (delta 8), pack-reused 1705
Receiving objects: 100% (1736/1736), 5.77 MiB | 4.86 MiB/s, done.
Resolving deltas: 100% (926/926), done.
Submodule path 'webview-official-sys/webview-official': checked out '7534ef6e476a1af6206ddb3d0efd3ebf131cba3c'
Brandons-MacBook-Air:Desktop brandonros 2022-02-10 13:33:32 $ cd webview_rust/
Brandons-MacBook-Air:webview_rust brandonros 2022-02-10 13:33:49 $ cargo build
Updating crates.io index
Downloaded pkg-config v0.3.24
Downloaded 1 crate (16.5 KB) in 0.34s
Compiling cc v1.0.72
Compiling pkg-config v0.3.24
Compiling webview-official-sys v0.1.2 (/Users/brandonros/Desktop/webview_rust/webview-official-sys)
Compiling webview_official v0.2.0 (/Users/brandonros/Desktop/webview_rust)
Finished dev [unoptimized + debuginfo] target(s) in 10.70s
Brandons-MacBook-Air:webview_rust brandonros 2022-02-10 13:34:09 $ cargo run --example sample
Compiling webview_official v0.2.0 (/Users/brandonros/Desktop/webview_rust)
Finished dev [unoptimized + debuginfo] target(s) in 0.23s
Running `target/debug/examples/sample`
Hello World
Note on macos windows can only be created on the main thread
this is most likely the culprit. it'd be cool if webview_deno PLUGIN_URL=target/debug/ deno run -Ar --unstable examples/local.ts
didn't silently hang/swallow that error somewhere, but aside from that I'm not quite sure how the new deno FFI
stuff is going to allow webview_deno
to create a window on Mac on the main deno thread...
@brandonros I admit I have no clue about low-level stuff (I don't even really know what a thread is), but to me this sounds like Deno itself needs to provide some way of choosing threads or creating a new process, right? webview_deno
is just the first example where we encounter this limitation, but isn't this basically an upstream issue completeley different deno projects could also face?
FYI make example
spawns a webview instance inside a web worker (another thread). We need to update the example to run the webview instance on the main thread. This is not a Deno FFI bug.
Note that the local.ts
example does not launch webview from a non-main thread. Only make example
uses web workers (#102 should fix it)
@littledivy thanks for that
that gets make example
in line with local.ts
where it is silently failing/not actually creating a window:
$ git pull origin main
make eremote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 11 (delta 6), reused 7 (delta 3), pack-reused 0
Unpacking objects: 100% (11/11), 1.84 KiB | 171.00 KiB/s, done.
xFrom github.com:webview/webview_deno
* branch main -> FETCH_HEAD
19c1e77..d19defc main -> origin/main
Updating 19c1e77..d19defc
Fast-forward
Cargo.toml | 1 -
Makefile | 2 +-
examples/local.ts | 3 ++-
examples/ssr/main.ts | 13 +++++++++++++
examples/ssr/worker.ts | 12 ------------
examples/ssr/{ssr.jsx => worker.tsx} | 11 +----------
src/webview.ts | 4 ++--
7 files changed, 19 insertions(+), 27 deletions(-)
create mode 100644 examples/ssr/main.ts
delete mode 100644 examples/ssr/worker.ts
rename examples/ssr/{ssr.jsx => worker.tsx} (68%)
Brandons-MacBook-Air:webview_deno brandonros 2022-02-11 15:15:44 $ make example
PLUGIN_URL=target/debug/ deno run \
-A \
--unstable \
--no-check \
--config examples/ssr/tsconfig.json \
examples/ssr/main.ts
[runner] Listening on http://localhost:8000
[runner] worker started
Any idea on what else I can do locally to turn up verbosity and figure out where we are getting stuck?
I tried debugging it, it's not stuck in deno_webview but something is not working with the NSApplication event loop inside webview. (Setting debug: c_int
to 1
doesn't help either)
Hi @eliassjogreen
I created a PR to fix the issue related to WebView on Darwin https://github.com/webview/webview_deno/pull/103
First: Must explicitly call set_size method on webview_sys
sys.symbols.deno_webview_set_size(this.#handle, width, height, hint);
I'm not sure about this one return encoder.encode(value + "\n");
in other platform but we need to remove '\n' in Darwin so I do platform check for backward compatible.
This issue should be closed now with #103. Thanks @hoangpq!
Works great!
just shows in the dock, click it and no window to be found anywhere