Skip to content
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

[Node.js] Brainflow not working in electron when electron-app is packaged (node.js) #733

Open
GordonPmnt opened this issue Jul 2, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@GordonPmnt
Copy link

GordonPmnt commented Jul 2, 2024

Describe the bug

This is more a compatibility issue with the Node.js package and electron.js.

When running brainflow in an electron app, it\s working well in a dev env. But when packaging the app, electron cannot resolve the dll path in Boardshim constructor.

this.libPath = `${__dirname}/../brainflow/lib`;

Today, in order to solve this issue, we had to adapt brainflow a bit:

    const RESOURCES_PATH = app.isPackaged
      ? path.join(process.resourcesPath, 'app.asar.unpacked', 'node_modules', 'brainflow')
      : path.join(__dirname, '../../brainflow');
    this.libPath = path.join(RESOURCES_PATH, 'brainflow', 'lib');

To Reproduce

Install brainflow in an electron app. Create a button running an instance of synthetic board.

Run it locally, it will work.

Then, package the app and run it. Electron shoudl complain because it cannot resolve path to import dll files.

Info (please complete the following information):

  • Board Id: any
  • OS running on your PC: any
  • Programming Language and its version: node.js 20
  • Architecture(x86, x64, ARM, etc): any
  • In case of Python full output of pip list command, for other languages please provide BrainFlow version used

Expected behavior
Path should be resolved properly in electron packaged context for production.

** suggestion **
Init constructor differently, or add an electron support.

@GordonPmnt GordonPmnt added the bug Something isn't working label Jul 2, 2024
Copy link

github-actions bot commented Jul 2, 2024

Welcome to BrainFlow project and thanks for your contribution! We will try to fix your issue ASAP. Make sure that you have read about issue format in the docs.

@Andrey1994
Copy link
Member

hi, sorry for late response.

I am not very well familiar with electron and js in general... is there a way to pack libs properly to solve it?

@Andrey1994
Copy link
Member

and will it help if we do smth like this:

if (libs in current path exist)
    load libs from it
else
    try to load it wo path specification and then OS should search for it in current dir and in PATH/LD_LIBRARY_PATH env vars

?

If so could you send a PR implementing it?

@retiutut
Copy link
Member

I'm familiar with how this plays out using the BrainFlow Java library, and we've written some code in the Java binding to handle this. This may need a new contribution in the NodeJS binding or example code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants