vite-plugin-electron: importing electron in a WebWorker doesn't work
Doing import { ipcRenderer} from 'electron' (or any other renderer electron module) crashes the app with reason: "crashed" and exitCode: 11.
Details
- Iβm trying to migrate from Webpack and the same code works there.
nodeIntegrationInWorkeris set to true.- Exit code 11 usually means Segmentation fault.
- One thing that is being logged in the Terminal when the app crashes:
[20890:0831/172750.464535:ERROR:shared_image_manager.cc(267)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox. [20890:0831/172750.464559:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox. [20890:0831/172750.464564:ERROR:shared_image_manager.cc(267)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox. [20890:0831/172750.464569:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox. [20890:0831/172750.464572:ERROR:shared_image_manager.cc(267)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox. [20890:0831/172750.464578:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox. [20890:0831/172750.464580:ERROR:shared_image_manager.cc(267)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox. [20890:0831/172750.464584:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox. [20890:0831/172750.464601:ERROR:shared_image_manager.cc(267)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox. [20890:0831/172750.464606:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox. [20890:0831/172750.464609:ERROR:shared_image_manager.cc(267)] SharedImageManager::ProduceOverlay: Trying to Produce a Overlay representation from a non-existent mailbox. [20890:0831/172750.464612:ERROR:skia_output_device_buffer_queue.cc(354)] Invalid mailbox. - Another thing:
Error sending from webFrameMain: Error: Render frame was disposed before WebFrameMain could be accessed at n._sendInternal (node:electron/js2c/browser_init:165:629) at b._sendInternal (node:electron/js2c/browser_init:161:2573) at node:electron/js2c/browser_init:193:729 at new Promise (<anonymous>) at Object.invokeInWebContents (node:electron/js2c/browser_init:193:477) at b.executeJavaScript (node:electron/js2c/browser_init:161:3267) at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (22 by maintainers)
type: "module"will be supported inv0.9.3, coming soon. πAwesome! Thanks for all the work you put into this!
Another idea: You can throw an error if someone tries to access an ipcRenderer property (using a Proxy) and explain the issue. This will be very helpful to other users.
Good idea! I will fix it in next version. π
Done. Here is the repo: https://github.com/astoilkov/electron-vite-worker-issue.
The important part is in
renderer/main.ts:Clicking on the βhelloβ text will run the code and the
BrowserWindowwill crash. You can open DevTools before you click the βhelloβ text so you can see DevTools shows a message as well.@Jazcash π This project is just for my personal interest, I have not tested many cases, such as
web worder. By the way, Vite behaves very differently duringvite serveandvite build, so I run into really tricky issues a lot of the time.The
web worderwill be imported by Vite as a separate file during development, and will be correctly loaded by Electron-Renderer ashttp. During a Vite build, all files will be built into onbundlefile, this difference may be the main cause of the BUG π.Yep, I will do it on Monday.