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.