-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
atem-connection not playing well with webpack and electron. #106
Comments
Could you try this version on npm |
Thanks a lot for your answer. Unfortunately i does not. It seems that threadedClass still looks for a file instead of querying webpack for the file to load. This is the Error I get:
|
oh sorry, I glossed over that you are using webpack. Unfortunately I don't have any ideas on how to resolve this. I think the problem here is that it is trying to create a new worker thread, and the worker thread is failing to load its entrypoint. And even then the dynamic imports will probably have messed up the bundling so that the intended code will be missing. Webpack is not something I am comfortable with so do not know where to start |
No worries, neither do I have much knowledge about webpack. would you mind telling me what purpose threadedclass serves so that I may try to spin a branch without it and thus make things work even with webpack? |
threadedclass is used to manage a worker thread. I am currently tempted to see if it is possible to swap out the library for https://github.com/andywer/threads.js, as that is more widely used and claims to work well with webpack. The thread is necessary for handling the connection, to avoid the connection dropping when the node event loop is blocked by other tasks. |
Let me give this a try. |
Just to keep you up to date with my efforts. I'm currently trying to write a webpack plugin to handle threadedClass... This seems less intrusive than changing the used library. |
While workin on this issue, I found that webpack is not as easy to master as I initially thought. You mention the node event loop being blocked. Did you encounter this? Would it be feasable to spin a variant of atem-connection that runs everything on the event loop - I'd be willing to create and maintain this spin off... |
Yeah, I wouldnt want to dive into that side of webpack. If your code is using enough timers, or waiting on promises then it might be ok. But any synchronous operations that take more than 20ms are likely to cause issues. |
I found a way around this issue. There is the possibility to specify an external source for webpack (to tell it that this particular import should not be grabbed). This allows me to mark the atemSocketChild class as external. I the use WebpackCopyPlugin to copy the file over to the destination directory. With this trick I was able to get things to work properly. Thanks for the insights. Maybe you want to add this to the documentation. https://webpack.js.org/plugins/copy-webpack-plugin/ : new CopyPlugin({
patterns: [{ from: '**/atemSocketChild*', to: '[name].[ext]' }],
}), (Note that the newest version does only support webpack 5) https://v4.webpack.js.org/configuration/externals/ : externals: /^(atemSocketChild)$/i, |
I just ran into something that feels related to this.
Could this be related? And is there a possible workaround? |
This is definitively related. I was able to solve the issue by creating a second target for webpack that packages atemSocketChild class and it's dependencies. That way it works flawlessly. Please feel free to take https://github.com/sensslen/Cgf.CameraControl.Main.Gui (https://github.com/sensslen/Cgf.CameraControl.Main.Gui/blob/main/webpack.main.config.js) for inspiration. |
@sensslen Thank you for sharing your config. At the moment I am probably just going to stick to unbuild versions… introducing webpack additionally was not on my plan for this moment. Still hopeful that this lib could just support building out of the box. |
Im going to reopen this as a reminder to myself to look into what can be done here. It's a tough one to handle, as webpack introduces some complexity (and I suspect that the config will need to in some way be aware of the need to do some extra work), and electron introduces some other complexity due to its bad support for worker_threads. I have been tempted to try switching to a different thread helper library, which does itself have support for webpack, so it might make this easier to do neatly |
I have the same error as @chrisspiegl, however, I'm not using webpack or any other bundler. It's just plain js. I've also made a test-repo. If you run
Adding Shoud I create an issue in the threadedclass repo? I think, if the user could configure the path to the threadedclass folder, it should work. |
@hrueger please try using version |
Thanks for the quick response, that worked 👍 |
I'm using the 3.0.0 nightly mentioned by @Julusian and am still running into issues with webpack.
|
I'm also running into similar issues while running in the electron environment and trying to establish Such as:
Have there been any updates on this topic? |
After I was able to fix the webpack stuff I also encountered this issue - just to find out that electron‘s worker thread implementation is kind of broken. At least that‘s what I read. Therefore I moved away from electron. |
I'm submitting a ...
[ x ] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project
Summary
I am trying to use atem-connection in an electron application. Electron-Forge (the electron helper tool used) normally uses webpack in order to pack the application (and allow for usage of react.
When I use atem-connection on the main process, threadedClass fails to find the file atemSocketChild, as it searches the current directory.
To reproduce the issue feel free to check out https://github.com/sensslen/Cgf.CameraControl.Main.Gui
The text was updated successfully, but these errors were encountered: