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

DRM build is not working on some platforms #181

Open
konsumer opened this issue Jan 12, 2024 · 2 comments
Open

DRM build is not working on some platforms #181

konsumer opened this issue Jan 12, 2024 · 2 comments

Comments

@konsumer
Copy link
Collaborator

konsumer commented Jan 12, 2024

I am on Mac M1, in docker (just doing some build-testing) so it's technically ARM64 linux.

If I run a project that uses node-raylib, it seems to be trying to load the plain .node file, but it downloaded the drm file:

node:internal/modules/cjs/loader:1144
  const err = new Error(message);
              ^

Error: Cannot find module '../../build/Release/node-raylib.node'
Require stack:
- /test/node_modules/raylib/src/generated/node-raylib.js
- /test/node_modules/raylib/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/test/node_modules/raylib/src/generated/node-raylib.js:10:11)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/test/node_modules/raylib/src/generated/node-raylib.js',
    '/test/node_modules/raylib/index.js'
  ]
}

Node.js v21.1.0

On an ARM64 host, this will repro:

docker run -it --rm node bash
cd root
npm i raylib
node -e 'require("raylib")'

This is shape of node_modules:

node_modules/raylib/build
`-- Release
    `-- node-raylib-drm.node

I think @twuky and I talked about this before, but I think the DRM-stuff needs a little work. A possible solution, in my mind, is to just make a totally seperate npm lib that is only for drm. Essentially, a pi, for example, can run the regular .node file fine, with X, like any other linux, but gets more performance (and works without X) with the DRM-version, so if they were separate npm packages, the user could choose to specifically require that, if they want to. I think we could build/publish both npm packages in CI, so it's not really much of a code-change, other than our build-scripts.

Another option might be an env-var that chooses which native lib to load, but I feel like that could get a bit flakey (it would need to be set at all the different stages, like setup/download/build/runtime.)

An aspect of this issue, also, is that DRM-build is useful, even to non-arm64 (x86_64 can use it too) so targeting only arm64 is maybe not enough, anyway. Originally, we did this because it makes a huge difference on pi0-2 and other low-end ARM64 devices (like Anbernic handhelds) but I think giving everyone the option of DRM or X would be better.

I think this is all related to an overhaul of our build/download steps. It could definitely be simplified and improved.

I'd like to see this, as a total solution, and if it seems ok, I will work on it:

  • make a new package (maybe raylib-drm?) for DRM-only
  • build prebuilt drm & regular node packages, for arm64 & x86_64 in CI, for every tag (releases, but also testing tags, etc)
  • publish both to npm, as separate packages
  • make the download/build step smarter for end-users for both
  • test both versions on supported platforms: mac m1/x86_64, windows x86_64 (all 3 use "regular" build) and linux arm64/x86_64 (both drm and regular)

I figured out some CI tricks for doing better matrix-builds and copying assets into releases and stuff (see #182) so I think I can improve the whole setup.

@twuky
Copy link
Collaborator

twuky commented Jan 14, 2024

i remember another solution being that ARM platforms would download both, and then its up to the user to require raylib or raylib/drm. would something like that help here?

@konsumer
Copy link
Collaborator Author

I really like that, as a solution. essentially leave it up to the user, so they can include either one, since the default import will work fine (in X.)

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

2 participants