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

High CPU Usage even if unused #10

Closed
vctender opened this issue Jul 15, 2017 · 8 comments
Closed

High CPU Usage even if unused #10

vctender opened this issue Jul 15, 2017 · 8 comments

Comments

@vctender
Copy link

Hi all,

I recognized an issue in a RPI3 using bt speaker to use the Pi as an audio transceiver. First of all, bt-speaker is working fine without problems. I do not use the builtin WLAN module to avoid the sound problems.

After some time, even if not used, the python-process of bt-speaker constantly causes high cpu usage (100% on one core). How can I help to investigate?

Regards,

@lukasjapan
Copy link
Owner

Hmmm,
maybe a first step would try to find out if the load comes from inside the C library or python.
Probably it comes from python if the load is also high when not playing audio.

Approaches I could think of are:

  • Add debug logging in code
  • Monitor the DBUS for abnormalities

Maybe its even GLib responding unnecessarily to something.

Personally I never experienced (or noticed) that issue since I use the Pi exclusively for bluetooth in my project.

@gonzotek
Copy link

gonzotek commented Jul 15, 2017

I am experiencing this as well. It seems to happen shortly after the first bluetooth disconnect after a boot; at least for me. I'm running bt-speaker on a RPi 3 using an up-to-date retropie image (installed retropie 4.2, then updated setup script and retropie packages using retropie's updater). Also using ethernet, wifi is disabled via /boot/config.txt; I am using the onboard bluetooth however.

@vctender
Copy link
Author

Restarting bt_speaker resolves the issue immediately. I can confirm that it happens after disconnecting. Nevertheless the service seems to work fine, even with high cpu usage.

@lukasjapan
Copy link
Owner

lukasjapan commented Jul 15, 2017

I can confirm it now.

Will definitely look into this and try to fix it tonight or tomorrow.

It looks like the raw_audio function is called in an infinite loop, probably with empty data.
A simple sleep should fix this if there is no better solution.

@vctender
Copy link
Author

n1, will validate your changes soon. Thanks

@lukasjapan lukasjapan mentioned this issue Jul 16, 2017
lukasjapan added a commit that referenced this issue Jul 16, 2017
@lukasjapan
Copy link
Owner

Turns out that bluez does not tell to release the filedescriptor of the audio stream on disconnect and the GObject listener went crazy.

It should be fixed now.

@gonzotek
Copy link

Confirmed fixed for me (retropie 4.2 base image, packages all up-to-date as of 2017-07-16). Thanks!! Working great :-)

@vctender
Copy link
Author

confirmed - Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants