You are not logged in.

#1 2024-06-07 09:11:41

bjo
Member
Registered: 2011-09-10
Posts: 93

[SOLVED] mopidy stuttering via bluetooth

Hi,

I'm running mopidy on a NUC with a Intel(R) Celeron(R) J4005 and 6.6.32-1-lts. The NUC is connected to some simple bluetooth output via pipewire/wireplumber and it's onboard bluetooth chip.

Since some time, the sound output (e.g. from a soma.fm stream) stutters even when running only yay, while the whole system has a low load (0.45). It get's even worse when restic or borgmatic are doing backups.

The box don't get reboots often, so maybe something changed within the lts kernel. Did anybody else experience such issues?

Last edited by bjo (2024-06-07 21:52:10)

Offline

#2 2024-06-07 13:26:06

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

1. Check out this.
2. What is the priority of pipewire / wireplumber ?

ps -eo pid,comm,nice | grep -E 'wireplumber|pipewire'

3. Try different kernels to see if there is any difference.


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#3 2024-06-07 13:33:49

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

Thanks for your reply.

1) No access denied, but it doesn't look ok either I think.

pipewire[1390]: mod.rt: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown
pipewire[1390]: mod.rt: RTKit does not give us MaxRealtimePriority, using 1
pipewire[1390]: mod.rt: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown
pipewire[1390]: mod.rt: RTKit does not give us MinNiceLevel, using 0
pipewire[1390]: mod.rt: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown
pipewire[1390]: mod.rt: RTKit does not give us RTTimeUSecMax, using -1

2)

   1390 pipewire          0
   1392 pipewire-pulse    0
   1423 wireplumber       0

3) I will try.

Offline

#4 2024-06-07 13:39:17

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

RTKit is not able to set priority (from default 0 to -11).
* See that package rtkit is installed and that the daemon is running (rtkit-daemon)


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#5 2024-06-07 13:41:16

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

It's installed now and started, but doesn't supervise anything:

 rtkit-daemon[399150]: Supervising 0 threads of 0 processes of 0 users.

But the error message from pipewire disappeared.

Offline

#6 2024-06-07 13:55:16

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

Restart pipewire and wireplumber and check their priorities again.
If it's -11 (what pipewire by default requests), then it works, and you can play, put load on the system and see if it solves the problem.


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#7 2024-06-07 14:00:18

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

Restarted wireplumper, pipewire and pipewire-pulse still at 0:

 
400123 pipewire          0
400154 wireplumber       0
400225 pipewire-pulse    0

Just checked on another box which runs Budgie and has rtkit installed to compare it to the headless box:

1515 pipewire          0
1517 wireplumber       0
1519 pipewire-pulse    0

Last edited by bjo (2024-06-07 14:03:02)

Offline

#8 2024-06-07 14:17:24

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

* Are you running pipewire as user or as system? Checkout this in regards.
* Did you check the possible solutions in this link from the Wiki page?

Last edited by impossibleveins23 (2024-06-07 14:17:57)


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#9 2024-06-07 17:56:58

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

* pipewire / wireplumber run as user
* Adjusting the rlimits acording to https://gitlab.freedesktop.org/pipewire … ng#rlimits and adding myself to the audio-group lead at least to

1193 pipewire        -11
1194 wireplumber     -11
1196 pipewire-pulse  -11

But the stutter still occurs while doing SSD IO, but confusingly enough not while downloading an iso to /dev/null.
And it also exists with kernel 6.1.71.

Edit:
Stumpled upon https://gitlab.freedesktop.org/pipewire … ssues/2784 and tried preempt=full and threadsirq, but no luck.
"Fixed" it now by using a cable and a 3,5mm jack.

Last edited by bjo (2024-06-07 21:51:02)

Offline

#10 2024-06-08 09:04:15

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

OK but if you want to further troubleshoot:
1. You mentioned that it started to happen recently. Try going back a kernel for a few weeks.
2. Try Pulseaudio. It can help to show whether the problem is on Pipewire side.
3. What's the CPU status when audio active? Do you upsample?
4. Perhaps it's a generic CPU load. What's the idle status? Is anything else significantly spikes the CPU?


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#11 2024-06-08 09:45:56

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

1. As I tried 6.1.71 which is from 5 month ago and it also appears I don't think it's kernel related.
2. That's on my list to test when I'm in the mood for further testing.
3. no upsampling, just Bluetooth with SBC.
4. The load is around 0.2, and iotop does not even show read/write access when the stutter appears

Maybe I should downgrade pipewire/wireplumber and test it again. Weeks before it was even possible to build an OpenWRT image without stutter and the load was much higher - which would be a situation I would understand the issue much more.   

I checked

for pid in `pgrep -w 'pipewire|wireplumber'`; do chrt -p $pid; done
pid 981's current scheduling policy: SCHED_OTHER
pid 981's current scheduling priority: 0
pid 982's current scheduling policy: SCHED_OTHER
pid 982's current scheduling priority: 0
pid 1000's current scheduling policy: SCHED_OTHER
pid 1000's current scheduling priority: 0
pid 983's current scheduling policy: SCHED_OTHER
pid 983's current scheduling priority: 0

as mentioned in https://gitlab.freedesktop.org/pipewire … ssues/2784 - maybe as I didn't get rtkits config from https://gitlab.freedesktop.org/pipewire … ning#rtkit working.

But I also think it's somehow confusing that that the issue appears at all and possibly needs to be fixed by some "performance tuning" as playing a simple soma.fm stream is not "pro audio setup" which some people might need.

Offline

#12 2024-06-09 08:34:43

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

I agree that it's frustrating is something that used to work is broken now.

* Anything changed that can contribute to the system load (service, less disk space...)?
* Did you try different codecs?
* New wireless interference?
* Is the tests you perform are always by streaming audio? IMO better to reduce the network component by playing a local file.
* Try to debug Pipeware/ Wireplumber and attach the output here.

PIPEWIRE_DEBUG=4 pipewire >pw_debug.out 2>&1
WIREPLUMBER_DEBUG=4 wireplumber >wp_debug.out 2>&1

* Any power optimization applied to BT/USB/audio?
* If enabled, try to disable BLE.


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#13 2024-06-11 12:50:38

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

The issue fixed itself out of the blue as I wanted to debug it. Even building an OpenWRT image which generates a load of 3 does not affect the bluetooth stream any more.

But btw, you threw some things in here which were also unrelated:
* How shoud less disk space or wireless interference affect the issue which was only appearing when doing an IO access?
* The issue did not appear while downloading a big file - I would assume that network buffering issues would appear then.

Offline

#14 2024-06-11 13:32:11

impossibleveins23
Member
From: Israel
Registered: 2022-06-18
Posts: 148

Re: [SOLVED] mopidy stuttering via bluetooth

1. Disk space or fragmented will directly affect the IO and CPU. Some FS more than others.
2. Wireless interference can affect the Bluetooth connection.
3. Roughly speaking, downloading a file is more affected by bandwidth than latency and is probably less sensitive.
4. Agreed that if compiling caused this problem than it probably a CPU / resources / scheduling and not external interference.

Either way happy that it was solved for you.


* Good formatted problem description will cause good and quick solution smile
* Please don't forget to mark as [SOLVED].

Offline

#15 2024-06-11 13:45:02

bjo
Member
Registered: 2011-09-10
Posts: 93

Re: [SOLVED] mopidy stuttering via bluetooth

Sure, disk space can affect IO and wireless interferences can accect bluetooth connections - but as it did not appear in general, but only in situations like the "Upgrading package database" step of pacman which is no big deal regarding CPU / IO - and this was reproducable - it was clearly something IO-related. And then I started

WIREPLUMBER_DEBUG=5:spa.bluez5.sink.media wireplumber 2>&1 | grep --line-buffered -E '^I|send blocks' > wp.log 2>&1

to get some debug output and it was gone yikes

Last edited by bjo (2024-06-11 13:45:23)

Offline

Board footer

Powered by FluxBB