stackgl / headless-gl

🎃 Windowless WebGL for node.js
1.73k stars 166 forks source link

Support for Node.js v20 #268

Closed zdu-strong closed 4 months ago

fazouane-marouane commented 8 months ago

A bit of context on this: The library still works on node 20 but the prebuilt binaries don't seem to be published for this version. So it builds necessarily on install.

skerit commented 8 months ago

That's strange, because I'm getting build errors on node 20:

npm ERR! In file included from ../angle/src/common/debug.h:16,
npm ERR!                  from ../angle/src/common/mathutil.h:12,
npm ERR!                  from ../angle/src/common/Float16ToFloat32.cpp:9:
npm ERR! ../angle/src/common/angleutils.h:36:14: error: ‘uintptr_t’ does not name a type
npm ERR!    36 | extern const uintptr_t DirtyPointer;
npm ERR!       |              ^~~~~~~~~
npm ERR! ../angle/src/common/angleutils.h:21:1: note: ‘uintptr_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
npm ERR!    20 | #include <vector>
npm ERR!   +++ |+#include <cstdint>
npm ERR!    21 | 
npm ERR! make: *** [angle/src/angle_common.target.mk:159: Release/obj.target/angle_common/angle/src/common/Float16ToFloat32.o] Error 1
npm ERR! gyp ERR! build error 
fazouane-marouane commented 8 months ago

@skerit I tried on a variety of macos and ubuntu (laptop + headless) without any issue other than missing prebuilts. As for your logs, you're probably missing a dependency and the source of errors like these are usually at the very top of the logs. You can try installing the missing dependencies if any (https://github.com/stackgl/headless-gl#system-dependencies) and maybe share your logs if there's nothing sensitive there.

HarelM commented 7 months ago

I've just upgraded my CI (ubuntu) to use node 20 and I believe the installation of this package fails. The following is the error:

npm ERR! code 1
npm ERR! path /home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/gl
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! prebuild-install warn install No prebuilt binaries found (target=20.10.0 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.0
npm ERR! gyp info using node@20.10.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v20.10.0/SHASUMS[25](https://github.com/maplibre/maplibre-gl-js/actions/runs/7100755864/job/19327891529?pr=3452#step:4:26)6.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.10.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/gl/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/runner/.cache/node-gyp/20.10.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/home/runner/.cache/node-gyp/20.10.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/runner/.cache/node-gyp/20.10.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/gl',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Package xi was not found in the pkg-config search path.
npm ERR! Perhaps you should add the directory containing `xi.pc'
npm ERR! to the PKG_CONFIG_PATH environment variable
npm ERR! No package 'xi' found
npm ERR! gyp: Call to 'pkg-config --libs-only-L --libs-only-other x11 xi xext' returned exit status 1 while in angle/src/angle.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/node-gyp/lib/configure.js:325:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:[28](https://github.com/maplibre/maplibre-gl-js/actions/runs/7100755864/job/19327891529?pr=3452#step:4:29))
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:[29](https://github.com/maplibre/maplibre-gl-js/actions/runs/7100755864/job/19327891529?pr=3452#step:4:30)4:12)
npm ERR! gyp ERR! System Linux 6.2.0-1016-azure
npm ERR! gyp ERR! command "/opt/hostedtoolcache/node/20.10.0/x[64](https://github.com/maplibre/maplibre-gl-js/actions/runs/7100755864/job/19327891529?pr=3452#step:4:65)/bin/node" "/home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/runner/work/maplibre-gl-js/maplibre-gl-js/node_modules/gl
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v9.3.0
npm ERR! gyp ERR! not ok

This is the CI run: https://github.com/maplibre/maplibre-gl-js/actions/runs/7100755864/job/19327891529?pr=3452

Relevant PR: https://github.com/maplibre/maplibre-gl-js/pull/3452

Am I doing anything wrong?

Probably similar to #267

dhritzkiv commented 7 months ago

@HarelM it looks like libxi isn't present.

Try sudo apt-get -y install libxi-dev, and see if that resolves it.

HarelM commented 7 months ago

Thanks for the tip! I have decided to remove this dependency and mock gl behavior when running jest tests. Thanks for all the work on this lib!

xeoshow commented 4 months ago

Strongly need prebuilt binaries for node 20 (or other new node versions), especially on windows. It is too complex and time consuming for installing windows-build-tools (more than 3GB) for just building a small package (compared to 3GB) like headless-gl ...

A bit of context on this: The library still works on node 20 but the prebuilt binaries don't seem to be published for this version. So it builds necessarily on install.

xeoshow commented 4 months ago

Anyone used it within electron? I got below error after days of struggling:

An error occurred: D:\gitrepository\yy-software\build\node_modules\.pnpm\gl@6.0.2\node_modules\gl\src\javascript\native-gl.js:1
Error: The module '\\?\D:\gitrepository\yy-software\build\node_modules\.pnpm\gl@6.0.2\node_modules\gl\build\Release\webgl.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 115. This version of Node.js requires
NODE_MODULE_VERSION 121. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (node:electron/js2c/node_init:2:2214)
    at Module._extensions..node (node:internal/modules/cjs/loader:1343:18)
    at Object.func [as .node] (node:electron/js2c/node_init:2:2214) {
  code: 'ERR_DLOPEN_FAILED'
}

I used "electron": "29.1.0", which has corresponding NODE_MODULE_VERSION 121, and after checking electron releases info from below link, there is NO NODE_MODULE_VERSION 115. So I had to try the electron-rebuild process, till now I still failed on this step. Could you please help to provide a version with support to the latest LTS nodejs version? So for the electron users, there is NO need to use electron-rebuild, which is really a great pain on windows. Your help is highly appreciated!

https://releases.electronjs.org/releases.json
dhritzkiv commented 4 months ago

Prebuilds are available for linux/macOS with the latest v8.0.2 release. Node versions 18 and 20 are supported. Sorry for the wait!

xeoshow commented 4 months ago

@dhritzkiv Thank you very much! By "Node versions 18 and 20 are supported", does it mean all the versions of 18.X.X and 20.X.X are supported, or some specific versions of 18 and 20 are supported? Since I have to integrate headless-gl into electron app, I will need to pick the exact version supported by v8.0.2, thanks again v v much!

dhritzkiv commented 4 months ago

@xeoshow it should be all versions: 18.x.x and 20.x.x.

As for electron, it has a different abi version than node (unless something has recently changed), so the prebuilds won't work there – it'll have to build from source when you install.

xeoshow commented 4 months ago

Thank you very much for your kind help.

@xeoshow it should be all versions: 18.x.x and 20.x.x.

As for electron, it has a different abi version than node (unless something has recently changed), so the prebuilds won't work there – it'll have to build from source when you install.

ImpChiang commented 2 months ago

@dhritzkiv @xeoshow hi,when i build electron in windows, its fails, following is the error:

 npm ERR! (Use `node --trace-warnings ...` to show where the warning was created)
    npm ERR! prebuild-install warn install Request timed out
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@9.4.1
    npm ERR! gyp info using node@20.10.0 | win32 | x64
    npm ERR! gyp info find Python using Python version 3.6.6 found at "C:\Program Files\python\python.exe"
    npm ERR! gyp info find VS using VS2017 (15.9.34729.27) found at:
    npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
    npm ERR! gyp info find VS run with --verbose for detailed information
    npm ERR! gyp info spawn C:\Program Files\python\python.exe
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   'D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\node-gyp\\gyp\\gyp_main.py',
    npm ERR! gyp info spawn args   'binding.gyp',
    npm ERR! gyp info spawn args   '-f',
    npm ERR! gyp info spawn args   'msvs',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\gl\\build\\config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\node-gyp\\addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\Users\\kmxxg\\.electron-gyp\\29.3.0\\include\\node\\common.gypi',
    npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
    npm ERR! gyp info spawn args   '-Dvisibility=default',
    npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\kmxxg\\.electron-gyp\\29.3.0',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\kmxxg\\\\.electron-gyp\\\\29.3.0\\\\<(target_arch)\\\\node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\gl',
    npm ERR! gyp info spawn args   '-Dnode_engine=v8',
    npm ERR! gyp info spawn args   '--depth=.',
    npm ERR! gyp info spawn args   '--no-parallel',
    npm ERR! gyp info spawn args   '--generator-output',
    npm ERR! gyp info spawn args   'D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\gl\\build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   'build/binding.sln',
    npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
    npm ERR! gyp info spawn args   '/nologo',
    npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp ERR! build error
    npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onExit (D:\electron-ai\node_modules\inkpaint\node_modules\node-gyp\lib\build.js:203:23)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
    npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
    npm ERR! gyp ERR! System Windows_NT 10.0.22631
    npm ERR! gyp ERR! command "C:\\ProgramData\\nvm\\node.exe" "D:\\electron-ai\\node_modules\\inkpaint\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
    npm ERR! gyp ERR! cwd D:\electron-ai\node_modules\inkpaint\node_modules\gl
    npm ERR! gyp ERR! node -v v20.10.0
    npm ERR! gyp ERR! node-gyp -v v9.4.1
    npm ERR! gyp ERR! not ok

how to solve this?

dhritzkiv commented 2 months ago

@ImpChiang Hmm the error from Visual Studio is not very helpful. Any chance you can get a more detailed message somehow? (I'm not familiar with Windows anymore, so I can't really walk you through with specific steps)

Also, I'm not sure if the current build process is supported with Visual Studio 2017 toolchain. Are you able to use a more recent version, and see it if produces better results?

ImpChiang commented 2 months ago

@ImpChiang Hmm the error from Visual Studio is not very helpful. Any chance you can get a more detailed message somehow? (I'm not familiar with Windows anymore, so I can't really walk you through with specific steps)

Also, I'm not sure if the current build process is supported with Visual Studio 2017 toolchain. Are you able to use a more recent version, and see it if produces better results?

I use electron version 29.3.0 within nodejs version 20.9.0,when use electron-builder it throw an error prebuild-install http 404 https://github.com/stackgl/headless-gl/releases/download/v6.0.2/gl-v6.0.2-electron-v121-win32-x64.tar.gz

dhritzkiv commented 2 months ago

@ImpChiang that's expected to happen, as:

  1. there are no prebuilt versions for node on Windows at this time. This may change in the future.
  2. there are no prebuilt versions for Electron (on any platform). There are no plans to produce prebuilt versions for Electron at this time.

That said, prebuilt versions are a convenience, and when installing headless-gl, it should still build from source using a build toolkit on your system. It looks like it's failing when it tries to build with Visual Studio.

ImpChiang commented 2 months ago

@ImpChiang that's expected to happen, as:

  1. there are no prebuilt versions for node on Windows at this time. This may change in the future.
  2. there are no prebuilt versions for Electron (on any platform). There are no plans to produce prebuilt versions for Electron at this time.

That said, prebuilt versions are a convenience, and when installing headless-gl, it should still build from source using a build toolkit on your system. It looks like it's failing when it tries to build with Visual Studio.

ok,Thanks a lot