Third-party screensavers not quitting on Sonoma - any workarounds?

I've run into a really weird bug with a macOS screen saver I've been developing using the ScreenSaver framework. It works fine on Ventura, but on Sonoma, when the user dismisses the screensaver, it continues to animate invisibly in the background using up CPU and GPU cycles. Even worse, when the user activates the screensaver a second time, yet another copy appears to be created, and so on. The call to stop animating is also never sent to the view, as far as I can tell.

I logged this as FB13041503 already, but I'm trying to come up with a workaround now, since this is still happening in the release version of macOS 14.0.

Any ideas how I can detect that the screensaver has been dismissed, so I can minimise my resource usage? I've even tried watching for things like NSWindowDidChangeOcclusionStateNotification but nothing seems to get called that I can use.

Replies

It’s taken me a while, but I finally have the info I need to act here (-:

I logged this as FB13041503 already

Thanks for that.

Have you tried this on the latest macOS 14.1b2 seed (23B5056e)? I don’t have any solid evidence that it’s fixed there, but I just want to establish a new baseline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes, it's still happening on 14.1b1 and b2. Every time the screensaver is activated, I can see an additional thread being created in the legacyScreenSaver (Wallpaper) process. The closest I have to a workaround is to poll the view's window's windowLevel, which appears to change depending on whether the screensaver is currently active.

One thought I had was that there was some kind of retain cycle happening, and that's why my view isn't getting deallocated in this new screensaver process, but it doesn't seem to be the case at least when it's running within a regular app context.

Also, I do get the "startAnimating" calls, but never see any "stopAnimating" calls.

This is REALLY annoying. Before Sonoma my MacBook usually kept cold to the touch. But nowdays often when I wonder why my keyboard is getting hot, it turns out there is at least one legacyScreenSaver process in the background, happily consuming about 20 % of the processing ressources – without any observable benefit. I am using the latest public version of Sonoma (14.1.2) and have to additional external displays, which amounts to 3 in total.

PLEASE FIX

I see behavior as well. And FYI location services appears to be broken: no delegate methods are ever called, which grounds my saver completely.

There are many bugs with third-party screensavers under Sonoma.

Here's a long thread that discusses a number of fixes: https://github.com/JohnCoates/Aerial/issues/1305

In particular, if your screensaver detects when it needs to exit, it can call exit(0) which seems to do the trick. Direct link: https://github.com/JohnCoates/Aerial/issues/1305#issuecomment-1680853387

Post not yet marked as solved Up vote reply of XMI Down vote reply of XMI