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

Support for Apple ARM macOS devices (e.g. MacBook Air M1) #14

Closed
raould opened this issue Jun 26, 2021 · 18 comments
Closed

Support for Apple ARM macOS devices (e.g. MacBook Air M1) #14

raould opened this issue Jun 26, 2021 · 18 comments

Comments

@raould
Copy link

raould commented Jun 26, 2021

Error: dlopen(/Users/x/Dev/3d/node_modules/segfault-raub/bin-osx/segfault.node, 1): no suitable image found. Did find:
/Users/x/Dev/3d/node_modules/segfault-raub/bin-osx/segfault.node: mach-o, but wrong architecture

% uname -a
Darwin X-Air.lan 20.4.0 Darwin Kernel Version 20.4.0: Fri Mar 5 01:14:02 PST 2021; root:xnu-7195.101.1~3/RELEASE_ARM64_T8101 arm64

@raub
Copy link
Member

raub commented Jun 27, 2021

Hello. There is no support for any ARM arch now. One of the requirements for me is to be able to use GitHub Actions. I use them for building the final binaries. And I don't see any OSX ARM version available here https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on

So basically I have nothing against ARM. But I have no infrastructure to even start with this issue. There is a possibility of using a self-hosted runner for GitHub Actions, if there is a spare (ARM based) Mac available. As I've never had any Mac (and don't really want to), there is no other way I could build and test the solution at all.

But still, it's all open-source, and if you are really into it, you could try to get it running. You would have to rebuild all the involved modules. There are all the needed OSX build commands that are currently run on GitHub Actions. I can probably help if you have more questions trying to build it for ARM. But I certainly can't start working on it myself now.

@raub
Copy link
Member

raub commented Sep 24, 2022

@anion155
Copy link

anion155 commented Jan 7, 2024

Any updates here?

@anion155
Copy link

anion155 commented Jan 7, 2024

Maybe it would be easier to pack sources with npm package so it can be build locally?

@raub
Copy link
Member

raub commented Jan 9, 2024

The key idea of this project is to NOT build locally. And to fork and do anything you want if that doesn't fit you. Such as publishing your own versions with packed sources to build them locally.

Alternatively, you can contribute to the project by building locally on Mac M1 and providing the binaries. You can, of course, obtain and build them by cloning the repositories from GitHub. The problem with this approach is that it can't be automated like the other platforms.

@anion155
Copy link

Looks like macos-12 target can build m1 binaries though. There would need to be done some changes to build scripts to support it. I have been trying to build it locally, if I'll succeed in it I'll give you a thumbs up. If I'll succeed with local what would be better approach to provide you binaries, inside of an issue maybe?

@raub
Copy link
Member

raub commented Jan 10, 2024

@anion155 if you know how to cross-compile for M1 from x64 - that would work (in GitHub actions). I don't have a Mac, and not enough courage to research and test it in CI mode.

Also, I see some movement here: actions/runner-images#8439, so GitHub may already support M1, or in the near future.

If you build the binaries locally, you can zip and attach them even here. But there will be a whole bunch to cover all the dependencies. I wonder if it worths the effort.

@radeva
Copy link

radeva commented Jan 18, 2024

So basically I have nothing against ARM. But I have no infrastructure to even start with this issue. There is a possibility of > using a self-hosted runner for GitHub Actions, if there is a spare (ARM based) Mac available. As I've never had any Mac > (and don't really want to), there is no other way I could build and test the solution at all.

@raub Feel free to use FlyCI's M1 and M2 runners. Our runners are on average 2x faster and 2x cheaper than GitHub's AND we have a free tier for OSS projects (see below).

Install Instructions

  1. Install FlyCI app and
  2. Use a FlyCI runner in your workflow:
jobs:
 ci:
-    runs-on: macos-latest
+    runs-on: flyci-macos-large-latest-m1
   steps:
   - name: 👀 Checkout repo
     uses: actions/checkout@v4

500 mins/month Free for Public Repos

Since your repo is public, FlyCI offers 500 mins/month of free M1 runner usage with the flyci-macos-large-latest-m1 runner for public projects.

Don't hasitate to contact us in case the free tier doesn't suit your needs or you have any issues with the runners. Our team is here to support you!

Best Regards,
Veselina Radeva
Product Manager at FlyCI

@raub
Copy link
Member

raub commented Jun 2, 2024

@raould @anion155 the new version 4.3.0 should provide the missing MacOS ARM binaries. But I don't have any Mac to try them, I hope everything works.

@alexahdp
Copy link

alexahdp commented Jun 3, 2024

@raub, I've checked - it doesn't work on my Mac. When I try to run node brush.js, I see an error:

GLFW Error 65542: NSGL: OpenGL ES is not available via NSGL
GLFW Error 65542: NSGL: OpenGL ES is not available via NSGL
/Users/alexahdp/dev/3d-core-raub/node_modules/glfw-raub/js/window.js:499
			this._window = glfw.createWindow(
			                    ^

Error: Can't create GLFW window
    at Document._create (/Users/alexahdp/dev/3d-core-raub/node_modules/glfw-raub/js/window.js:499:24)
    at set mode [as mode] (/Users/alexahdp/dev/3d-core-raub/node_modules/glfw-raub/js/window.js:208:9)
    at new Window (/Users/alexahdp/dev/3d-core-raub/node_modules/glfw-raub/js/window.js:70:13)
    at new Document (/Users/alexahdp/dev/3d-core-raub/node_modules/glfw-raub/js/document.js:24:3)
    at _init (/Users/alexahdp/dev/3d-core-raub/js/index.js:77:14)
    at init (/Users/alexahdp/dev/3d-core-raub/js/index.js:135:11)
    at Object.<anonymous> (/Users/alexahdp/dev/3d-core-raub/examples/3d-core/brush.js:7:33)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)

Node.js v20.13.1

Chip: Apple M1 Pro
MacOS version: Sonoma 14.5
nodejs version: 20.13.1

@raub
Copy link
Member

raub commented Jun 3, 2024

@alexahdp if examples/3d-core/brush.js (here) set isGles3: false, - will it work?

There seems to be a lot of conditions that make it fail.

@alexahdp
Copy link

alexahdp commented Jun 5, 2024

@raub , no I see the next in the console:

THREE.WebGLProgram: Shader Error 1282 - VALIDATE_STATUS false

Material Name:
Material Type: ShaderMaterial

Program Info Log: ERROR: One or more attached shaders not successfully compiled
VERTEX

ERROR: 0:46: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:47: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:48: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:72: Invalid storage qualifiers 'out' in global variable context
ERROR: 0:75: Use of undeclared identifier 'projPos'
ERROR: 0:75: Use of undeclared identifier 'position'
ERROR: 0:77: Use of undeclared identifier 'position'

  41: 	attribute vec3 instanceColor;
  42: #endif
  43: #ifdef USE_INSTANCING_MORPH
  44: 	uniform sampler2D morphTexture;
  45: #endif
> 46: attribute vec3 position;
  47: attribute vec3 normal;
  48: attribute vec2 uv;
  49: #ifdef USE_UV1
  50: 	attribute vec2 uv1;
  51: #endif
  52: #ifdef USE_UV2
FRAGMENT

ERROR: 0:4: 'layout' : syntax error: syntax error

  1: #version 120
  2:
  3: #define varying in
> 4: layout(location = 0) out vec4 pc_fragColor;
  5: #define gl_FragColor pc_fragColor
  6: #define gl_FragDepth gl_FragDepth
  7: #define texture2D texture
  8: #define textureCube texture
  9: #define texture2DProj textureProj
  10: #define texture2DLodEXT textureLod

program doesn't fail, it just shows a black screen

@raub
Copy link
Member

raub commented Jun 6, 2024

@alexahdp, it probably needs isWebGL2: false, too

@alexahdp
Copy link

alexahdp commented Jun 6, 2024

@raub, turned it off too:

const { Screen, Brush, loop } = init({
        isGles3: false,
        isWebGL2: false,
        autoEsc: true,
        autoFullscreen: true,
});

Now I see the next error:

node brush.js
THREE.WebGLProgram: Shader Error 1282 - VALIDATE_STATUS false

Material Name:
Material Type: ShaderMaterial

Program Info Log: ERROR: One or more attached shaders not successfully compiled
VERTEX

ERROR: 0:46: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:47: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:48: Invalid storage qualifiers 'in' in global variable context
ERROR: 0:72: Invalid storage qualifiers 'out' in global variable context
ERROR: 0:75: Use of undeclared identifier 'projPos'
ERROR: 0:75: Use of undeclared identifier 'position'
ERROR: 0:77: Use of undeclared identifier 'position'

  41: 	attribute vec3 instanceColor;
  42: #endif
  43: #ifdef USE_INSTANCING_MORPH
  44: 	uniform sampler2D morphTexture;
  45: #endif
> 46: attribute vec3 position;
  47: attribute vec3 normal;
  48: attribute vec2 uv;
  49: #ifdef USE_UV1
  50: 	attribute vec2 uv1;
  51: #endif
  52: #ifdef USE_UV2
FRAGMENT

ERROR: 0:4: 'layout' : syntax error: syntax error

  1: #version 120
  2:
  3: #define varying in
> 4: layout(location = 0) out vec4 pc_fragColor;
  5: #define gl_FragColor pc_fragColor
  6: #define gl_FragDepth gl_FragDepth
  7: #define texture2D texture
  8: #define textureCube texture
  9: #define texture2DProj textureProj
  10: #define texture2DLodEXT textureLod

@raub
Copy link
Member

raub commented Jun 6, 2024

these are three.js shaders of #version 120 that can't run - maybe due to an insufficient GL version.

We can try the following: in init call, add option onBeforeWindow

const { Screen, Brush, loop } = init({
	isGles3: false,
	isWebGL2: false,
	autoEsc: true,
	autoFullscreen: true,
	onBeforeWindow: (window, glfw) => {
		glfw.windowHint(glfw.CONTEXT_VERSION_MAJOR, 3);
		glfw.windowHint(glfw.CONTEXT_VERSION_MINOR, 2);
	},
});

@alexahdp
Copy link

alexahdp commented Jun 6, 2024

No, still see:

node brush.js
THREE.WebGLProgram: Shader Error 1280 - VALIDATE_STATUS false

Material Name:
Material Type: ShaderMaterial

Program Info Log: ERROR: One or more attached shaders not successfully compiled
VERTEX

ERROR: 0:1: '' :  version '120' is not supported
ERROR: 0:2: '' :  #version required and missing.

> 1: #version 120
  2:
  3:
  4: #define attribute in
  5: #define varying out
  6: #define texture2D texture
  7:
FRAGMENT

ERROR: 0:1: '' :  version '120' is not supported
ERROR: 0:2: '' :  #version required and missing.
ERROR: 0:4: '0' : syntax error: integers in layouts require GLSL 140 or later

> 1: #version 120
  2:
  3: #define varying in
  4: layout(location = 0) out vec4 pc_fragColor;
  5: #define gl_FragColor pc_fragColor
  6: #define gl_FragDepth gl_FragDepth
  7: #define texture2D texture

@raub
Copy link
Member

raub commented Jun 7, 2024

Maybe try:

glfw.windowHint(glfw.CONTEXT_VERSION_MAJOR, 4);
glfw.windowHint(glfw.CONTEXT_VERSION_MINOR, 1);

or

glfw.windowHint(glfw.CONTEXT_VERSION_MAJOR, 2);
glfw.windowHint(glfw.CONTEXT_VERSION_MINOR, 1);

also try alternating isGles3 between true/false for all of the versions above (2.1, 3.2, 4.1)

😑 that's why I don't want a mac

@raub
Copy link
Member

raub commented Nov 7, 2024

The MacOS ARM support is provided but limited. The binaries now exist as per the OP's report. Please open new specific issues if you have shader errors or other particular problems.

@raub raub closed this as completed Nov 7, 2024
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

5 participants