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 Apple Silicon! #306

Closed
ccorcos opened this issue Nov 3, 2021 · 18 comments
Closed

Support Apple Silicon! #306

ccorcos opened this issue Nov 3, 2021 · 18 comments
Labels
enhancement Enhancement to existing features

Comments

@ccorcos
Copy link

ccorcos commented Nov 3, 2021

Short overview

The new Mac M1 Pro is sweet! But this library doesn't work anymore 😭

Use case

Detailed feature description

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @nut-tree/nut-js@1.7.0: wanted {"os":"linux,darwin,win32","arch":"x64,ia32"} (current: {"os":"darwin","arch":"arm64"})
npm ERR! notsup Valid OS:    linux,darwin,win32
npm ERR! notsup Valid Arch:  x64,ia32
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: arm64

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chet/.npm/_logs/2021-11-03T15_56_11_865Z-debug.log

Additional content

Please provide any (mandatory) additional data for your desired feature

@s1hofmann
Copy link
Member

Hi @ccorcos 👋

I'd love to port nut.js to Apple Silicon, however, I do not own an M1 Mac.
Since my current machine is fairly new it's not feasible for me to get a new one, especially since it would only be for this particular reason.

Given this, it still boils down to what I said in #224

Just a quick update on this issue: As I don't own an M1 Mac I will only spend time on this once nut.js donations allow me to get one or someone is willing to provide me an M1 Mac.

As soon as it's possible, I'm all in 👍

@ccorcos
Copy link
Author

ccorcos commented Nov 3, 2021

Ah, I see...

  1. This is a decent option for just renting one in the cloud:

https://www.scaleway.com/

image

  1. I'm happy to help! I'm not terribly experiences with C or any of that though. Any ideas where I should start? 🙏

@s1hofmann
Copy link
Member

Oh, this actually looks like a pretty solid option, I'll check that out! 👍

Now that I know you're running an M1 Mac, could you give @nut-tree/nut-js@next a try?
With image search being optional the actual blocker for Apple Silicon should no longer be included by default.

As I'm currently making quite good progress towards 2.0.0 I'll definitely try out the M1 build, but since I do not know too much about it yet, it's hard to tell where I could need a helping hand. Having a second machine for testing is definitely a good start, so I'll simply reach out to you as soon as I have something to test 👍

@s1hofmann s1hofmann added the enhancement Enhancement to existing features label Nov 3, 2021
@ccorcos
Copy link
Author

ccorcos commented Nov 6, 2021

Sounds good! I'll try this out next week -- got a little busy all of a sudden.

What's your game plan for 2.0.0? 😄

@s1hofmann
Copy link
Member

What's your game plan for 2.0.0?

The biggest change is the introduction of a little plug-in system which allows one to provide a custom implementation for e.g. image matching. This enabled moving image matching code and it's dependencies into a separate, opt-in package, thus removing the node version dependence in case you don't need any image matching.
And it enables users to publish their own implementations!

Other than that I'm currently re-building the whole image matching package from scratch to reduce the amount of complexity tied to it and to make it independent of node/Electron versions.

Oh, and I'm working on an OCR plug-in!

@ccorcos
Copy link
Author

ccorcos commented Nov 7, 2021 via email

@s1hofmann
Copy link
Member

s1hofmann commented Nov 7, 2021

With systems you have control over, like your Electron setup, this is absolutely feasible.

For general UI testing and automation, e.g. when dealing with legacy applications or systems you only have access to via VNC, image based testing is often the only way to go.

But we're getting a bit off-topic on this issue :) Want to join the nut.js Discord to continue on this topic?

@ccorcos
Copy link
Author

ccorcos commented Nov 8, 2021 via email

@ccorcos
Copy link
Author

ccorcos commented Nov 16, 2021

❯❯❯ npm install --save-dev @nut-tree/nut-js@next
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @nut-tree/nut-js@1.7.1-next.20211115155253: wanted {"os":"linux,darwin,win32","arch":"x64,ia32"} (current: {"os":"darwin","arch":"arm64"})
npm ERR! notsup Valid OS:    linux,darwin,win32
npm ERR! notsup Valid Arch:  x64,ia32
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: arm64

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chet/.npm/_logs/2021-11-16T07_50_11_190Z-debug.log

@ccorcos
Copy link
Author

ccorcos commented Nov 16, 2021

Added arm64 to package.json just so it will attempt to install:

  "cpu": [
    "x64",
    "ia32",
    "arm64"
  ],

Ran npm run compile and npm test:

❯❯❯ npm test

> @nut-tree/nut-js@1.7.0 test
> jest --runInBand

 PASS  lib/screen.class.spec.ts
 FAIL  lib/provider/native/libnut-mouse.class.spec.ts
  ● Test suite failed to run

    dlopen(/Users/chet/Code/js/nut.js/node_modules/@nut-tree/libnut-darwin/build/Release/libnut.node, 0x0001): tried: '/Users/chet/Code/js/nut.js/node_modules/@nut-tree/libnut-darwin/build/Release/libnut.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/libnut.node' (no such file), '/usr/lib/libnut.node' (no such file)

Digging into libnut-darwin now... (I figure I'll write my notes here)

@s1hofmann
Copy link
Member

Could you check the output of lipo -info libnut.node?

@ccorcos
Copy link
Author

ccorcos commented Nov 16, 2021

From the develop branch:

~/C/j/nut.js ❯❯❯ lipo -info node_modules/@nut-tree/libnut-darwin/build/Release/libnut.node
Non-fat file: node_modules/@nut-tree/libnut-darwin/build/Release/libnut.node is architecture: x86_64

I downloaded libnut and built it too. Seems to work:

~/C/j/libnut ❯❯❯ lipo -info build/Release/libnut.node
Architectures in the fat file: build/Release/libnut.node are: x86_64 arm64 

But I can't figure out how to link the projects together. Somehow the libnut-darwin package shows up...

@s1hofmann
Copy link
Member

So the second snippet is for the @next package from npm?

@ccorcos
Copy link
Author

ccorcos commented Nov 16, 2021

Simply installing the @next version is problematic:

❯❯❯ npm install --save-dev @nut-tree/nut-js@next
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @nut-tree/nut-js@1.7.1-next.20211115155253: wanted {"os":"linux,darwin,win32","arch":"x64,ia32"} (current: {"os":"darwin","arch":"arm64"})
npm ERR! notsup Valid OS:    linux,darwin,win32
npm ERR! notsup Valid Arch:  x64,ia32
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: arm64

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chet/.npm/_logs/2021-11-16T07_50_11_190Z-debug.log

Need to add arm64 to the cpus section in the package.json. Then I can give it a try 😄

@s1hofmann
Copy link
Member

I'll take care of it later today 👍
Thanks for your debugging help :)

s1hofmann added a commit to nut-tree/libnut-core that referenced this issue Nov 16, 2021
@s1hofmann
Copy link
Member

@ccorcos Can you give it another try?

@ccorcos
Copy link
Author

ccorcos commented Nov 17, 2021

Back in business! Thanks for the help 😄

@ccorcos ccorcos closed this as completed Nov 17, 2021
@s1hofmann
Copy link
Member

/cc @danielehrhardt

s1hofmann added a commit that referenced this issue Nov 26, 2021
* (#259) Introduced ImageProcessor interface

* (#259) imageToJimp converter function

* (#259) RGBA dataclass

* (#259) Implement ImageProcessor and register the new provider

* (#259) Re-use imageToJimp and clean up tests

* (#259) Fixed import for Image which was previously importing from dist

* Maintenance/310/remove adapters (#311)

* (#310) Delete both adapters

* (#310) Migrate window.function to not use adapters

* (#310) Migrated window.class to not use adapters

* (#310) Migrated screen.class to not use adapters

* (#310) Migrated movement.function to not use adapters

* (#310) Migrated mouse.class to not use adapters

* (#310) Remove leftover notions of adapters in test description

* (#310) Fixed expected format when saving a screenshot to disk

* (#310) Migrated keyboard.class to not use adapters

* (#310) Migrated clipboard.class to not use adapters

* (#310) Migrated assert.class test to not use adapters

* (#310) Migrated all exported instances to not use adapters

* (#310) Removed mention of adapter from test description

* Added sponsors listing to README.md

* (#306) Update supported cpus to include Apple Silicon (arm64)

* Add https://github.com/stoefln to sponsors listing

* Feature/204/screen find image needles (#319)

* (#204) Enabled passing of Image data to Screen#find

* (#204) Updated screen tests

* (#204) Removed plugin test from main repo

* (#204) Removed plugin test from Docker test runs

* (#204) Introduced additional id property to images

* (#204) Adjusted tests and image usage to new id property

* (#204) Added helper function to make loading image resources easier

* (#204) Adapted toShow matcher to new find parameters

* (#204) Re-use loadImageResource function

* Feature/320/find accept promise (#322)

* (#320) Make find, and the functions re-using it, accept Promise<Image>

* (#320) Update toShow matcher accordingly

* (#320) Update tests

* (#321) Added `findAll` to Screen (#323)

* (#259) Add `colorAt` to screen class
s1hofmann added a commit to nut-tree/libnut-core that referenced this issue Dec 11, 2021
* (#47) Deleted src/buffer_finalizer.h

* (#47) Switched to using Buffer::Copy

* Fix for screen highlight window minimized intead close

* Create LICENSE.md

* Add Helper Methods for calculating the required absolute position on the screen

* Refactor moveMouse to use SendInput for absolute position movements on windows

* Indentation

* Add Coord constant

* Squash x and y coord methods
Make Absolute coord calculation return MMPoint

* Call coord calculator with MMPoint

* Correct Types and Return values

* Import for getMainDisplaySize

* Bugfix for lost co-ordinate precision

* (nut-tree/nut.js#249) Enable DPI awareness when fetching screen content to always capture the full screen content even with scaling applied

* (nut-tree/nut.js#249) Refactor scale calculation to work correctly with custom regions

* (nut-tree/nut.js#306) Specify supported os and cpu in package.json to enable Apple Silicon

* Remove scan code block

* Release/v2.1.3 (#88)

* Update changelog for v2.1.3

* Release v2.1.3

Co-authored-by: Gyula Madarasz <gyula.madarasz@gmail.com>
Co-authored-by: Reiss Cashmore <reiss.cashmore@outlook.com>
s1hofmann added a commit that referenced this issue Dec 17, 2021
* Bump tar from 4.4.13 to 4.4.15

Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v4.4.13...v4.4.15)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump tar from 4.4.13 to 4.4.15 in /e2e/electron-test

Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v4.4.13...v4.4.15)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump path-parse from 1.0.6 to 1.0.7

Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* (#190) Rename private field native to nativeAdapter to stay consistent

* (#255) Only run sonar step if SONAR_TOKEN is set

* Added link to API docs to README.md

* (#260) Added missing lookup for 'delete' key

* (#262) Upgraded to Typescript 4.4.2 with minor adjustments

* (#265) Upgraded to SonarSource/sonarcloud-github-action v1.6

* Bump tar from 4.4.15 to 4.4.19 in /e2e/electron-test

Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v4.4.15...v4.4.19)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Revert conditional execution of Sonar reports

* (#269) Export some internal objects

* (#271) Disable sonarcloud reporting to unstuck cross-platform checks

* (#271) Updated dependencies, fix conflicts

* (#271) Pin versions for clipboardy

* (#271) Move Jest timeout config out of test

* (#271) Debug failing AbortController test

* (#271) Revert node-abort-controller version bump due to inconsistencies. (Typescript complains on compile time, but after the change it fails on runtime)

* (#271) Fixed timeout configs in e2e tests

* Added demo video to README.md

* (#269) Changed export level and renamed classes to be less ambiguous

* (#278) Added grab and grabRegion methods to Screen

* (#278) Adjusted captureRegion and grabRegion parameters to accept Promises

* (#285) Added additional publish step for GitHub package registry

* (#258) Refined wording in snapshot release workflow

* Feature/292/provider registry (#293)

* (#292) Draft provider registry

* (#292) Register ImageWriter and ImageReader instances

* Feature/294/export provider interfaces (#295)

* (#294) Export interfaces for providers

* (#294) Align naming of interfaces

* (#296) Add missing export for ImageWriterParameters (#297)

* (#301) Exported FilType enum (#302)

* Feature/279/separate image matching (#298)

* (#279) Remove image matching provider code

* (#279) Remove image matching providers from registry

* (#279) Update vision adapter test

* (#279) Remove opencv4nodejs-prebuilt dependency

* (#279) Plugin e2e test

* (#279) Init plugin e2e test

* (#279) Align e2e package versions

* (#279) Fix resource path

* (#279) Add error info to output, formatting

* (#279) Run plugin test in Docker environment

* (#279) Export FileType enum

* (#279) Move screen e2e test to plugin e2e test subpackage since it requires the template-matcher package as well

* (#279) Move keyboard e2e test to plugin subpackage as well

* feat: adding the rest of the function keys (#305)

* (#130) Introduce EasingFunction interface (#304)

* (#130) Updated implementation

* (#130) Easing function refinement

* Feature/307/default imagereader imagewriter (#308)

* (#307) Add jimp dependencz

* (#307) Implement image reader

* (#307) Implement image writer

* (#307) Test data

* (#307) Register both providers

* (#307) Stick to BGR color format when loading images

* (#307) Expose imagereader and imagewriter through utility functions

* (#307) Updated tests to verify calls to Jimp

* (#307) Mock jimp in testcases using the pluginRegistry to avoid ReferenceErrors

* (#307) Mock jimp in e2e testcases to avoid ReferenceErrors

* Maintenance/310/remove adapters (#311)

* (#310) Delete both adapters

* (#310) Migrate window.function to not use adapters

* (#310) Migrated window.class to not use adapters

* (#310) Migrated screen.class to not use adapters

* (#310) Migrated movement.function to not use adapters

* (#310) Migrated mouse.class to not use adapters

* (#310) Remove leftover notions of adapters in test description

* (#310) Fixed expected format when saving a screenshot to disk

* (#310) Migrated keyboard.class to not use adapters

* (#310) Migrated clipboard.class to not use adapters

* (#310) Migrated assert.class test to not use adapters

* (#310) Migrated all exported instances to not use adapters

* (#310) Removed mention of adapter from test description

* Added sponsors listing to README.md

* (#306) Update supported cpus to include Apple Silicon (arm64)

* Add https://github.com/stoefln to sponsors listing

* Feature/204/screen find image needles (#319)

* (#204) Enabled passing of Image data to Screen#find

* (#204) Updated screen tests

* (#204) Removed plugin test from main repo

* (#204) Removed plugin test from Docker test runs

* (#204) Introduced additional id property to images

* (#204) Adjusted tests and image usage to new id property

* (#204) Added helper function to make loading image resources easier

* (#204) Adapted toShow matcher to new find parameters

* (#204) Re-use loadImageResource function

* Feature/320/find accept promise (#322)

* (#320) Make find, and the functions re-using it, accept Promise<Image>

* (#320) Update toShow matcher accordingly

* (#320) Update tests

* (#321) Added `findAll` to Screen (#323)

* Feature/259/get screen pixel color (#325)

* (#259) Introduced ImageProcessor interface

* (#259) imageToJimp converter function

* (#259) RGBA dataclass

* (#259) Implement ImageProcessor and register the new provider

* (#259) Re-use imageToJimp and clean up tests

* (#259) Fixed import for Image which was previously importing from dist

* Maintenance/310/remove adapters (#311)

* (#310) Delete both adapters

* (#310) Migrate window.function to not use adapters

* (#310) Migrated window.class to not use adapters

* (#310) Migrated screen.class to not use adapters

* (#310) Migrated movement.function to not use adapters

* (#310) Migrated mouse.class to not use adapters

* (#310) Remove leftover notions of adapters in test description

* (#310) Fixed expected format when saving a screenshot to disk

* (#310) Migrated keyboard.class to not use adapters

* (#310) Migrated clipboard.class to not use adapters

* (#310) Migrated assert.class test to not use adapters

* (#310) Migrated all exported instances to not use adapters

* (#310) Removed mention of adapter from test description

* Added sponsors listing to README.md

* (#306) Update supported cpus to include Apple Silicon (arm64)

* Add https://github.com/stoefln to sponsors listing

* Feature/204/screen find image needles (#319)

* (#204) Enabled passing of Image data to Screen#find

* (#204) Updated screen tests

* (#204) Removed plugin test from main repo

* (#204) Removed plugin test from Docker test runs

* (#204) Introduced additional id property to images

* (#204) Adjusted tests and image usage to new id property

* (#204) Added helper function to make loading image resources easier

* (#204) Adapted toShow matcher to new find parameters

* (#204) Re-use loadImageResource function

* Feature/320/find accept promise (#322)

* (#320) Make find, and the functions re-using it, accept Promise<Image>

* (#320) Update toShow matcher accordingly

* (#320) Update tests

* (#321) Added `findAll` to Screen (#323)

* (#259) Add `colorAt` to screen class

* (#324) Updated assert to handle valid find parameter types (#326)

* Feature/329/find image parameter type (#330)

* (#329) Make `Screen#find` only accept `Image` or `Promise<Image>` parameter type

* (#329) Update docstrings

* (#329) Adjusted tests

* (#329) Remove leftover string type checks

* (#327) Apply pixel density scaling when querying pixel color information (#332)

* (#312) Added new parameter `updateInterval` to `waitFor` to make the interval user configurable (#333)

* Feature/233/audio keys (#334)

* (#233) Extended key.enum with audio multimedia keys

* (#233) Extended Key mapping

* Feature/336/colormode conversion (#337)

* (#336) Introduced colormode enum

* (#336) Extended Image class with color mode conversion methods

* (#336) Set color mode on images when reading from disk

* (#336) Set colormode on images when grabbing screen content

* (#336) Limit switching of channels only to BGR images

* (#336) Export ColorMode enum

* (#336) Chasing down another async error in tests due to jimp

* Update README and docstrings

* Fix y offset for tests on macos-latest

* Maintenance/341/remove old code (#342)

* (#341) Remove Region#scaled

* (#341) Remove LocationParameters

* Maintenance/340/refine types (#343)

* (#340) Refactor the `data` property of `ImageWriterParameters` to `image`

* (#340) Refactor `Image#data` to a `Buffer` instead of `any`

* (#340) Fixed screen tests

* Re-enable sonar step (#344)

* Release/v2.0.0 rc1 (#345)

* Updated readme

* RC1

* Update @nut-tree/libnut to 2.1.3

* Center image in readme again

* Fixed typedoc config

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ahad <me@ahadcove.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to existing features
Projects
None yet
Development

No branches or pull requests

2 participants