You are not logged in.

#1 2024-06-16 09:34:17

balthamaisteri
Member
Registered: 2014-09-02
Posts: 26

[SOLVED] Bluetooth keyboard reconnection time

I feel that my bluetooth keyboard reconnection time (after automatic shutdown) is greatly increased lately.

Keyboard takes multiple seconds to reconnect after multiple attempts.

On my ubuntun laptop, reconnection is almost instant.

/etc/bluetooth/main.conf config file:

FastConnectable = true
ReconnectAttempts=7
ReconnectIntervals=1

Is there any way to debug this issue?

Kernel: 6.9.4-arch1-1
DE: Plasma 6.0.5

edit:

6.9.6 should solve the issue. RC1 connects almost instantly.

Last edited by balthamaisteri (2024-06-21 17:06:58)

Offline

#2 2024-06-17 21:02:52

filotek
Member
Registered: 2018-08-15
Posts: 25

Re: [SOLVED] Bluetooth keyboard reconnection time

I've noticed ever since the linux 6.9.3 kernel upgrade, my Sony WH-1000XM4 headset takes a-lot longer to connect via bluetooth.  Upwards of 8 to 9 seconds (instead of the usual 3 seconds).

I can fix the issue by downgrading to kernel 6.9.2, and reproduce the problem on kernel 6.9.3.

Below, I've obscured the device id to look like F8_XX_XX_XX_XX_XX but everything else about the logs are faithful.

# 6.9.2 kernel

$ journal --follow
Jun 17 16:13:33 forage systemd[2341]: Reached target Bluetooth.
Jun 17 16:13:33 forage pulseaudio[2502]: [70B blob data]
Jun 17 16:13:34 forage chronyd[1090]: Selected source 206.108.0.131 (3.arch.pool.ntp.org)
Jun 17 16:13:34 forage pulseaudio[2502]: Battery Level: 100%
< CONNECTED HERE >
Jun 17 16:13:36 forage bluetoothd[1192]: /org/bluez/hci0/dev_F8_XX_XX_XX_XX_XX/sep1/fd0: fd(30) ready
Jun 17 16:13:36 forage rtkit-daemon[2540]: Supervising 7 threads of 1 processes of 1 users.
Jun 17 16:13:36 forage rtkit-daemon[2540]: Successfully made thread 3662 of process 2502 owned by '1001' RT at priority 5.
Jun 17 16:13:36 forage rtkit-daemon[2540]: Supervising 8 threads of 1 processes of 1 users.
Jun 17 16:13:36 forage pulseaudio[2502]: org.freedesktop.DBus.Properties.Get /org/bluez/hci0/dev_F8_XX_XX_XX_XX_XX/sep1/fd0 Volume property not (yet) available
Jun 17 16:13:36 forage kernel: input: WH-1000XM4 (AVRCP) as /devices/virtual/input/input23
Jun 17 16:13:36 forage systemd-logind[1073]: Watching system buttons on /dev/input/event8 (WH-1000XM4 (AVRCP))

# 6.9.3 kernel

$ journal --follow
Jun 17 16:06:34 forage systemd[2381]: Reached target Bluetooth.
Jun 17 16:06:40 forage kernel: input: WH-1000XM4 (AVRCP) as /devices/virtual/input/input23
Jun 17 16:06:41 forage systemd-logind[1071]: Watching system buttons on /dev/input/event8 (WH-1000XM4 (AVRCP))
Jun 17 16:06:43 forage pulseaudio[2539]: [70B blob data]
< CONNECTED HERE >
Jun 17 16:06:43 forage bluetoothd[1178]: /org/bluez/hci0/dev_F8_XX_XX_XX_XX_XX/sep1/fd0: fd(30) ready
Jun 17 16:06:43 forage rtkit-daemon[2575]: Supervising 7 threads of 1 processes of 1 users.
Jun 17 16:06:43 forage rtkit-daemon[2575]: Successfully made thread 4018 of process 2539 owned by '1001' RT at priority 5.
Jun 17 16:06:43 forage rtkit-daemon[2575]: Supervising 8 threads of 1 processes of 1 users.
Jun 17 16:06:43 forage pulseaudio[2539]: Battery Level: 100%

On a side note, I also noticed that I used to be able to get the bluetooth battery percentage from sink properties using pactl -f json list sinks.

$ pactl -f json list sinks | jq .
....
    "properties": {
      "bluetooth.protocol": "a2dp_sink",
      "bluetooth.codec": "sbc",
      "device.description": "WH-1000XM4",
      "device.string": "F8:XX:XX:XX:XX:XX",
      "device.api": "bluez",
      "device.class": "sound",
      "device.bus": "bluetooth",
      "device.form_factor": "headset",
      "bluez.path": "/org/bluez/hci0/dev_F8_XX_XX_XX_XX_XX",
      "bluez.class": "0x240404",
      "bluez.alias": "WH-1000XM4",
      "bluetooth.battery": "100%",
      "device.icon_name": "audio-headset-bluetooth",
      "device.intended_roles": "phone"
    },
....

This battery info is no longer available from the pactl list sinks command after kernel upgrades to 6.9.3 (or later).  Though it's not a big loss as I can still get to it from pactl -f json list cards (as opposed to list sinks) or using a python dbus script to get at this data.

I have not tried setting FastConnectable = true or using any of the other /etc/bluetooth/main.conf settings as outlined by @balthamaisteri.  I don't care to increase battery consumption (as noted in the config) and it doesn't seem to work for @balthamaisteri in any event.

I'm not sure where I'd report this bug, nor am I certain this is even a bug.  Maybe it's supposed to take longer and the kernel updates fixes this?  No idea.

Though it is annoying to start up my bluetooth headset before a call and wait effectively 3x longer before joining an on-line meeting.

Details about my system:

DE: i3-wm
Machine: ThinkPad T14 Gen 3
Linux forage 6.9.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 16 Jun 2024 19:06:37 +0000 x86_64 GNU/Linux

Offline

#3 2024-06-20 22:55:32

filotek
Member
Registered: 2018-08-15
Posts: 25

Re: [SOLVED] Bluetooth keyboard reconnection time

I was able to find the following reported regression for the 6.9.3 kernel.
https://lore.kernel.org/regressions/CAG … ail.com/T/

It further pointed to an issue discussed on the bluez repository.
https://github.com/bluez/bluez/issues/865

Within the bluez issue, it speaks to a 6-second timeout with a 3-second period of inactivity.  It lines up with my experience using the Sony WH-1000XM4.

A fix was proposed and confirmed within the issue, and it looks like the fix is now on linux-stable-rc.git
https://git.kernel.org/pub/scm/linux/ke … db509a2b20

And it also seems to be included in the RC release for 6.9.6 (the next kernel release).
https://lkml.org/lkml/2024/6/19/713

I decided to build my own kernel (6.9.5) using this patch from the above commits.

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index e3f5d830e42bfe..9394a158d1b1a2 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4009,8 +4009,8 @@ static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
                                status = L2CAP_CS_AUTHOR_PEND;
                                chan->ops->defer(chan);
                        } else {
-                               l2cap_state_change(chan, BT_CONNECT2);
-                               result = L2CAP_CR_PEND;
+                               l2cap_state_change(chan, BT_CONFIG);
+                               result = L2CAP_CR_SUCCESS;
                                status = L2CAP_CS_NO_INFO;
                        }
                } else {

After rebooting I can confirm the fix WORKS!  The Sony WH-1000XM4 connects to the laptop within 2 to 3 seconds after it's turned on.  It also restored functionality with pactl -f json list sinks in that it now reports the battery levels for my head-set.

@balthamaisteri, I don't know much of what's going on or why the fix works, though I'm happy that it does.  If you're itching to resolve your issue, give it a shot; or just wait for the 6.9.6 release (which should be the next one).

Offline

#4 2024-06-21 06:19:38

balthamaisteri
Member
Registered: 2014-09-02
Posts: 26

Re: [SOLVED] Bluetooth keyboard reconnection time

Nice! Time to learn how to compile kernel I quess xD

Thanks!

Offline

#5 2024-06-21 07:20:12

gromit
Administrator
From: Germany
Registered: 2024-02-10
Posts: 1,525
Website

Re: [SOLVED] Bluetooth keyboard reconnection time

You can also find a prebuilt version of the release candidate here:

sudo pacman -U https://pkgbuild.com/\~gromit/linux-bisection-kernels/linux-6.9.6rc1-1-x86_64.pkg.tar.zst

Offline

#6 2024-06-21 08:48:43

balthamaisteri
Member
Registered: 2014-09-02
Posts: 26

Re: [SOLVED] Bluetooth keyboard reconnection time

It seems to be much snappier now!

Thanks smile

Offline

Board footer

Powered by FluxBB