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

(macOS) Performance: constant high CPU usage #829

Closed
foss- opened this issue Nov 13, 2021 · 15 comments
Closed

(macOS) Performance: constant high CPU usage #829

foss- opened this issue Nov 13, 2021 · 15 comments

Comments

@foss-
Copy link

foss- commented Nov 13, 2021

System Information:

  • Operating system: macOS 11.6.1
  • Strawberry Version: Open Strawberry Version 1.0.0-116-g0fbe5d88

Constant high CPU usage on macOS.

To Reproduce
With Strawberry open and doing nothing (no scrolling or playing a track or any interaction at all) Strawberry constantly sits at over 40% CPU usage
Screenshot 2021-11-13 at 17 46 43

Playing a track it sits at over 60% while sometimes spiking at over 100%:
Screenshot 2021-11-13 at 17 50 27

Expected behavior
CPU usage is too high. Comparing with Apples music app which sits at 0,1% when idle and goes up to under 2% when playing a track.

Additional context
Spin Dump: https://bin.disroot.org/?73b77829f80a251e#5vwiHDcJRRTccyUMsLmNgUidDriH9xRhv6HMAEW8hoUn
Process Sample: https://bin.disroot.org/?103ce9f6c263e0fb#HzSkmVV7rWMBXs5GyL1nzbP6h6cA92XRhmUJc6ATSDKw

@foss- foss- changed the title macOS Performance: permanent high CPU usage macOS Performance: constant high CPU usage Nov 13, 2021
@jonaski
Copy link
Member

jonaski commented Dec 1, 2021

Uses 15-20% CPU here in my macOS VM.
Did you change any specific configuration options?
Did you try with a fresh configuration? delete ~/Library/Preferences/org.strawberrymusicplayer.Strawberry.plist

@foss-
Copy link
Author

foss- commented Dec 1, 2021

Interesting finding and thanks for going through the effort to verify this problem. Are you also running macOS 11?
I enabled storing metadata back to files and disabled the default library background picture. Other than that can't recall changes.

I removed ~/Library/Preferences/org.strawberrymusicplayer.Strawberry.plist as suggested, installed latest main build.

CPU consumption while playing a track is now back to normal levels. Will keep an eye on this and re-open if issue returns, hopefully with more details as to which change triggers the CPU increase.

@foss- foss- closed this as completed Dec 1, 2021
@foss-
Copy link
Author

foss- commented Dec 1, 2021

Well that was a quick one. Connecting an external monitor makes CPU go up to ~50-80% playing a track and ~40-50 when ideling.
For comparison: when playing a track in Apples Music app CPU is around or mostly below 2%.

@foss- foss- reopened this Dec 1, 2021
@jonaski
Copy link
Member

jonaski commented Dec 1, 2021

It might be related to #542

@foss-
Copy link
Author

foss- commented Dec 1, 2021

Which gladly is seeing active development and just yesterday received patch set 8. Not sure if it is indeed the cause for the constant high CPU though, as no scrolling is involved in my tests.

@e471wo
Copy link

e471wo commented Dec 6, 2021

duno if that help, but on my mac, if I put no analyser -> cpu down. (note -> Version 1.0.0-125-g4c6251bf)

image

@richarddbarnett
Copy link

I found this because Strawberry 1.0.1 on macOS 11.6.2 was consuming a lot of CPU (about 40%) when paused.
Turning off the analyzer seems to fix it.

MacBook Pro 15", 2.9GHz quad-core i7.
External monitor is connected via USB-C.

@foss-
Copy link
Author

foss- commented Jan 17, 2022

Also confirming: Strawberry 1.0.1-22-g56b2630a on macOS 11.6.2 sitting idle ~40% CPU
Switching from Block analyzer to No analyzer and it goes to 0,0 sitting idle.

@jonaski
Copy link
Member

jonaski commented Jan 17, 2022

What about the other analyzers, do they cause as much CPU too?

@foss-
Copy link
Author

foss- commented Jan 17, 2022

Strawberry idle / playing ~40% / ~60% for all analyzers.

@jonaski
Copy link
Member

jonaski commented Apr 1, 2022

The problematic code is in https://raw.githubusercontent.com/strawberrymusicplayer/strawberry/master/src/analyzer/analyzerbase.cpp
There is a timer that repaints every few milliseconds depending the framerate set.
Although this not a problem on any other platforms and is likely a Qt-macOS specific issue.

@jonaski jonaski changed the title macOS Performance: constant high CPU usage (macOS) Performance: constant high CPU usage Apr 1, 2022
@jonaski
Copy link
Member

jonaski commented Apr 15, 2022

Can you try the latest from https://builds.strawberrymusicplayer.org/macos/ those have Qt 6.3.0 (instead of Qt 6.2.x).

@foss-
Copy link
Author

foss- commented Apr 15, 2022

macOS 12.3.1
Strawberry 1.0.4-5-g907dfee6
Playing a track with analyzer selected CPU is under 20% which is somewhat acceptable. (Apple music app is ~3% but it is optimised for macOS)
Ideling it is ~12% which is high for doing ... nothing.

But since both values have improved a lot. I think it is fair to close this issue. What do you think? Can others test as well?

@Calinou
Copy link

Calinou commented May 15, 2022

It might be worth disabling the analyzer by default on macOS to fix the issue out of the box. I'm not sure how many people actually look at the analyzer anyway. Typically, you minimize the music player a few seconds after choosing a track to play 🙂

@jonaski
Copy link
Member

jonaski commented Nov 23, 2022

In my macOS Big Sur VM which is slow in general strawberry is using approximately 4% - 10% when idle and 15-30% when playing, both with the analyzer is on. If I turn the analyzer off when idle, the CPU goes almost to 0, when playing it's under 20%.
When removing the timer that does frequent repaints when the analyzer is on, the CPU usage goes down, I also made a small test program, same thing happens with the test program, so it's not specific to the analyzer itself, but frequent repaints.
I'm considering filing a bug report to Qt, but at least for me, I also see the Activity monitor having somewhat high CPU usage, so my VM is not really ideal for benchmarking since it's so much slower than a real mac would be.
I don't think I can do much with this, so closing it for now. Turning off the analyzer as a solution for those having the issue is written in the Wiki: https://wiki.strawberrymusicplayer.org/wiki/Known_Issues

@jonaski jonaski closed this as completed Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants