pwr-Solaar / Solaar

Linux device manager for Logitech devices
https://pwr-solaar.github.io/Solaar
GNU General Public License v2.0
5.54k stars 410 forks source link

Solaar crashes when connecting laptop to dock with a logitech mouse plugged in #2178

Closed Aleksandar204 closed 11 months ago

Aleksandar204 commented 12 months ago

Information

``` solaar version 1.1.10 Lightspeed Receiver Device path : /dev/hidraw4 USB id : 046d:C547 Serial : 8A3EBF52 Firmware : 04.02.B0009 Bootloader : 02.09 Other : 0D.C1 Has 1 paired device(s) out of a maximum of 2. Notifications: wireless, software present (0x000900) Device activity counters: 1=205 solaar: error: Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/solaar/cli/__init__.py", line 211, in run m.run(c, args, _find_receiver, _find_device) File "/usr/lib/python3.12/site-packages/solaar/cli/show.py", line 296, in run _print_device(dev) File "/usr/lib/python3.12/site-packages/solaar/cli/show.py", line 85, in _print_device dev.ping() File "/usr/lib/python3.12/site-packages/logitech_receiver/device.py", line 455, in ping protocol = _base.ping(self.handle or self.receiver.handle, self.number, long_message=long) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/logitech_receiver/base.py", line 541, in ping raise NoSuchDevice(number=devnumber, request=request_id) logitech_receiver.base.NoSuchDevice: {'number': 1, 'request': 27} ```
``` - 1.1.10 - _NAME: G502 X PLUS _absent: [hi-res-scroll, lowres-scroll-mode, scroll-ratchet, smart-shift, thumb-scroll-invert, thumb-scroll-mode, pointer_speed, speed-change, backlight, backlight-timed, fn-swap, reprogrammable-keys, persistent-remappable-keys, divert-keys, disable-keyboard-keys, crown-smooth, divert-crown, divert-gkeys, m-key-leds, mr-key-led, multiplatform, change-host, gesture2-gestures, gesture2-divert, gesture2-params, sidetone, equalizer, adc_power_management] _battery: 4100 _modelId: 4099C0950000 _sensitive: {hires-smooth-resolution: false} _serial: 73BCA4E6 _unitId: 73BCA4E6 _wpid: '4099' dpi: 2400 hires-scroll-mode: false hires-smooth-invert: false hires-smooth-resolution: true onboard_profiles: 1 report_rate: 1 ```

Describe the bug When connecting a powered on laptop to a usb type c dock, which has a logitech mouse connected to it, solaar crashes, and the settings are sometimes applied to the mouse, and other times aren't, when launching the app again, everything seems to work as intended.

To Reproduce Steps to reproduce the behavior:

  1. Turn on computer while disconnected from dock
  2. When logged in to desktop, connect the laptop to the dock
  3. Solaar crashes

Additional context Not sure if this is a part of the problem, but I'm running libinput-config to make libinput think that my G502X plus is a high resolution scrollwheel mouse.

pfps commented 12 months ago

Please run Solaar from a terminal as solaar -dd and post any messages near the time of the crash. Also, is the crash from solaar show repeatable? If so, please provide the output of solaar -ddd show.

pfps commented 12 months ago

After you have done the above please download PR #2179 and run bin/solaar -ddd show. This PR handles the exception in solaar show and should provide more information on your devices.

To clone and use Solar from its GitHub repository

git clone https://github.com/pwr-Solaar/Solaar.git
cd Solaar

Run Solaar as bin/solaar from this directory.

To run PR #2179, first clone Solaar if you have not already done so and cd to the clone directory. The first time you download the pull request, fetch it into a new branch and checkout that branch, as in:

git fetch origin pull/2179/head:pull_2179
git checkout pull_2179

To download a new version of the pull request, fetch it and then set your pull branch to the new fetch, as in:

git checkout pull_2179
git fetch origin pull/2179/head
git reset --hard FETCH_HEAD
Aleksandar204 commented 12 months ago

Hi, I started trying to reproduce the crash with logs. I can't reproduce the crash from running solaar show again. As for the crash when connecting to the dock, it looks like it won't crash if the mouse didn't enter sleep mode between disconnecting and reconnecting to the dock, so it will probably take some time to capture all the logs due to the wait for it to go to sleep. Will update once I get something useful. (maybe the crash in 'solaar show' is also connected to it going into sleep, will try to test)

pfps commented 12 months ago

OK. What is the output of solaar -ddd show when there is no crash?

Aleksandar204 commented 12 months ago

Managed to get the output of solaar -dd while crashing, it's the first attachement, the second one is solaar -ddd show solaar-dd.txt solaar-dddshow.txt

pfps commented 12 months ago

OK, it looks as if there are times when attempts to ping the device through the receiver just fail. I'll add some code to Solaar to make it behave more gracefully in these cases.

What does the Solaar main window look like when the crash happens?

Aleksandar204 commented 12 months ago

Screencast from 2023-11-18 15-38-56.webm

pfps commented 12 months ago

So Solaar is behaving normally except that it spits out a bunch of error messages, and there is a pop-up saying that it crashed? Afterwards can you interact with the Solaar window? Do you know what is producing the pop-up?

Aleksandar204 commented 12 months ago

Yes, the app works fine after the crash, sometimes it even applies the settings to the mouse, sometimes it doesn't. The popup is (I think) a part of the gnome built in crash detection and auto reporter. It leads to the fedora bugzilla page with crash analytics

pfps commented 12 months ago

If the settings are for the scroll wheel then the issue is that Solaar and the Linux driver and possibly libinput-config are all changing the setting. The one that wins is the last one. To make things worse, the driver makes the changes in a very simplistic manner. There is wording on https://github.com/pwr-Solaar/Solaar about this, but the solution is to have Solaar ignore scroll wheel resolution, and probably the other scroll wheel settings.

pfps commented 12 months ago

The current version of PR #2179 should be somewhat better. Please download it and try bin/solaar -dd and see what happens when your mouse is asleep. Also try bin/solaar -d in the same circumstances.

Aleksandar204 commented 12 months ago

I did a bit of testing, looks like libinput-config or race conditions are not to blame. I uninstalled libinput-config, set all solaar settings related to the scrollwheel to Ignore this setting and I am still getting those errors. It appears that this is not related to the mouse itself going to sleep, or at least not completely since I can get the same error by cutting power to the dock and thus the reciever. Will test out that PR within an hour or two, and will report back if it fixed the problem.

pfps commented 12 months ago

The crashes are not related to the race condition except as how they may slow down Solaar. The race condition is related to the how the settings end up.

Aleksandar204 commented 12 months ago

Hi, i tried out the PR, based on the log, some error still happens but the gnome crash reporter tool doesn't give a pop-up anymore (maybe because it wasn't installed through the package manager, but instead ran from my home dir, idk how it works).

output2.txt

pfps commented 12 months ago

The fix I had for the logging error didn't work. I added a check when printing a device so that, hopefully, it will not crash. Please download the current version of the PR and try again.

Aleksandar204 commented 12 months ago

Something still makes an error, but the traceback is much shorter than last time. output3.txt

pfps commented 12 months ago

Yes, another place where an exception in ping needs to be handled. Please download the PR again and try again.

Aleksandar204 commented 12 months ago

Tried it out now, looks good to me. No errors