Bug 493329 - Monitors attached after startup do not appear in the brightness applet unless Powerdevil is manually restarted (X11)
Summary: Monitors attached after startup do not appear in the brightness applet unless...
Status: RESOLVED WORKSFORME
Alias: None
Product: Powerdevil
Classification: Plasma
Component: general (show other bugs)
Version: 6.1.90
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-18 16:35 UTC by Tim Schneeberger
Modified: 2024-11-14 03:46 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Schneeberger 2024-09-18 16:35:23 UTC
SUMMARY
I'm using a laptop running the Plasma 6.2 beta and occasionally connect an external 4K monitor with DDC support to it.

I noticed that if I connect the monitor after startup, the brightness applet does not list it.
If the monitor is connected during boot time, the brightness applet shows it as expected until I disconnect and reconnect it later.

By restarting powerdevil (`killall org_kde_powerdevil; kstart /usr/lib/org_kde_powerdevil`) manually, after the new monitor has been connected, it correctly appears in the applet as expected.

STEPS TO REPRODUCE
1. Attach a secondary monitor with DDC support after Plasma & Powerdevil has launched
2. Connected monitor does not appear in the brightness applet 

OBSERVED RESULT
Only the internal laptop screen is listed in the applet. The other monitor is missing.

EXPECTED RESULT
The external monitor should be listed in the applet after plugging it in.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux using the `kde-unstable` package repo
KDE Plasma Version: 6.1.90
KDE Frameworks Version: 6.6.0
Qt Version: 6.8.0

ADDITIONAL INFORMATION
Apart from detecting new monitors, the applet also doesn't detect whether a monitor has been removed.
For example, if I disconnect my external monitor, the brightness applet continues to list it even though it is no longer present.

Only when I attempt to move its brightness slider in the applet, does Powerdevil seem to realize that the monitor is missing and remove it from the list.
Comment 1 Tim Schneeberger 2024-09-18 16:58:06 UTC
I forgot to mention that I use X11.

Also, Powerdevil doesn't produce any logs when disconnecting or connecting the monitor.
Comment 2 Marco Martin 2024-09-19 11:02:02 UTC Comment hidden (spam)
Comment 3 Marco Martin 2024-09-19 11:05:07 UTC Comment hidden (spam)
Comment 4 Jakob Petsovits 2024-10-14 23:03:36 UTC
Git commit 44e6922ae9f06a3e2fa3e7640be7eb32591cd579 by Jakob Petsovits.
Committed on 14/10/2024 at 22:36.
Pushed by jpetso into branch 'master'.

daemon: Retry failed DDC/CI reads and writes repeatedly

DDC/CI communication with monitors can be unreliable,
especially when the monitor is still in the process of
fully waking up. The moment that we receive a connection
or DPMS awake event may not be the moment that brightness
commands start working.

Prior to this commit, `DDCutilDisplay` protected itself against
this case with a drastic measure: if a read or write command
failed, the object would claim brightness controls as
unsupported. This error condition meant that we won't end up
with inconsistent state, but it also makes the monitor's
brightness slider go away (or fall back to software
brightness controls if KWin wants those instead).

This commit still uses the same failure mode, but will try
harder before we give up on the monitor altogether.
Both initialization (reading the initial brightness value)
and `setBrightness()` will now retry a few times if the
first attempt didn't work out. Subsequent retries will be
spaced out further, until we finally give up on that monitor.

To avoid exposing uninitialized `DDCutilDisplay` objects,
a list of pending displays now holds these objects while
they're waiting for another initialization attempt.

`setBrightness()` will only be performed once initialization
has succeeded, so the two operations are mutually exclusive.
We can reuse DDCutilDisplay's existing brightness delay timer
for both kinds of retry operations.
Related: bug 482713

M  +23   -11   daemon/controllers/ddcutildetector.cpp
M  +69   -15   daemon/controllers/ddcutildisplay.cpp
M  +8    -2    daemon/controllers/ddcutildisplay.h

https://invent.kde.org/plasma/powerdevil/-/commit/44e6922ae9f06a3e2fa3e7640be7eb32591cd579
Comment 5 Jakob Petsovits 2024-10-14 23:07:33 UTC
Git commit 48453745b1cfb0fce66e16ec9ef8caf961e79677 by Jakob Petsovits.
Committed on 14/10/2024 at 23:04.
Pushed by jpetso into branch 'Plasma/6.2'.

daemon: Retry failed DDC/CI reads and writes repeatedly

DDC/CI communication with monitors can be unreliable,
especially when the monitor is still in the process of
fully waking up. The moment that we receive a connection
or DPMS awake event may not be the moment that brightness
commands start working.

Prior to this commit, `DDCutilDisplay` protected itself against
this case with a drastic measure: if a read or write command
failed, the object would claim brightness controls as
unsupported. This error condition meant that we won't end up
with inconsistent state, but it also makes the monitor's
brightness slider go away (or fall back to software
brightness controls if KWin wants those instead).

This commit still uses the same failure mode, but will try
harder before we give up on the monitor altogether.
Both initialization (reading the initial brightness value)
and `setBrightness()` will now retry a few times if the
first attempt didn't work out. Subsequent retries will be
spaced out further, until we finally give up on that monitor.

To avoid exposing uninitialized `DDCutilDisplay` objects,
a list of pending displays now holds these objects while
they're waiting for another initialization attempt.

`setBrightness()` will only be performed once initialization
has succeeded, so the two operations are mutually exclusive.
We can reuse DDCutilDisplay's existing brightness delay timer
for both kinds of retry operations.
Related: bug 482713


(cherry picked from commit 44e6922ae9f06a3e2fa3e7640be7eb32591cd579)

Co-authored-by: Jakob Petsovits <jpetso@petsovits.com>

M  +23   -11   daemon/controllers/ddcutildetector.cpp
M  +69   -15   daemon/controllers/ddcutildisplay.cpp
M  +8    -2    daemon/controllers/ddcutildisplay.h

https://invent.kde.org/plasma/powerdevil/-/commit/48453745b1cfb0fce66e16ec9ef8caf961e79677
Comment 6 Jakob Petsovits 2024-10-15 00:05:47 UTC
Hi Tim, thanks for reporting this. I can't quite say whether the above commit will fix your issue, but I hope it does. Please test again with Plasma 6.2.1 and let me know if that did anything for you. Cheers!

You've already been testing the beta so I'll assume that you can get a hold of 6.2.1 relatively quickly, so I'll set this to WAITINGFORINFO. Please set it back in case your issue still persists.

(On a different note, PowerDevil does have extra log output, but you may have to enable verbose logging first in order to see it. Check out https://invent.kde.org/plasma/powerdevil/-/blob/master/README.md for more details on how to do this.)
Comment 7 Bug Janitor Service 2024-10-30 03:46:53 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Bug Janitor Service 2024-11-14 03:46:47 UTC
๐Ÿ›๐Ÿงน This bug has been in NEEDSINFO status with no change for at least 30 days. Closing as RESOLVED WORKSFORME.