hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.45k stars 897 forks source link

Hyprctl devices shows multiple touch/touchscreen devices after suspend/resume (increments the device) #3859

Open nine7nine opened 11 months ago

nine7nine commented 11 months ago

Hyprland Version

v0.32.3-19-g81598b3d

Bug or Regression?

Bug

Description

After resuming from suspend, hyprctl devices shows multiple entries for my touch / touchscreen devices. ~ It increments the devices after each resume.

Touch:
    Touch Device at 55bb8471c680:
        ipts-045e:099f-touchscreen
    Touch Device at 55bb848cfe00:
        ipts-touch
    Touch Device at 55bb864a9260:
        ipts-touch-1
    Touch Device at 55bb86596d20:
        ipts-045e:099f-touchscreen-1
    Touch Device at 55bb8471e6c0:
        ipts-045e:099f-touchscreen-2
    Touch Device at 55bb8648e640:
        ipts-touch-2

I noticed this after setting up a manual rotation button/widget in AGS (as so far, I have not been able to get auto-rotate with iio-sensor-proxy to work correctly with my device)... Manual rotation works great, until I use suspend at which point - the touch device no longer rotates properly, because my code expects the device to be 'ipts-touch', but the device is incremented to ipts-touch-1, ipts-touch-2 and so on...

Looking at the device on the system or in evtest - there is no increment happening... I only see this is in hypctl devices ~ but as I am not even sure how hyprctl determines the devices, I'm not sure what the cause would be; only that rotating my touch device stops working due to the increment in device name, after each suspend/resume.

the comment in this PR: https://github.com/hyprwm/Hyprland/pull/1730 also mentions the functionality not working after suspend/resume, which makes me wonder if they are experiencing the same issue (?)

How to reproduce

  1. suspend my machine.
  2. resume / wake my machine.
  3. try to rotate the touch input using my widget/button, code is basically using:

hyprctl keyword device:ipts-touch:transform 1 hyprctl keyword device:ipts-touch:transform 0

which doesn't work due to the device name incrementing...

check hyprctl devices output: it shows a new touch device and any previous touch devices/duplicates. ~ highest increment/number is the one that will be active, so assuming it was ipts-touch-2 now, to manually rotate input becomes:

hyprctl keyword device:ipts-touch-2:transform 1

Crash reports, logs, images, videos

No response

idabmat commented 7 months ago

Still experiencing in v0.37.1. Name of device keeps on incrementing after resume from suspend. Only the last one (higher increment) is active.

> hyprctl devices

Touch:
    Touch Device at d94bf50:
        elan9009:00-04f3:41d9
    Touch Device at da3e2d0:
        elan9009:00-04f3:41d9-1
    Touch Device at db6b1d0:
        elan9009:00-04f3:41d9-2
    Touch Device at d92aa50:
        elan9009:00-04f3:41d9-3
    Touch Device at 34b28c0:
        elan9009:00-04f3:41d9-4
    Touch Device at 368fb70:
        elan9009:00-04f3:41d9-5
    Touch Device at da113d0:
        elan9009:00-04f3:41d9-6
    Touch Device at d7e9940:
        elan9009:00-04f3:41d9-7
    Touch Device at 35031d0:
        elan9009:00-04f3:41d9-8

The workaround for now is to duplicate the device config in hyprland.conf

device {
  name=elan9009:00-04f3:41d9
  output=DP-5
}

device {
  name=elan9009:00-04f3:41d9-1
  output=DP-5
}

device {
  name=elan9009:00-04f3:41d9-2
  output=DP-5
}

device {
  name=elan9009:00-04f3:41d9-3
  output=DP-5
}

device {
  name=elan9009:00-04f3:41d9-4
  output=DP-5
}

device {
  name=elan9009:00-04f3:41d9-5
  output=DP-5
}

But of course, if you end up suspending more times than the config is replicated, then it falls apart.

Is there another way to handle that scenario?

vaxerski commented 7 months ago

I think this is a kernel bug or driver bug or wlr bug or something.

nine7nine commented 7 months ago

Ya, I'll close this one.

I can't produce this on inux-6.8 or linux-6.9-rc2

I suspect you are correct and it was a kernel or driver bug.

idabmat commented 7 months ago

I'm on linux 6.8 and still seeing it though. Any ideas how to pinpoint where the issue could be?

nine7nine commented 7 months ago

@idabmat - personally, I have no idea.

@vaxerski may have some recommendations on how to try and pin point it...? But I have no clue.

vaxerski commented 7 months ago

no clue either this is not hyprland's fault tho

xtj7 commented 3 months ago

I have the same problem but in a more complex setup (3 touchscreens). But I can provide more details on the extent of the issue.

If you have multiple touchscreens and it resumes after suspend, it SOMETIMES increases the number for all touchscreens. If it increases the number, the order will be randomised. So let's say you have touchscreen, touchscreen-1 and touchscreen-2, after suspend/resume it could be touchscreen-4, touchscreen-3 and touchscreen-5. Not just the order in the devices list is random, but also what's behind each name. I tried to write myself a little script that simply replaces the config on resume to circumvent the issue, but both the id of the device and the name of the device change - in a random order. Sorting the list by name does not help either, as what is behind each entry is also random (probably based on which device turned on first?). So there is no way for me to do this in an automatic way. Every time after resume I have to manually go into the config and fix the order myself by trial and error.

Whenever the screen wakes up and the number behind the name has not increased, it seems the order also has not changed and it is the same device.

My Kernel version: 6.9.10-arch1-1 So even with 6.9 this definitely is still an issue.

Example before suspend:

        Touch Device at 5f326bff3830:
                wch.cn-touchscreen-1
        Touch Device at 5f326bfefe00:
                wch.cn-touchscreen-2
        Touch Device at 5f326bf96e40:
                wch.cn-touchscreen-3

Example after resume:

        Touch Device at 5f326c0923d0:
                wch.cn-touchscreen-1
        Touch Device at 5f326bfa2ee0:
                wch.cn-touchscreen-2
        Touch Device at 5f326c062d50:
                wch.cn-touchscreen-3

I should note that cn-touchscreen-1, -2 and -3 were the same devices before and after resume, despite the different id. The order is only randomised once they get a new name. While all IDs are different each time it wakes up, the first 5 characters are always identical (5f326), the last 7 characters are not.

This is my lsusb output for these devices:

Bus 001 Device 070: ID 27c0:0859 Cadwell Laboratories, Inc. TouchScreen
Bus 001 Device 071: ID 27c0:0859 Cadwell Laboratories, Inc. TouchScreen
Bus 001 Device 072: ID 27c0:0859 Cadwell Laboratories, Inc. TouchScreen

If I run libinput list-devices I get this for all 3, only difference is the kernel device path:

Device:           wch.cn TouchScreen
Kernel:           /dev/input/event15 # <- this is different, otherwise identical
Group:            5
Seat:             seat0, default
Size:             216x91mm
Capabilities:     touch
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      identity matrix
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Disable-w-trackpointing: n/a
Accel profiles:   n/a
Rotation:         0.0

If you need me to do more testing or provide further information to help nail down this issue, I am happy to support. Let me know what you want me to try out and I will do so :)

Could be very well a Wayland or Kernel issue as well, but I would not know how to verify that. I don't know where the id nor name that hyprctl devices returns is generated but presumably in hyprland, as I cannot find these names / IDs anywhere else in the system.