deno-windowing / dwm

Deno Window Manager: Cross-platform window creation and management
https://deno.land/x/dwm
Apache License 2.0
155 stars 11 forks source link

Doesn't work in Web Worker #36

Closed Mutefish0 closed 1 month ago

Mutefish0 commented 1 month ago

I encountered an error when using dwn in a Web Worker.

Deno version:

deno 1.46.3 (stable, release, aarch64-apple-darwin)

Steps to Reproduce

create main.js:

new Worker(import.meta.resolve("./worker.js"), {
  type: "module",
});

create worker.js:

import { createWindow } from "https://deno.land/x/dwm@0.3.6/mod.ts";
console.log(createWindow);

run:

deno run --unstable-ffi main.js

then you will get this error:

2024-09-17 19:03:12.057 deno[71161:1360199] *** Assertion failure in -[NSMenu _setMenuName:], NSMenu.m:777
DjDeveloperr commented 1 month ago

Looks like you're on macOS - macOS or any Apple platform in general does not allow UI from non-main thread. So dwm will always crash when used from a worker

Mutefish0 commented 1 month ago

Understood, thanks for the clarification!