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

SketchyBar sometimes vanishes unexpectedly. #512

Open
CrazyCatZhang opened this issue Mar 2, 2024 · 4 comments
Open

SketchyBar sometimes vanishes unexpectedly. #512

CrazyCatZhang opened this issue Mar 2, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@CrazyCatZhang
Copy link

sometimes after my mac goes into screensaver mode and I enter my password to return to the main screen, sketchybar disappears suddenly. however, when I repeat the steps, sketchybar reappears.
like this:
image
btw, i am using multiple-bars.

@FelixKratz FelixKratz added bug Something isn't working not reproducible and removed not reproducible labels Mar 4, 2024
@FelixKratz
Copy link
Owner

This has been a problem for quite some time now and I was able resolve all those prior problems but something with the wake event seems to be going wrong still #430, #422, #97, #497. The fact that the bar reappears after a further lock->unlock makes a freeze implausible. I think it must have to do with the wake event not being received properly such that the bar internally thinks the computer is still sleeping.

@CrossR
Copy link

CrossR commented Mar 22, 2024

I'm able to reproduce this bug fairly easily (I think).

If I just close the lid on my MacBook Air, then re-open it basically straight away, and then wake the device with the keyboard, say by pressing spacebar, I can repro some form of weird behaviour, that I think is this bug. (Sometimes for whatever reason, the device won't actually sleep, so you may need to keep the lid closed for a second or two).

Doing that gives me the following behaviour:

  • Sketchybar is fine. I do the steps outlined above : Bar vanishes.
  • Sketchybar is running, but vanished. I do the steps outlined above : Bar comes back!

This is on a device with only a single screen etc, so I don't think its something to do with that, at least in my case.

Now, I've done a bit of poking and I could be entirely wrong (I've only really given a quick glance over the code...) but something that looks fairly suspect to me is the didWake function in workspace.m: Is there a reason it is hooked up to both NSWorkspaceDidWakeNotification and com.apple.screenIsUnlocked?

I ask, because if I print out all the events that are being processed as I do the steps outlined above, every time I see the bar behave funny and go away / or come back once hidden, its because there has been two SYSTEM_WOKE events: One for the NSWorkspaceDidWakeNotification and one for com.apple.screenIsUnlocked, and these events come one after another.

If instead I just lock my screen, or close the laptop lid for a few minutes, any of the interactions that don't cause the bar to vanish, there is only a single SYSTEM_WOKE event.

Is it possible that there is some weird interaction happening if two SYSTEM_WOKE interactions run at the same time / in quick succession?

If I just comment out the com.apple.screenIsUnlocked version, it "fixes" it for me, though I'm sure causes other issues with other events, so something a bit more sophisticated to not run both events could be needed, assuming this is a fix at all.

@FelixKratz
Copy link
Owner

FelixKratz commented Mar 22, 2024

Thank you for the investigation. It is indeed true that the system wake event is posted into the event loop in both cases. This is on purpose because having multiple wake events should make the bug appear less frequently, as a similar bug was reported even before this code change was made. Having two system wake events creates no interplay as in both cases the bars are created entirely from scratch (thats at least how it should be).

I originally thought this bug was because we call the system woke code in:

void bar_manager_handle_system_woke(struct bar_manager* bar_manager) {

too early such that the api we use to enumerate the active displays wrongfully reports no active display, which would lead to all bars being destroyed but not recreated. On my system this bug happens very infrequently (once a month) and I was not able to find any way to reliably reproduce it in all the prior issues listed above.

I never sleep my laptop with the menubar action, only by closing the lid or letting the system time out, maybe I could try that.

It would be interesting which of the two events is responsible for the single wake call, ie screen unlock or wake?

You mention that you wake the device with the space key after opening the lid, does opening the lid not wake the system automatically?

@adrianvalenz
Copy link

adrianvalenz commented May 21, 2024

After I close my laptop completely and open it the first time, sketchybar disappears. Second time I close my laptop completely and open it for the second time and it reappears. Upon every close and opening of laptop it alternates states (visible sketchybar, not visible, visible, not visible, and so on...)

Then I proceeded to almost close my laptop (not completely as I can still see the screen and keyboard) but enough so the screen goes black...then I move it back up to wake the screen but sketchybar is not visible...I do this 3 more times in a row (almost closing it but not) to sleep the screen so when I move it back up to wake it sketchybar is not visible (those 3 times).

Finally I close the laptop completely and open it and because the sketchybar was not visible upon completely closing it, it reappears when I open the laptop.

Second test I did was repeatedly Sleep and Lock Screen from the Apple menu bar and sketchybar never seemed to disappears. So it appears some different method is being called when you actually fully close the laptop.

I hope this helps.

Edit: Would be interested to see how sketchybar reacts by testing the Sleep/Lock Screen buttons from the menu bar when the laptop is closed in clamshell while being connected to an external monitor.

Edit 2: When Sleeping the screen via Apple menu, if I wake with the touchpad, sketchybar persists...when I wake it with a key like the spacebar, it disappears, and then I can wake it again with the touchpad sketchybar reappears. This is all done back to back without every closing the laptop. It seems how the screen wakes up is a factor.

Also tried the touch id and entering password to get back onto the desktop from the lockscreen and sketchybar persists. So it seems to happen in or around the screen Sleeping only and how it wakes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants