Wednesday, October 4, 2023

Control Center in macOS Always Using CPU

Frank A. Krueger (Hacker News):

The Control Center icon in the Mac [menu bar] is always running and always using 1% CPU. Not a big deal, but I finally had to know wtf it was doing…

Turns out it is constantly re-rendering its SwiftUI (running layout) even though there is no UI visible. 🤣 Yay for modern software

Frank A. Krueger:

In a nutshell, no, this is not increasing my power usage by 1%.

[…]

One app doing that isn’t a biggie, sure, but it should be fixed anyway. If every background app started doing this, we’d end up with lots of wasted CPU cycles. Plus: on weaker machines that process may take up more than 1% and could actually prevent the CPU from fully throttling.

Harmonicritik:

Functional-reactivity is power-efficient because the view chooses when to ask its components for updated data. SwiftUI was invented for the Apple Watch following this principle.

However, it doesn’t work that way in practice, seemingly because AppKit is repeatedly asking SwiftUI for information that it hasn’t cached.

Marcin Krzyzanowski:

🤔 SwiftUI on macOS underperforming is an understatement. “tell me you rewrite user-facing parts of the operating system interface with new technology without checking if that’s the right tool for the job”

dosdude1:

Yep, I notice this in EVERY app based on SwiftUI, especially under Mac OS.

Control Center in macOS is just poorly implemented in general. Lots of little glitches, awkward modes and navigation, and it doesn’t support keyboard navigation.

Previously:

Update (2023-10-09): SheriefFYI:

This could have significant, subtle power implications - the CPU usage spike might be preventing idle sleep or increasing the system timer tick frequency. Something similar ended up costing me an hour of PC battery life simply by preventing down-clocking.

8 Comments RSS · Twitter · Mastodon

Agreed 100% on your concise assessment Michael. The navigation inconsistencies really bug me in particular.

It's also very sluggish on older hardware. Until I had an M-series Mac, there was a noticeable delay when interacting with some of its menus (the wifi menu was much more sluggish than its previous equivalent) and I could see the low frame rate animations. As usual with modern Mac features, it was changed but never polished.

Sébastien LeBlanc

Changing section in the Settings app has a noticable 300-500ms delay... Even on a M1 Pro MacBook Pro ! I can't even imagine how slow it must be on Intel.

The ecosystems written in SwiftUI that ship with macOS have been a serious disaster, making me think that Web-based apps are not so bad in comparison.

I am sweating bullets. Currently rewriting the UI for my app to use SwiftUI, because I trust Apple to fix SwiftUI’s scary future gotchas.
It is not easy, and I am powering through, putting my trust in Apple. Despite all the setbacks, I am finding workarounds, thinking I will not need these ugly tricks further down the road. Still, there is this little voice in my head telling me Apple may screw me over when they, perhaps change their minds about Swift, being the best way to develop apps for their platforms.

i think you have a good reason to be sweating. Since iOS 17 been seeing a bunch of posts about SwiftUI memory leaks with no workaround available for devs (it seems, I don’t use these APIs).

When Apple takes control away from the developer and you have to rely on their “magic” framework you’re basically screwed when bad things happen.

Good news for Swift devs you’re not alone. There’s some broken code in frameworks written in C++ and I can’t swizzle my way out of the problem.

Have to wonder if someone in management is gonna come along one day and say “alright that’s enough…” if things don’t get cleaned up.

While I (web developer, occasionally dabbling in macOS development) agree with many of the criticisms directed at SwiftUI, my experience as a user is entirey different here:
Control Center performs without any noticeable delay and rarely uses more than 0.02% of the CPU — often 0.0%. All this on an officially ancient 2017 5k iMac.

I don’t understand why Control Center on the Mac can’t be customized. I just want to add dark mode toggle and battery saver to it, just like on my iPhone and iPad.

Wes Campaigne

The Control Center process is responsible for a bunch of the macOS menu bar items, as well.

Root cause appears to be updating the time in the menu bar:

- I was seeing ~3% CPU use from Control Center
- In my menu bar "Clock" options, I didn't have seconds visible, but I _did_ have the "flash the time separators" toggle enabled
- After turning that off*, the CPU use dropped to ~0.1%

I'm guessing that if seconds are visible, or just flashing the separator is enabled, Control Center is forced to trigger a surprisingly expensive set of view updates every second.

* Turning off the setting was surprisingly tricky: turning it off on its own didn't affect the menu bar; I had to temporarily change another setting in the Clock options for it to recognize that the "flash separators" setting had been changed. Ugh.

Leave a Comment