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
Starting with 5.73, Logitech MX Master 3 scroll wheel speed drops dramatically after some idle time or mouse power toggle #778
Comments
Same here with Logitech MX Master on Archlinux after bluez update from 5.72 to 5.73. Turning the mouse off and on doesn't help. The Bluetooth process seems to hang a little. Bluetooth cannot be switched off/on via the Mate GUI. As a temporary solution, I kill the Bluetooth process with signal 9. The mouse then reconnects and the scroll wheel can be used normally again. until the next break.
|
I'm experiencing the same. Unless I did something wrong while testing, neither |
Same issue with Logitech MX Anywhere 3 |
same issue, also with logitech mx anywhere 3 downgraded from 5.73 to 5.72 as a temp fix |
Also discussed here, where I thought it was a GNOME issue. Something I found there: if you install the 'solaar' management utility and toggle the "Scroll Wheel Resolution" setting to on (when I ran the app, it was off - you have to 'unlock' the setting by clicking the lock icon twice first) it 'fixes' the problem. So bluez may be somehow inadvertently doing something to whatever that toggle represents? |
Change 44d3f67 since to have introduced quite a few bugs related to device_is_connected return true which prevents proper cleanup of connection. Fixes: bluez/bluez#774 Fixes: bluez/bluez#778 Fixes: bluez/bluez#783 Fixes: bluez/bluez#784
After I got https://gitlab.archlinux.org/archlinux/packaging/packages/bluez/-/blob/e67ba6b274c4b5e182c323ae0048fe96da1bcdcb/0001_use_bt_uhid_functions.patch via Arch's 5.73-4, the problem seems to be gone. Edit: I also got an update to Linux 6.8 that might be relevant somehow. Edit: Not true. It's back. Trying 8060d12 now. |
I added the patch from BluezTestBot#2140 to the fedora package and built locally. Seems to fix this issue. Also tested my Pixel Buds Pro, no regressions there. So that PR LGTM. |
Sadly I'm still seeing slow scrolling here :( It seemed to be working all day, but after I left the system idle for a while and came back, slow scrolling returned. |
Can't reproduce, at least not yet, after a 15-minute idle period. (edit: with the same locally-built patched package) |
I left it longer than that (went downstairs for dinner, probably 3 hours or so). |
Yup, reproduced here too after an overnight
Editing to add: Later in the day leaving the machine idle doesn't (yet) reproduce the problem, even though the |
With Archlinux bluez 5.73-4 the problem is NOT gone for me. |
It does kinda seem like the problem happens less now, but hard to say if that's really true or just my unreliable impression... |
Sorry, I just jumped to conclusions there. See my edits. With 8060d12 (on top of Arch's 5.73-4) it seems to be running fine yet. Will report back if it reappears. |
Unfortunately it's back. I second @AdamWill's impression that it takes a longer idle time to appear with that patch, but it still does. |
For me, I don't even need to go idle. If I simply turn off the mouse, the problem will trigger. I can make bluetoothd die completely if, after this issue occurs, I try to turn off/on bluetooth in KDE settings. Restarting the bluetooth service does fix it. Restarting it does take quite a while though. |
@dimitris-personal might be a duplication of #777, we persist the input node because of #771 otherwise we may loose key presses at the start. HIDP actually has a way to indicate to the host it wants to generate a virtual cable unplug: https://github.com/bluez/bluez/blob/master/profiles/input/device.c#L323 So if there anything wrong with keeping the device 'plugged' that is because the manufactorer did not asked it to be unplugged while disconnected. |
Try this next: When you are afflicted (Hehe... love that word!) by the mouse slowdown issue, go in KDE settings (I assume it's the same with Gnome) and try to disable bluetooth and reenable it. In KDE, that seems to work, but then devices will not reconnect. The only fix for this is to restart bluetoothd. |
@Vudentz I see. I tried Any chance of an option to control the behavior at https://github.com/bluez/bluez/blob/master/profiles/input/device.c#L323 ? Any other workarounds? I did try the unifying receiver and it does work, but a) it's an extra dongle, b) forwards/backwards buttons and overview gesture no longer work with it. |
Well this looks more interesting: I tried building b8ad349 plus the patch at https://patchwork.kernel.org/project/bluetooth/patch/20240320130119.854959-1-luiz.dentz@gmail.com/ plus setting Then looking at kernel messages, it looks like both Steps:
So, not sure what/how is loading |
My guess is that this is a kernel issue, not a bluetooth issue. Just some latest update in bluez exposed it for bluetooth connection as well. I've reported a slow scrolling bug in 2019, using USB dongle connection, here: So it has been present for at least 5 years now. During that time, it has never affected bluetooth connection (I still have the same mouse, and I use it with both USB dongle and BT regularly), that started just recently. |
TL;DR: This may be a problem where the Linux input driver is not notified or does not recognize when the mouse reconnects under Bluetooth. Here is some background on the problem. I have knowledge of how these mice work because I maintain the Solaar program, which can be used to control various Logitech devices that use the Logitech HID++ protocol. These mice respond to a special (HID++) message sent to them by changing several ways the scroll wheel works. The message sets the scroll wheel into low-resolution or high-resolution mode, into inverted or not inverted mode, and into HID or HID++ mode. In high-resolution mode the mouse wheel reports about 8 times as much distance when it turns as it does in low-resolution mode, and can report many more events. The Linux HID++ driver, https://github.com/torvalds/linux/blob/master/drivers/hid/hid-logitech-hidpp.c, uses high-resolution mode to implement smooth scrolling. What the driver does, at least for programs that don't use smooth scrolling, is to keep track of the high-resolution scrolling distance and only send out a scroll event when 8-or-so high-resolution distance units have been accumulated. So nothing should change for these programs. There are two things that can go wrong. First, a program, like Solaar, might change the resolution mode. The driver should examine all the messages that the device sends out and change smooth-scrolling mode when the device indicates that it has switched resolution mode but it does not. Second, each time that the mouse goes into a power-saving mode it forgets its scrolling modes and when it reawakens it starts up in its default modes, which include low-resolution mode. The driver should recognize when the device wakes up and send a message to switch to high-resolution mode. For mice connected via a Logitech receiver this is generally done in response to HID++ connection messages. For mice connected via Bluetooth this is generally done when the Bluetooth connection is established, because Bluetooth connections were dropped when the mouse goes into a power-saving mode. If this is no longer the case then it is easy to see how scrolling can become slow after a period of inactivity. For more information on the HID++ messages used for these scrolling wheels see https://drive.google.com/drive/folders/0BxbRzx7vEV7eWmgwazJ3NUFfQ28?resourcekey=0-dQ-Lx1FORQl0KAdOHQaE1A PS: The ongoing problem when the connection is via a receiver may be caused by sending a message to the mouse so early in the reconnect process that the message is either lost or the mouse does not process the message. |
@pfps which driver would that be? |
hid-logitech-hidpp But it might be that the driver currently has no way of recognizing when the device wakes up, so the change has to (also?) be in the Bluetooth stack. Or it might be that some driver has to set a flag somewhere so that the Bluetooth stack knows to do something differently. Or there might be something else that needs to be changed so that the driver can know when the device wakes up. |
If what you are saying is related to keeping the uhid device while disconnected Ive just merged the following change: https://patchwork.kernel.org/project/bluetooth/patch/20240405211145.3463154-3-luiz.dentz@gmail.com/ This will store the control messages seem when it connects the first time, then if reconnects (due to entering powersafe mode, etc) then we will replay the control messages to restore the states. |
Correction, looks like this won't work on LE since the changes were just for classic, so I may need to move the replay support to a common place to have LE also taking benefit of it. |
@Vudentz How are you keeping track of the messages? The messages sent by the driver (and Solaar) are HID++ messages sent on the raw interface. The underlying issue is that there is state that may need to be set up whenever these devices come back from a power-saving mode. Some of this state (e.g., high-resolution scrolling) needs to be sent from software (driver or some other system) to the device, but other state (e.g., distance multiplication) is stored on the device and needs to be present in software. The driver sends three messages (get an index used in later messages, get the multiplier, set high-resolution mode). Only the third needs to be sent on reconnections. The first two only retrieve information and the information is always the same for the device (unless its firmware is updated). I'm not sure how this all will affect Solaar, which similarly sets up device state for Logitech HID++ devices whenever they connect or reconnect. The number of messages that Solaar sends to do this can be several dozen. |
@pfps it records all messages of ev.type = GET_REPORT/SET_REPORT. so as long as that is what HID++ uses then it shall be fine. And yes, there are quite a few of them, I recorded 18 with MX Anywhere 3, then on reconnect they are resend immediately, we may want to introduce a timeout for these messages though so if the device stay disconnected for some long time we just send UHID_DESTROY and cleanup the cache. |
@Vudentz For some Logitech devices the best startup sequence can be non-trivial to determine. Some messages to the device change what messages are sent from the device. A bad situation is if the device is woken up by pressing a function key. Many Logitech devices have a mode that switches the HID report that is sent by these keys. The device should be set up to delay messages until software has had a chance to tell it what report to send for function keys. The software should quickly send setup messages and then tell the device that it is finished setup so the device can then sent the appropriate report. (There is a timeout to guard against deficient software.) I don't know whether replay is sufficient here. |
Here is the set: https://patchwork.kernel.org/project/bluetooth/list/?series=842597 |
On bluez 5.72 when a Bluetooth device disconnects Solaar immediately notices that the connection is gone. When the device reconnects Solaar sees a new device and sends appropriate setup messages. On bluez 5.73 when a Bluetooth device disconnects Solaar does not notice that anything has changed. Writes to the device fail but the HID raw node for the device is still available. But something notices because a notification pops up saying that the device has disconnected. Is there documentation on this change? Is there any way for Solaar to find out that the device has disconnected? When the Logitech device reconnects it sends a message asking for reconfiguration. Solaar currently doesn't do anything with this message, but it should. UPDATE: Not all Logitech devices send this message so Solaar needs to know when a device disconnects. The messages that Solaar sends to set up Logitech devices should not be replayed becuase Solaar will soon be able to set up these devices when they disconnect, even under bluez 5.73. As well, the correct setup sequence may have changed because the user has changed settings on the device. Replaying driver setup messages might not be correct for the same reason, although I don't think that there currently is any variability in setup by the current Linux driver for Logitech devices. Replaying setup messages is also potentially inefficient as on reconnect the driver might not request information that is unchanging. |
What is Solaar? https://pwr-solaar.github.io/Solaar/?
The change to prefer uHID was introduced to keep input devices around since otherwise there were events being lost during the creation of the input node, in particular this is very cumbersome for keyboards since the users had to re-enter key presses while reconnecting and by keeping the device around the problem was gone, which indicates there is a bug somewhere in between HID, or perhaps user session, not processing these events. Anyway there is a long list of changes for 5.74 release so I do recommend testing against that. |
So is this bug actually resolved or was this GH issue just closed prematurely? |
It was closed prematurely, the bug definitely persists. @Vudentz says to try the replay patches - I think that's the range 7604a57..b163e2b in git master. I'm trying that now. edit - for anyone on Fedora 40, https://koji.fedoraproject.org/koji/taskinfo?taskID=116243781 is a scratch build of current git master (the patches don't backport cleanly so I just went with a snapshot build). I've just installed it, will have to wait a bit to see if it fixes the bug. |
I don't want to jump the gun again, but it really does seem like that build fixes it this time, so presumably the replay patches helped. @Vudentz will 5.74 be coming soon? It'd be great to get this fixed for Fedora 40, but I don't really want to update the package to a random git snapshot...I can try harder to rebase the replay patches if the release won't be soon, I guess. |
That is great to know it is working for more people, we are in the process of releasing 5.74 soon. |
After updating to 5.75, the scroll wheel keeps its speed, but the sensitivity (DPI) still drops. I'm also using solaar. |
I've never tweaked my DPI, so I wouldn't have noticed that part. |
@samfelgar You could run Solaar as |
@pfps Here's the output: solaar-debug.txt Thanks! |
Thanks. Here is an edited, annotated list of the messages that are coming back from the mouse. The first message is a notification from the device of its battery status
Then there are a bunch of responses to messages sent to the device. The messages appear to have been originally sent by the device driver, because the driver uses a 0x1 for the software identifier, which is the lower half of the fourth byte of the responses. It is unclear whether these are all from the bluez replay mechanism.
Of these 20 responses, 19 are for messages sent to gather information. Some of these are to determine the indexes of various features. Some are to find out the device's name. Some are to find information about the device's battery. One is to find out information about the device's protocol version. One is to find out information about the device's scroll wheel. There is quite a bit of duplication, putting extra load on the device. The source of this duplication is unclear. Only one response is for a message that actually changes something. Fortunately it appears that messages sent by Solaar are not being replayed. |
Hmm, maybe we need to check if there are duplicated messages in the queue, anyway we can make bt_uhid instance be a little bit more smart with respect to the device, maybe even incorporate the logic of Solaar and make it remember settings so the user don't have to keep doing this on every reconnect. |
Thanks for fixing this guys 🙏 as I'm on Fedora, I will survive with |
Solaar https://github.com/pwr-Solaar/Solaar release 1.1.12rc1, just out, uses the connect and disconnect DBus messages from bluez to reinitialize the Bluetooth devices it controls when they reconnect. It can be used to correctly set the feature that the hid_logitech_hidpp driver modifies to implement smooth scrolling and prevent wheel speed drop when Bluez 5.73 is installed. The Solaar Scroll Wheel Resolution setting has to be true (and not ignored). There is a small chance that Solaar and the driver interact poorly at startup, which can be fixed by toggling the setting to false and back to true. |
@discapes just do |
Same good results here with the same F39 versions @ktdreyer. One note: After I removed |
Up to date Fedora 39 paired with a MX Master 3. Mouse has been working flowlessly up to and including 5.72. Starting with 5.73:
s2ide
: Turn mouse on, connects, mouse wheel speed is normal.A quick look at the journal shows only this:
bluetoothd[34318]: Device is already marked as connected
(edit: as far as I can tell this message only started appearing with 5.73)
Downgrading back to 5.72 fixes the issue.
The text was updated successfully, but these errors were encountered: