libratbag / piper

GTK application to configure gaming devices
GNU General Public License v2.0
4.77k stars 177 forks source link

Piper crashes when opening devices with weird profiles. #120

Closed cvuchener closed 7 years ago

cvuchener commented 7 years ago

I have some mice where I tested weird profiles. Piper crashes when I try to open them.

First one is a G500 using "Switch to profile X" special action that is not supported by libratbag ("UNKNOWN").

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/gi/_propertyhelper.py", line 427, in obj_set_property
    prop.fset(self, value)
  File "/usr/local/lib/python3.6/site-packages/piper/mouseperspective.py", line 89, in device
    self.stack.add_titled(ButtonsPage(device), "buttons", _("Buttons"))
  File "/usr/local/lib/python3.6/site-packages/piper/buttonspage.py", line 50, in __init__
    self._set_profile(self._device.active_profile)
  File "/usr/local/lib/python3.6/site-packages/piper/buttonspage.py", line 57, in _set_profile
    self._on_ratbagd_button_action_type_changed(ratbagd_button, None, button)
  File "/usr/local/lib/python3.6/site-packages/piper/buttonspage.py", line 83, in _on_ratbagd_button_action_type_changed
    label = RatbagdButton.SPECIAL_DESCRIPTION[ratbagd_button.special]
KeyError: 4294967295

The second is a G500s with multiple profiles (but libratbag only supports one profile for the G500s). I am not sure what is the exact cause for the crash.

Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/gi/_propertyhelper.py", line 427, in obj_set_property
    prop.fset(self, value)
  File "/usr/local/lib/python3.6/site-packages/piper/mouseperspective.py", line 87, in device
    self.stack.add_titled(ResolutionsPage(device), "resolutions", _("Resolutions"))
  File "/usr/local/lib/python3.6/site-packages/piper/resolutionspage.py", line 66, in __init__
    self._init_ui()
  File "/usr/local/lib/python3.6/site-packages/piper/resolutionspage.py", line 86, in _init_ui
    self._on_active_profile_changed(self._device, profile)
  File "/usr/local/lib/python3.6/site-packages/piper/resolutionspage.py", line 92, in _on_active_profile_changed
    self.rate_500.set_active(active_resolution.report_rate == 500)
AttributeError: 'NoneType' object has no attribute 'report_rate'

Output of ratbag-command info:

ratbag info: Profile 0 has a wrong CRC, assuming valid.
Device 'Logitech G500s Laser Gaming Mouse'
Capabilities: res profile btn-key btn-macros
Number of buttons: 13
Number of leds: 0
Profiles supported: 1
  Profile 0 (enabled) (active)
    Resolutions:
      Range: [50, 8200]
      0: 400x400dpi @ 1000Hz (default)
      1: <disabled>
      2: <disabled>
      3: <disabled>
      4: <disabled>
    Button: 0 type left is mapped to 'button 1'
    Button: 1 type middle is mapped to 'button 2'
    Button: 2 type right is mapped to 'button 3'
    Button: 3 type thumb is mapped to 'button 4'
    Button: 4 type thumb2 is mapped to 'button 5'
    Button: 5 type thumb3 is mapped to 'button 3'
    Button: 6 type wheel left is mapped to 'resolution up'
    Button: 7 type wheel right is mapped to 'resolution down'
    Button: 8 type resolution up is mapped to 'profile up'
    Button: 9 type resolution down is mapped to 'profile down'
    Button: 10 type unknown is mapped to 'none'
    Button: 11 type unknown is mapped to 'none'
    Button: 12 type unknown is mapped to 'none'
Hjdskes commented 7 years ago

First one is a G500 using "Switch to profile X" special action that is not supported by libratbag ("UNKNOWN").

If it's not supported by libratbag then Piper can't use it, but I should definitely check whether the key is in the map to prevent Piper from crashing like it currently does.

The second is a G500s with multiple profiles (but libratbag only supports one profile for the G500s). I am not sure what is the exact cause for the crash.

According to your traceback, active-resolution is None, meaning that your profile doens't have an active resolution set: https://github.com/libratbag/piper/blob/master/piper/resolutionspage.py#L90 and https://github.com/libratbag/piper/blob/master/piper/ratbagd.py#L407, this is confirmed by your output of ratbag-command info. As far as I know there should always be an active resolution so this is primarily a libratbag bug, but, again, something that shouldn't make Piper crash. Can you open an issue on libratbag for not having an active resolution on your device?

Hjdskes commented 7 years ago

Thanks for testing by the way, this week I want to solve exactly these kind of issues before we tag a (pre-)release.

cvuchener commented 7 years ago

your profile doens't have an active resolution set

I see why now. Getting the active profile or resolution is not reliable on HID++1.0 devices. But I don't know a good way to fix that. I'll open an issue on libratbag.

Thanks for testing by the way, this week I want to solve exactly these kind of issues before we tag a (pre-)release.

I have a few more issues but I am not sure how to trigger them yet.

Hjdskes commented 7 years ago

I opened #121 and https://github.com/libratbag/libratbag/issues/281 related to the special mapping issue.

Hjdskes commented 7 years ago

And #122 for broken drivers.

Hjdskes commented 7 years ago

Closing this one for now as there are two PRs solving the issues you mentioned. Feel free to reopen.