webview_deno icon indicating copy to clipboard operation
webview_deno copied to clipboard

Problems with running in a worker?

Open randallb opened this issue 1 year ago • 1 comments

If I try to run webview in a webworker, I get:

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                      0x00000001ad8db3f8 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x00000001ad426ea8 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001ad904810 _CFBundleGetValueForInfoKey + 0
	3   AppKit                              0x00000001b0b02a18 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 320
	4   AppKit                              0x00000001b0af1524 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 816
	5   AppKit                              0x00000001b0af11e8 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
	6   5a78a907fb3b54a23d6ec12156baa6a1009 0x0000000108904fd0 _ZN7webview6detail22cocoa_wkwebview_engineC2EbPv + 672
	7   5a78a907fb3b54a23d6ec12156baa6a1009 0x0000000108904d0c _ZN7webview7webviewC2EbPv + 72
	8   5a78a907fb3b54a23d6ec12156baa6a1009 0x0000000108903afc _ZN7webview7webviewC1EbPv + 56
	9   5a78a907fb3b54a23d6ec12156baa6a1009 0x0000000108903a50 webview_create + 56
	10  deno                                0x000000010325004c ffi_call_SYSV + 76

Presumably that's because it's not on the main thread. I'm unclear on how to make this work so I don't have to block my main thread.

Any thoughts?

randallb avatar Dec 19 '22 16:12 randallb

macOS requires all UI code to run on the main thread, so there's no avoiding that.

The C SDK provides webview.dispatch for executing code on the main thread, so if that got implemented here you could use that to still utilize the main thread.

e3ndr avatar Dec 19 '22 16:12 e3ndr