daitj / gnome-display-brightness-ddcutil

Display brightness slider for gnome shell using ddcutil backend
GNU General Public License v3.0
308 stars 38 forks source link

Race condition leading to no monitor when querying multiple monitors #87

Closed ailin-nemui closed 1 year ago

ailin-nemui commented 2 years ago

Describe the bug I have 2 monitors connected, but only 1 of them shows up in the menu. Even though both are in ddcutil detect

To Reproduce Steps to reproduce the behavior:

open the menu -> only 1 monitor is visible

Journal logs

journalctl --no-pager -b /usr/bin/gnome-shell
display-brightness-ddcutil extension:
Reloading widgets
display-brightness-ddcutil extension:
Reload extension
display-brightness-ddcutil extension:
Remove keyboard shortcuts
display-brightness-ddcutil extension:
Adding to panel
display-brightness-ddcutil extension:
Add keyboard shortcuts
display-brightness-ddcutil extension:
ddcutil brief info:
Invalid display
   I2C bus:          /dev/i2c-9
   DRM connector:    card1-eDP-1
   Monitor:          AUO::

Invalid display
   I2C bus:          /dev/i2c-11
   DRM connector:    card1-DP-2
   Monitor:          DEL:DELL U2412M:0FFXD3432J6L

Display 1
   I2C bus:          /dev/i2c-15
   DRM connector:    card1-DP-3
   Monitor:          DEL:DELL U2412M:0FFXD3432J6L

Display 2
   I2C bus:          /dev/i2c-16
   DRM connector:    card1-DP-4
   Monitor:          DEL:DELL U2412M:0FFXD4C41CUS

display-brightness-ddcutil extension:
ddcutil brief info found bus line:
    I2C bus:          /dev/i2c-9
display-brightness-ddcutil extension:
ddcutil reading display state for bus: 9
display-brightness-ddcutil extension:
ddcutil brief info found bus line:
    I2C bus:          /dev/i2c-11
display-brightness-ddcutil extension:
ddcutil reading display state for bus: 11
display-brightness-ddcutil extension:
ddcutil brief info found bus line:
    I2C bus:          /dev/i2c-15
display-brightness-ddcutil extension:
ddcutil reading display state for bus: 15
display-brightness-ddcutil extension:
ddcutil brief info found bus line:
    I2C bus:          /dev/i2c-16
display-brightness-ddcutil extension:
ddcutil reading display state for bus: 16
display-brightness-ddcutil extension:
ddcutil reading display status for bus: 11 is: DDC communication failed for monitor on bus /dev/i2c-11
display-brightness-ddcutil extension:
ddcutil reading display status for bus: 15 is: No monitor detected on bus /dev/i2c-15
display-brightness-ddcutil extension:
ddcutil reading display status for bus: 16 is: VCP D6 SNC x01
display-brightness-ddcutil extension:
ddcutil reading display status for bus: 9 is: DDC communication failed for monitor on bus /dev/i2c-9
display-brightness-ddcutil extension:
Reloading widgets

Screenshots image

Desktop (please complete the following information):

Additional context I could reproduce the issue in a shell: if I run this command

ddcutil getvcp --brief D6 --bus 15 & ddcutil getvcp --brief D6 --bus 16 &

I get most of the time, from either the one or the other monitor:

No monitor detected on bus /dev/i2c-15
VCP D6 SNC x01

or

No monitor detected on bus /dev/i2c-16
VCP D6 SNC x01

and sometimes

VCP D6 SNC x01
VCP D6 SNC x01

The extension seems to follow a similar path with the Convenience.spawnWithCallback in a loop. It might be better to run the getvcp commands sequentially instead, first waiting for the response. I could never evoke the "No monitor detected" when running

ddcutil getvcp --brief D6 --bus 15 ; ddcutil getvcp --brief D6 --bus 16 ;

i.e. ; instead of &

ailin-nemui commented 2 years ago

could be related to #86

spyfly commented 2 years ago

@ailin-nemui seems to be a duplicate of #86. I had the same symptoms as you, when running ddcutil manually in parallel and after each other.

Do you run the monitors in a Daisy-Chain Configuration? That's what it looks like to me, at least, from the ddcutil output.

daitj commented 1 year ago

I think you both have very similar issue, lets keep the discussion here.

I believe this is ddcutil issue rather than extension issue. Have you both checked this info about docking stations from ddcutil's faq? There are some similar issues like yours with docking station label in ddcutil's repo. I would suggest to create an issue in ddcutil's repo.

As a workaround may be you could create a ddcutil wrapper in your $HOME/bin/ddcutil (which should be in your path), which would check if there is /usr/bin/ddcutil running every second, then run a new /usr/bin/ddcutil only if no other processes were detected. You need to update this line change /usr/bin/ddcutil to ddcutil there.

In early days of extension I did try to use normal loop, the results were not that satisfactory, when you move the sliders and when the brightness was updated was not smooth at all, some unexpected error in one display would leave rest of the actions unperformed. So you will probably feel the same once you have that wrapper.

daitj commented 1 year ago

I have added a new advanced settings sleep multipler, may be if you have really low sleep multipler, the action will be done faster and you wont run into similar issue, could you give it a try? You can read about sleep multipler in Performance and Tuning Options section of the documentation.

Reopen the issue if needed.

spyfly commented 1 year ago

@daitj yes, this fixes the issue.

Thanks a lot :+1: Would be nice if you could publish a version for GNOME 42 (Ubuntu 22.04 LTS)

I built it myself by reverting the two GNOME 43 support commits.