koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.37k stars 643 forks source link

macOS 14 Sonoma #1772

Closed 0xCUB3 closed 1 year ago

0xCUB3 commented 1 year ago

Yes, yes, it's the first day...

The good news is that yabai is functional. The bad news is that it randomly just stops working, restarts itself, works again, and the cycle continues. Sometimes when I try to start yabai manually, I get this error:

Bootstrap failed: 5: Input/output error Try re-running the command as root for richer errors. Error: Failure while executing; /bin/launchctl bootstrap gui/501 /Users/me/Library/LaunchAgents/homebrew.mxcl.yabai.plist exited with 5.

koekeishiya commented 1 year ago

Upgrade to yabai v5.0.6 and stop using brew services. There is a launchd interface directly in yabai now.

0xCUB3 commented 1 year ago

thank you! This works :) Will close for now unless another issue occurs

pupbrained commented 1 year ago

@0xCUB3 have you had any issues with yabai segfaulting over and over? I did the same thing as mentioned (upgrading to yabai v5.0.6 and using yabai --install-service) but when starting the service it runs for about a minute, then segfaults. Looking at the logs it seems to be failing on:

yabai: could not access accessibility features! abort..

But I've tried removing yabai from accessibility, restarting the service, and adding it back when it asked for the permission, and that didn't change anything.

(Apologies if I shouldn't post this here, just using this as I'm having a similar issue.)

0xCUB3 commented 1 year ago

remove all other "yabai" instances from accessibility and then try again. Make sure yabai is on the latest version too.

pupbrained commented 1 year ago

I've made sure to remove all the other instances, and I'm using yabai from the latest GitHub release.

0xCUB3 commented 1 year ago

Interesting. I followed the same steps and had no issues. Someone else will have to chime in.

koekeishiya commented 1 year ago

You should keep in mind that Sonoma is in developer preview 1 and the issues you experience are likely macOS issues/bugs, that will be fixed in later previews. This is even more likely considering you seem to be having issues using the accessiblity API, which is a publicly documented and fairly stable API (stable as in Apple very rarely, if ever, does breaking changes to this API).

0xCUB3 commented 1 year ago

yeah that's correct; the issues will likely resolve themselves over time. I mostly upgraded to test my own apps to see if they work ðŸĪŠ

pupbrained commented 1 year ago

You should keep in mind that Sonoma is in developer preview 1 and the issues you experience are likely macOS issues/bugs, that will be fixed in later previews. This is even more likely considering you seem to be having issues using the accessiblity API, which is a publicly documented and fairly stable API (stable as in Apple very rarely, if ever, does breaking changes to this API).

Yeah, that's most likely what's happening here. It's not too much of an issue, but I just wanted to see if it's happening to anybody else.

pupbrained commented 1 year ago

Okay, after trying a few more things, the segfault seems to be caused by focus_follows_mouse being set to autoraise?

After removing that line from my yabairc and re-running yabai, I've had it running for about 5 minutes now with no segfaults. Previously, it would immediately segfault when switching windows by moving the mouse to another window.

What I find especially odd, though, is that Amethyst's implementation of focus_follows_mouse works just fine, even with yabai running as the window manager and Amethyst being disabled.

EDIT: I cloned the yabai repo to my mac, and tried debugging it through CLion. From what I can tell, the segfaults happen when yabai attempts to switch window focus with an EXC_BAD_ACCESS. According to CLion, the error traces back to this line: https://github.com/koekeishiya/yabai/blob/fa966c7f26b660d8a71f06ab14ee33842810355d/src/window_manager.c#L1218

descensiontohell commented 1 year ago

It is not functional. It segfaults every focus switch. Gotta rollback the OS now

0xCUB3 commented 1 year ago

yes it started doing it for me again, even with the switch to the built-in launchd interface.

pupbrained commented 1 year ago

yes it started doing it for me again, even with the switch to the built-in launchd interface.

it seems to be either an issue with the focus-switching code, or how macOS Sonoma handles it.

ralphptorres commented 1 year ago

it seems to be either an issue with the focus-switching code, or how macOS Sonoma handles it.

I can confirm this. Other yabai window-specific commands like swap, warp, resize, toggle gap, and toggle zoom-fullscreen work without yabai crashing. Whereas executing the focus (and interestingly, toggle native-fullscreen) command and hovering to an unfocused window with the config focus_follows_mouse enabled make it crash.

koekeishiya commented 1 year ago

When yabai focuses a window it is a mix of private APIs, reverse engineered events that are sent directly to an application, and the AX API. This combination is necessary as a workaround to a problem where the wrong window will receive focus in a multi-monitor setup. See https://github.com/koekeishiya/yabai/issues/102 for history. Window focusing has worked this way ever since yabai v1.0.6.

I don't know if this is broken in Sonoma, or if the crash that is observed now are happening because of issues that Apple will resolve in later versions of Sonoma, as they are still on the first developer beta.

I am personally not going to care much about issues that arise, until they ship the ~3rd public beta release.

pupbrained commented 1 year ago

Little update to this, 2nd beta seems to still be broken w/ yabai. It also seems they recently deprecated a lot of things, so it might have something to do with that?

UPDATE: I thought yabai had been working, but the bug still seems to be present.

pupbrained commented 1 year ago

Again, 3rd beta has the same issues. Seems that Apple most likely changed something with the APIs that yabai uses, considering I've also seen lots of API deprecation warnings in numerous apps.

i-jared commented 1 year ago

After upgrading I am unable to switch spaces focus. Anybody else experiencing this issue?

roelvangils commented 1 year ago

I'm fully aware that I don't deserve support as a Sonoma Public Beta user (sorry, I couldn't resist installing it), but maybe someone can help me out anyway! 😁

What I did: I uninstalled yabai with brew uninstall yabai after installing Sonoma Public Beta 1 because I thought it was a good idea to start over. Then I attempted to reinstall it, but that didn't work. First, Homebrew complains (for a good reason), but that's not the issue. It's this error message I'm stuck on:

Error: Your Xcode (14.3.1) is too outdated.
Please update to Xcode 15.0 (or delete it).

I did install Xcode 15 Beta (4), but I still get the message saying Xcode is outdated. Also, I'm unsure what does Yabai mean by "or delete it"? ðŸĪ” Should I delete the Xcode 15 beta again? Not sure if that's going to help.

Full output:

==> Downloading https://formulae.brew.sh/api/formula.jws.json
############################################################################################################################################################################ 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################################################################################################ 100.0%
Warning: You are using macOS 14.
We do not provide support for this pre-release version.
It is expected behaviour that some formulae will fail to build in this pre-release version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

==> Fetching koekeishiya/formulae/yabai
==> Downloading https://github.com/koekeishiya/yabai/releases/download/v5.0.6/yabai-v5.0.6.tar.gz
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/184909163/df79b725-6f01-431f-95de-a5911d7d66bc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X
############################################################################################################################################################################ 100.0%
==> Installing yabai from koekeishiya/formulae
Error: Your Xcode (14.3.1) is too outdated.
Please update to Xcode 15.0 (or delete it).
Xcode can be updated from:
  https://developer.apple.com/download/all/
roelvangils commented 1 year ago

Update (to whom it concerns): after installing Xcode 15 Beta, you need to run this command:

sudo xcode-select --switch /Applications/Xcode-beta.app

This lets you install Yabai 5.0.6 again.

JacquesCherbuin commented 1 year ago

I switched to Sonoma, reinstalled yabai and switched to Xcode-beta. Window swap, warp, mirror, padding, rotate, toggle float, grid mode, toggle split and opacity all work as expected. However, focusing windows and spaces doesn't work. Focusing windows occasionally causes all windows to switch around randomly after about 3 seconds, and occasionally it will work a single time but not work after that. So for now I've gone back to Ventura... I hope you will be able to eventually figure out a fix, I couldn't use macOS without yabai - it's so good

dchou-zxy commented 1 year ago

I am also unable to switch spaces since switching to Sonoma beta: yabai -m space --focus next cannot focus space due to an error with the scripting-addition.

roelvangils commented 1 year ago

@JacquesCherbuin my experience is identical to yours.

I didn't switch back to Ventura (I think the only way is to restore from a Time Machine backup, and that would take forever and is not without risks). Besides, I like everything else in Sonoma too much. Yabai is the only third-party app that is causing me trouble 😁 But that was totally to be expected, of course. Nonetheless, I'm holding my breath for a Yabai update and I hope @koekeishiya won't let us wait until the final release! 🙊

f64u commented 1 year ago

I'm also experiencing the focusing issue. I hope this gets addressed :(

ditadi commented 1 year ago

Same issue here, every three seconds yabai "reset" and refocus.

With this, it is impossible to use Yabai, so I stopped the service and hope we have a fix soon to be used again.

koekeishiya commented 1 year ago

You can apply this patch to the master branch (https://github.com/koekeishiya/yabai/commit/ea4eb843cead29cd97d27e8cc5d38faaa7b019bd) to make window focus work without segfaulting. Note that this patch will likely reintroduce the issue mentioned in #102 (and focus without raise aka autofocus will not work).

diff --git a/src/window_manager.c b/src/window_manager.c
index c14309c..6a8d4c8 100644
--- a/src/window_manager.c
+++ b/src/window_manager.c
@@ -1221,6 +1221,11 @@ static void window_manager_make_key_window(ProcessSerialNumber *window_psn, uint

 void window_manager_focus_window_without_raise(ProcessSerialNumber *window_psn, uint32_t window_id)
 {
+    if (workspace_is_macos_sonoma()) {
+        debug("%s is not available on macOS Sonoma..\n", __FUNCTION__);
+        return;
+    }
+
     if (psn_equals(window_psn, &g_window_manager.focused_window_psn)) {
         uint8_t bytes1[0xf8] = { [0x04] = 0xf8, [0x08] = 0x0d, [0x8a] = 0x02 };
         memcpy(bytes1 + 0x3c, &g_window_manager.focused_window_id, sizeof(uint32_t));
@@ -1246,13 +1251,18 @@ void window_manager_focus_window_without_raise(ProcessSerialNumber *window_psn,

 void window_manager_focus_window_with_raise(ProcessSerialNumber *window_psn, uint32_t window_id, AXUIElementRef window_ref)
 {
+    if (workspace_is_macos_sonoma()) {
+        _SLPSSetFrontProcessWithOptions(window_psn, 0, kCPSNoWindows);
+        AXUIElementPerformAction(window_ref, kAXRaiseAction);
+    } else {
 #if 1
-    _SLPSSetFrontProcessWithOptions(window_psn, window_id, kCPSUserGenerated);
-    window_manager_make_key_window(window_psn, window_id);
-    AXUIElementPerformAction(window_ref, kAXRaiseAction);
+        _SLPSSetFrontProcessWithOptions(window_psn, window_id, kCPSUserGenerated);
+        window_manager_make_key_window(window_psn, window_id);
+        AXUIElementPerformAction(window_ref, kAXRaiseAction);
 #else
-    scripting_addition_focus_window(window_id);
+        scripting_addition_focus_window(window_id);
 #endif
+    }
 }

 #pragma clang diagnostic push

As I have mentioned before; if this software is critical to your workflow you should refrain from upgrading to a beta OS.

0xCUB3 commented 1 year ago

Perfect! For those of you who don't know how to apply this patch, you need to switch to the dev version of yabai, which runs off of the latest commit.

Link to Guide

As @koekeishiya mentioned, however, run this at your own risk and don't run beta versions of macOS unless you understand all of the risks involved

roelvangils commented 1 year ago

Thanks! @0xCUB3 will this patch also restore the yabai -m space --focus y command?

f64u commented 1 year ago

I tried installing the patch and it still segfaults whenever I change focus (also it keeps requesting accessibility permissions even after I grant it).

dustinlieu commented 1 year ago

I tried installing the patch and it still segfaults whenever I change focus (also it keeps requesting accessibility permissions even after I grant it).

It works for me. I cloned the repo, applied the patch, and then compiled.

The current HEAD (https://github.com/koekeishiya/yabai/commit/ea4eb843cead29cd97d27e8cc5d38faaa7b019bd), as of now, does not have the patch, so simply installing the dev version through Homebrew will not work.

phyllisstein commented 1 year ago

Thank you for the patch. Echoing previous comments, yabai has become invaluable. Installing the betas every year was a bad habit you finally broke.

roelvangils commented 1 year ago

Can someone confirm if switching instantly between spaces (zero animations) is also restored with this patch? It's one of my favorite features in Yabai.

dattito commented 1 year ago

After the patch, switching focus is working again, but spaces are not working. When executing sudo yabai --load-sa, I get payload (0x0) doesn't support this macOS version!. Or did I miss-configured something?

0xCUB3 commented 1 year ago

Yeah I'm getting that too, but after awhile, it seems to randomly start working.

roelvangils commented 1 year ago

I'm starting to miss my beloved Yabai on Sonoma ðŸĨš Why was I so impatient! 😁

dattito commented 1 year ago

I really would love to use spaces in Sonoma, so @0xCUB3 if you figured out how you got it working, it would be awesome if you could share it!

0xCUB3 commented 1 year ago

I don't use spaces personally, so I don't really know how the functionality should work.

koekeishiya commented 1 year ago

Spaces features will not work on Sonoma until RC/public launch.

Minorsonek commented 1 year ago

If you guys know any way to get around this problem please share, us Sonoma users need to unite!

jesobremonte commented 1 year ago

I tried installing the patch and it still segfaults whenever I change focus (also it keeps requesting accessibility permissions even after I grant it).

It works for me. I cloned the repo, applied the patch, and then compiled.

The current HEAD (ea4eb84), as of now, does not have the patch, so simply installing the dev version through Homebrew will not work.

I've gotten as far as applying to patch to a locally cloned repo. Is there a guide on how to compile and install yabai from local source without Homebrew I've missed? I haven't found any on the yabai wiki. The Link to Guide only goes over installing HEAD with brew.

typkrft commented 1 year ago

Is there a guide on how to compile and install yabai from local source without Homebrew I've missed? I haven't found any on the yabai wiki. The Link to Guide only goes over installing HEAD with brew.

@jesobremonte Here's the formulae that homebrew uses and the make file. It looks like you would just need to run make -j1 install at a glance.

Patrick0308 commented 1 year ago

Sonoma user +1

roelvangils commented 1 year ago

Spaces features will not work on Sonoma until RC/public launch.

Good to know. Thanks for that! I'm glad the functionality will work again in the future. I was worried that there was something in Sonoma that would prevent it from ever working again! 😌

voidpointer0 commented 1 year ago

I have the same problem. I also couldn't resist upgrading to Sonoma. Can't wait for this fix to be merged! Any estimations?

0xCUB3 commented 1 year ago

I have the same problem. I also couldn't resist upgrading to Sonoma. Can't wait for this fix to be merged! Any estimations?

As with everything, the estimate is between now and never.

OfficialCRUGG commented 1 year ago

Just to confirm, the only way to have focus switching work on Sonoma is to manually compile yabai from source?

voidpointer0 commented 1 year ago

So I followed the "Installing yabai (from HEAD)" instructions on MacOS Sonoma Beta (14.0) and I'm happy to report yabai hasn't crashed so far!

Using it with skhd, configured by following the info on disabling SIP from the wiki and the yt tutorial by Josean Martinez. Yay.

lrangell commented 1 year ago

the RC has been launched, any updates?

tqoo commented 1 year ago

I can't seem to run yabai? Could not enable service: 125: Domain does not support specified action Bootstrap failed: 125: Domain does not support specified action

Edit: Ignore this, I just had to delete the plist file in ~/Library/LaunchAgents

0xCUB3 commented 1 year ago

has the latest stable release been working for people? I find that it still suffers the same issue.