Yabai: Apple Silicon M1

Created on 18 Nov 2020  路  20Comments  路  Source: koekeishiya/yabai

Placeholder to track support for Apple Silicon M1 at some point in the distant future.

Couple of things to be mentioned..

  1. The scripting-addition obviously needs a full rewrite for the ARM architecture and I do not actually have hands on experience with any ARM processor. This should not be a blocker, but will take time as the Dock.app ARM binary needs to be reverse engineered in the same way we did the x86-64 version.

  2. As this project does not have any external dependencies with the exception of the C standard library and Apple frameworks, I would expect basic support (read: compile and run) for Apple Silicon to work with close to no changes. Considering the performance differences between the models I am also interested in knowing if this will provide a noticeably better user experience when interacting with applications through the accessibility API, as yabai is doing, when managing windows.
    The master branch should now compile and run fine on Apple Silicon.

Feel free to discuss potential issues or post notable mentions in this issue.
If you are one of the people that have decided to get a first gen. M1 machine and are a developer, it would be great to see how yabai (or similar software) ends up running.

I'm undecided whether to get one of the new machines, or wait for further adjustments to their high-end machines.
Probably won't be getting one any time soon, so don't expect official support for some time.

discussion

Most helpful comment

Thanks for your hard working! Wish you a good day.

All 20 comments

Wow, so quick and nice!

Does this https://github.com/koekeishiya/yabai/commit/4410fef0fd272fc00a527f317351bb007bafe073 mean we can run script additions on M1 now?

I don't even know if the method for code injection is still going to work on the M1, and I can't really verify anything as I don't have one. The above commits are mostly just future notes for myself for when I do end up buying one, or if other members in the community want to do the work required to support the M1.

I have made adjustments to the injection process that I believe should work on the M1. If it works; the current master should support things such as window borders, opacity, layers (sticky windows) and such, but none of the spaces functionality will work yet.

Edit:
For people with experience in reverse engineering; basically locate the functions and object instances using the patterns provided in the osax/x86_64/payload.m file in the x86_64 binary, look for patterns that let you identify the same function in the arm64 binary, and fill out osax/arm64/payload.m. These patterns are then resolved in the function init_instances() in osax/payload.m. There is some inline x86_64 specific code in osax/payload.m when both resolving and calling some of these functions that also require changes.

Can't build on M1, error in the attachment.

1.txt

Should be resolved now.

I have both yabai and skhd up and running on my m1.
Screen Shot 2020-11-22 at 6 24 37 PM

So far so good! Here are a few small things I have noticed so far. Some of this might be my ignorance/configuration, but figured I would report it either way.

Screenshot of the first thing:
Screen Shot 2020-11-22 at 6 17 37 PM

This one is likely me being dumb, but for some reason I felt like the borders worked fine even on windows with a border radius of sorts.

The second thing:
I am seeing borders on workspaces for windows that aren't there/are on other workspaces maybe?/are hidden? ... I'm not entirely sure what is causing that.

Note: I don't have the scripting additions up and running at all, but I am down to try and get it going as well.

Thanks for all your work on this!

Window borders require the scripting addition to work correctly. The current master should support this, but spaces functionality is not yet implemented for arm.

I've installed master, I can confirmed that borders are not working (still shows "failed to inject payload into Dock.app!"), but yabai -m window --space N works.

Can you post the output of the following commands:
Screenshot 2020-11-23 at 17 18 06

Screen Shot 2020-11-24 at 00 29 17

Right, so it seems to me like it should be working fine. I'm probably just doing something wrong when setting up the thread state for arm64 here: https://github.com/koekeishiya/yabai/blob/master/src/osax/mach_loader.c#L94

Added a commit to master that will print the error; could you fetch that, compile and run sudo yabai --load-sa again and post the output?

sudo yabai --load-sa
could not spawn remote thread: (os/kern) protection failure
yabai: scripting-addition failed to inject payload into Dock.app!

Hmm how about now? I don't think it should matter, but it is my last idea as of now.

Still the same.

@cxa Can you try the latest commit? clean, make and reinstall the scripting addition before finally trying to load it.

I installed latest commit with brew install koekeishiya/formulae/yabai --HEAD, this should be a clean rebuild? After that I run

sudo yabai --uninstall-sa
sudo yabai --install-sa
sudo yabai --load-sa

Unfortunately it was still the same result.

Hmm aight, I give up for now; I don't see what I'm doing wrong.

Thanks for your hard working! Wish you a good day.

This seems like it could be relevant for the M1: https://bazad.github.io/2018/10/bypassing-platform-binary-task-threads/

Good luck. I will a bit before buying a M1, and a working yabai is one of my requirement :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koekeishiya picture koekeishiya  路  4Comments

zoenglinghou picture zoenglinghou  路  3Comments

eraserhd picture eraserhd  路  4Comments

Hum4n01d picture Hum4n01d  路  4Comments

stylerw picture stylerw  路  4Comments