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

SessionInfo #86

Closed
heimdallexus opened this issue Apr 24, 2020 · 31 comments
Closed

SessionInfo #86

heimdallexus opened this issue Apr 24, 2020 · 31 comments

Comments

@heimdallexus
Copy link

heimdallexus commented Apr 24, 2020

A question really. I've been writing some code using node-irsdk and electron for the past two weeks.
One thing I have been struggling is that I always manage to lose the first SessionInfo data after hooking the listerner to my browserwindow. Any tip on that?

@martinguder
Copy link

Which Electron version are you using? If Electron 7+, it would be nice to share, how you got it to work. Because seems, that a ton of people (including me), couldn't get it to run with Electron 7.

@heimdallexus
Copy link
Author

heimdallexus commented Apr 24, 2020

At this moment I'm stuck with 6.1.10. Will try another version today.

Edit: I'm new to React and Electron but I think I made it work with Electron 8.2.3. Tell me how can I help you Martin. What you need to know. But please, don't forget about my issue if you got any tips. :)

@martinguder
Copy link

Actually there is still an open issue regarding Electron 7+ compatibility. For now this issue was not closed and I couldn't get it to run. Prebuilt failed with Electron involved IIRC. But: I would give it a shot, when you can confirm, it's working with Electron 8.2.3. Would be awesome if you can check and if you did something special to get it runnig, describe, what to change. Then the other issue could be resolved for a ton of other users. Thanks so much so far! :)

@heimdallexus
Copy link
Author

Let's start with those steps and see if it helps:

  • fix deprecated set call on IrSdkBindingHelpers.cpp at 'convertTelemetryVarToObject'
    Nan::Set(arr, i, convertTelemetryValueToObject(var, i));

  • change import on node-irsdk.js
    var IrSdkNodeWrapper = require('../build/Release/IrSdkNodeBindings.node')

  • rebuild ./node_modules/.bin/electron-rebuild

@martinguder
Copy link

Thank you! Will give it a try asap

@heimdallexus
Copy link
Author

Hope it helps. If not let me know so we can look further.

@heimdallexus
Copy link
Author

Fixed my issue btw. :)
Multiple windows and promises ...

@martinguder
Copy link

@heimdallexus I still get this error:
Uncaught Error: The module '\\?\C:\Users\Martin\Desktop\irsdk-electron\node_modules\node-irsdk\build\Release\IrSdkNodeBindings.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js requires NODE_MODULE_VERSION 76. Please try re-compiling or re-installing the module (for instance, using npm rebuildornpm install). at process.func (electron/js2c/asar.js:140) at process.func [as dlopen] (electron/js2c/asar.js:140) at Object.Module._extensions..node (internal/modules/cjs/loader.js:1016) at Object.func (electron/js2c/asar.js:140) at Object.func [as .node] (electron/js2c/asar.js:140) at Module.load (internal/modules/cjs/loader.js:816) at Module._load (internal/modules/cjs/loader.js:728) at Module._load (electron/js2c/asar.js:717) at Function.Module._load (electron/js2c/asar.js:717) at Module.require (internal/modules/cjs/loader.js:853)

Rebuild throws now error, but also does not change anything.

@heimdallexus
Copy link
Author

Hey Martin,
Try rebuilding it with a specific electron version in this own directory (node-irsdk).
Something like the command bellow where 8.2.3 is electron version:
node-gyp rebuild --target=8.2.3 --arch=x64 --dist-url=https://electronjs.org/headers

@martinguder
Copy link

Well. Did not worked for me. Tried to follow some tutorials online, but can't get node-gyp to work. Do I have to install something on Windows to get this to work except for node-gyp itself (which is pre-installed with electron if I'm not wrong). Do I have to be in the module directory (node-irsdk) or in the apps root directory? Thanks for your help!

@heimdallexus
Copy link
Author

Anytime Martin. I'm trying to remember the correct steps. I'll try to find some time later today.

Anyway ... let me answer your questions.

Q: Do I have to install something on Windows to get this to work except for node-gyp itself (which is pre-installed with electron if I'm not wrong).
A: Nope.

Q: Do I have to be in the module directory (node-irsdk) or in the apps root directory?
A: Module directory.

@martinguder
Copy link

Thanks. I'll also investigate further today in the evening. Thanks a lot!

@heimdallexus
Copy link
Author

package.json
"electron": "8.2.5",
"electron-rebuild": "^1.10.1",
"node-irsdk": "^2.1.6", //With changes already made to the code

  • Remember to have all packages properly updated if any changes were made do package.json versions, if not just delete "node_modules" directory, run "npm install" and make the changes to node-irsdk

Couple of options after that to build the node file:

  1. Run this on project level
    ./node_modules/.bin/electron-rebuild

  2. Run this on module level - node-irsdk (considering electron version 8.2.5)
    node-gyp rebuild --target=8.2.5 --arch=x64 --dist-url=https://electronjs.org/headers

Both worked for me

@martinguder
Copy link

martinguder commented May 11, 2020

I did the following:

  • deleted modules folder and did a clean "npm install"
  • installed Python 3.8 via Windows Store
  • installed Visual Studio via Windows Store + Build tools as suggested for node-gyp
  • did the changes to the node-irsdk files as you suggested
  • ran your command on project level threw this error

An unhandled error occurred inside electron-rebuild
Could not detect abi for version 8.2.5 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron

Error: Could not detect abi for version 8.2.5 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron
at Object.getAbi (C:\Users\Martin\Desktop\irsdk-electron\node_modules\node-abi\index.js:30:9)
at new Rebuilder (C:\Users\Martin\Desktop\irsdk-electron\node_modules\electron-rebuild\lib\src\rebuild.js:126:28)
at rebuildWithOptions (C:\Users\Martin\Desktop\irsdk-electron\node_modules\electron-rebuild\lib\src\rebuild.js:404:23)
at Object.doRebuild [as rebuild] (C:\Users\Martin\Desktop\irsdk-electron\node_modules\electron-rebuild\lib\src\rebuild.js:427:16)
at C:\Users\Martin\Desktop\irsdk-electron\node_modules\electron-rebuild\lib\src\cli.js:120:33
at Generator.next ()
at fulfilled (C:\Users\Martin\Desktop\irsdk-electron\node_modules\electron-rebuild\lib\src\cli.js:6:58)

  • Trying the second route on module level threw this:

gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@12.16.3 | win32 | x64
gyp info find Python using Python version 3.8.2 found at "C:\Users\Martin\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe"
gyp info find VS using VS2017 (15.9.28307.1093) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Users\Martin\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe
gyp info spawn args [
gyp info spawn args 'C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\Martin\Desktop\irsdk-electron\node_modules\node-irsdk\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\Martin\AppData\Local\node-gyp\Cache\8.2.5\include\node\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\Martin\AppData\Local\node-gyp\Cache\8.2.5',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\Users\\Martin\\AppData\\Local\\node-gyp\\Cache\\8.2.5\\<(target_arch)\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\Users\Martin\Desktop\irsdk-electron\node_modules\node-irsdk',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\Users\Martin\Desktop\irsdk-electron\node_modules\node-irsdk\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py", line 50, in
sys.exit(gyp.script_main())
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 554, in script_main
return main(sys.argv[1:])
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 547, in main
return gyp_main(args)
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 520, in gyp_main
[generator, flat_list, targets, data] = Load(
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 136, in Load
result = gyp.input.Load(build_files, default_variables, includes[:],
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 2782, in Load
LoadTargetBuildFile(build_file, data, aux_data,
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 391, in LoadTargetBuildFile
build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
File "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 243, in LoadOneBuildFile
build_file_data = eval(build_file_contents, {'builtins': {}},
File "binding.gyp", line 1
{
^
SyntaxError: invalid character in identifier
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:310:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Martin\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=8.2.5" "--arch=x64" "--dist-url=https://electronjs.org/headers"
gyp ERR! cwd C:\Users\Martin\Desktop\irsdk-electron\node_modules\node-irsdk
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok

Not sure where the problem lies.

@martinguder
Copy link

Also tried updating node-abi, but that didn't weird either.

@heimdallexus
Copy link
Author

Can I take a look at your package.json and package-lock.json contents?
Saw some answers telling that is possible that some older version of node-abi is being used for some reason.

@martinguder
Copy link

OK this get's too long of an answer due to the code. I zipped it.

package-and-package-lock.zip

@heimdallexus
Copy link
Author

So we can move faster, and leave this board alone, reach me through my email.

@sabifa
Copy link

sabifa commented May 11, 2020

It would be nice if you could answer here again with the (hopefully soon found) solution!
I will try your steps as well tomorrow 🙂

@heimdallexus
Copy link
Author

Sure thing. Will update as soon as we find the reason for it since mine is working ok. :)

@heimdallexus
Copy link
Author

Martin, if you want to we can continue over here. No problem.
Let's see your node and npm versions.

Run:
npm version

@martinguder
Copy link

martinguder commented May 11, 2020

Sent you already an email. For me both is ok.

node: v12.16.3
npm: 6.14.4

@martinguder
Copy link

Just updated everything prior to continue working on this.

@martinguder
Copy link

martinguder commented May 12, 2020

Short update for @sabifa ... I installed a stripped down version by @heimdallexus, but the problem persists and seems to be related to the system config. Not sure what it needs, to get this up and running, but probably a complete rewrite of a new C++ implementation with no dependencies on old versions of node/electron is faster than hunting down a solution to this repo. Maybe just my frustration is writing those lines, but the fact, that this repo is not working with more recent electron versions renders it useless mostly.

@martinguder
Copy link

martinguder commented May 12, 2020

OK. So finally we traced back the error.

  1. Open node_modules/node-irsdk/bindings.gyp and copy the content over to notepad and overwrite bindings.gyp. There is a hidden special character, which seems to interrupt the rebuild and throws an error.

File "binding.gyp", line 1 { ^ SyntaxError: invalid character in identifier gyp ERR! configure error gyp ERR! stack Error:gypfailed with exit code: 1

  1. Apply the changes proposed by @heimdallexus:

Let's start with those steps and see if it helps:

  • fix deprecated set call on IrSdkBindingHelpers.cpp at 'convertTelemetryVarToObject'
    Nan::Set(arr, i, convertTelemetryValueToObject(var, i));
  • change import on node-irsdk.js
    var IrSdkNodeWrapper = require('../build/Release/IrSdkNodeBindings.node')
  • rebuild ./node_modules/.bin/electron-rebuild

Should work and rebuild just fine now and result in the bare minimum of node-irsdk throwing no error at least for starting electron and listening for iRacing. Have to do further testing though, but it seems at least start now without errors.

Additional steps I did:

  • install Python 2.8.x from the Windows Store
  • install Visual Studio + VS2017 Build Tools for C++

That's it. Hope it helps @sabifa and very big thanks to @heimdallexus once again. He hinted me to the error with the bindings.gyp so that I could hunt it down within 10 minutes in the end. :)

@heimdallexus
Copy link
Author

@sabifa if you want to take a look at my code I can send you the link, just let me know. My email is up there somewhere.

@martinguder
Copy link

Same from my side. Can send you a stripped down version as well.

@sabifa
Copy link

sabifa commented May 13, 2020

Wow! Thanks a lot guys, it worked on the first attempt! 🚀

One thing that bugs me is that we have to edit the files inside node_modules, so next time you reinstall the packages it will discard the changes. The best thing would be that @apihlaja applies these changes to the code or that you could set up a PR so he can merge the changes.

Maybe a PR would make sense anyways so other see what to do to make it work with newer Electron versions?

Unfortunately, looking at the recent issues it seems like he does not have any time working on the project for quite a while now.
Another active maintainer is needed I guess, maybe we can reach out to Antti through iRacing or so.

Another thought: Can't we just move the node-irsdk folder from node_modules into my src folder so it keeps the modified files?

@heimdallexus
Copy link
Author

Another thought: Can't we just move the node-irsdk folder from node_modules into my src folder so it keeps the modified files?

Sure. Or you can do as I've been doing. I keep my node-isrdk directory outside and, when I need to reinstall, I just copy it back to node_modules.

Anyway the best option is to merge those changes. I don't know Antti so if anybody is up to see if he can take a look or share this project with someone who can that would be nice. Also update irsdk_defines.h to the latest version.

@twk-b
Copy link

twk-b commented May 18, 2020

could someone post the required diff to get electron 8 working?

@sabifa
Copy link

sabifa commented May 19, 2020

could someone post the required diff to get electron 8 working?

Take a look at this comment 🙂
#86 (comment)

sabifa added a commit to sabifa/node-irsdk that referenced this issue Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants