Bug 487118

Summary: The Power Management applet displays incorrect description of effects of org.freedesktop.portal.Inhibit
Product: [Plasma] plasmashell Reporter: Wyatt Childers <kdebugs.81do7>
Component: Battery MonitorAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal CC: emil.vanherp, kde, kdebugs.81do7, me, natalie_clarius, nate
Priority: NOR    
Version: 6.0.4   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Wyatt Childers 2024-05-16 20:02:21 UTC
SUMMARY
The Plasma Power Management applet incorrectly displays that sleep and screen locking are disabled when org.freedesktop.portal.Inhibit is used.

STEPS TO REPRODUCE
1. Run an affected application like Firefox or Moonlight that send only org.freedesktop.portal.Inhibit and not org.freedesktop.ScreenSaver

OBSERVED RESULT
The UI reports that sleep and screen locking is blocked.

EXPECTED RESULT
The UI reports that sleep is blocked/the description of what's blocked is accurate (as Plasma does not block screen locking  without org.freedesktop.ScreenSaver).

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 40
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.0
Kernel Version: 6.8.9-300.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 7950X 16-Core Processor
Memory: 61.9 GiB of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Manufacturer: ASUS

ADDITIONAL INFORMATION
See Bug 485376 for some prior conversation.
Comment 1 Emil 2024-07-30 20:37:16 UTC
Is this not a bug in kscreenlocker? 

If I'm not mistaken the logic which correctly detects the inhibition in the battery monitor is here:

https://invent.kde.org/plasma/powerdevil/-/blob/master/applets/batterymonitor/plugin/powermanagementcontrol.cpp

But kscreensaver fails to detect that the screen has to be locked:

https://invent.kde.org/plasma/kscreenlocker/-/blob/master/powermanagement_inhibition.cpp
Comment 2 Emil 2024-07-30 20:52:11 UTC
If  org.freedesktop.portal.Inhibit is used with Firefox in Flatpak I see this with dbus-monitor
>signal time=1722369868.405491 sender=org.freedesktop.DBus -> destination=:1.1401 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
>   string ":1.1401"
>signal time=1722369868.405515 sender=org.freedesktop.DBus -> destination=:1.1401 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
>   string ":1.1401"
>method call time=1722369869.908031 sender=:1.544 -> destination=org.kde.Solid.PowerManagement serial=13724 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=AddInhibition
>   uint32 1
>   string "org.mozilla.firefox"
>   string "video-playing"
>signal time=1722369874.825363 sender=:1.545 -> destination=(null destination) serial=9434 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=InhibitionsChanged
>   array [
>      struct {
>         string "org.mozilla.firefox"
>         string "video-playing"
>      }
>   ]
>   array [
>   ]
>method call time=1722369874.825737 sender=:1.515 -> destination=org.kde.Solid.PowerManagement.PolicyAgent serial=4342 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=HasInhibition
>   uint32 4
>method call time=1722369874.827273 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=304963 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions
>method call time=1722369874.827313 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=304964 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions
>method call time=1722369877.280859 sender=:1.544 -> destination=org.kde.Solid.PowerManagement serial=13727 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ReleaseInhibition
>   uint32 920
>signal time=1722369877.281258 sender=:1.545 -> destination=(null destination) serial=9439 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=InhibitionsChanged
>   array [
>   ]
>   array [
>      string "org.mozilla.firefox"
>   ]
>method call time=1722369877.281461 sender=:1.515 -> destination=org.kde.Solid.PowerManagement.PolicyAgent serial=4343 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=HasInhibition
>   uint32 4
>method call time=1722369877.281671 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=304966 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions
>method call time=1722369877.281676 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=304967 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions

In the case of Firefox without Flatpak (using org.freedesktop.ScreenSaver it seems) I see this:

>>signal time=1722370014.376410 sender=org.freedesktop.DBus -> destination=:1.1405 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
>   string ":1.1405"
>signal time=1722370014.376428 sender=org.freedesktop.DBus -> destination=:1.1405 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
>   string ":1.1405"
>method call time=1722370017.317112 sender=:1.515 -> destination=org.kde.Solid.PowerManagement.PolicyAgent serial=4408 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=AddInhibition
>   uint32 4
>   string "firefox"
>   string "video-playing"
>signal time=1722370022.072171 sender=:1.545 -> destination=(null destination) serial=9486 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=InhibitionsChanged
>   array [
>      struct {
>         string "firefox"
>         string "video-playing"
>      }
>   ]
>   array [
>   ]
>method call time=1722370022.072447 sender=:1.515 -> destination=org.kde.Solid.PowerManagement.PolicyAgent serial=4410 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=HasInhibition
>   uint32 4
>method call time=1722370022.072457 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=305042 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions
>method call time=1722370022.072463 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=305043 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions
>method call time=1722370022.168754 sender=:1.515 -> destination=org.kde.Solid.PowerManagement.PolicyAgent serial=4411 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ReleaseInhibition
>   uint32 924
>signal time=1722370022.169080 sender=:1.545 -> destination=(null destination) serial=9491 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=InhibitionsChanged
>   array [
>   ]
>   array [
>      string "firefox"
>   ]
>method call time=1722370022.169252 sender=:1.515 -> destination=org.kde.Solid.PowerManagement.PolicyAgent serial=4413 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=HasInhibition
>   uint32 4
>method call time=1722370022.169629 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=305045 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions
>method call time=1722370022.169645 sender=:1.535 -> destination=org.kde.Solid.PowerManagement serial=305046 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ListInhibitions

The only difference I can see is AddInhibition with 4 vs 1.
Comment 3 Wyatt Childers 2024-07-30 23:56:40 UTC
(In reply to Emil from comment #1)
> Is this not a bug in kscreenlocker? 
> 
> If I'm not mistaken the logic which correctly detects the inhibition in the
> battery monitor is here:
> 
> https://invent.kde.org/plasma/powerdevil/-/blob/master/applets/
> batterymonitor/plugin/powermanagementcontrol.cpp
> 
> But kscreensaver fails to detect that the screen has to be locked:
> 
> https://invent.kde.org/plasma/kscreenlocker/-/blob/master/
> powermanagement_inhibition.cpp

Does the applet depend on kscreenlocker somehow?
Comment 4 Emil 2024-07-31 07:57:51 UTC
(In reply to Wyatt Childers from comment #3)
> (In reply to Emil from comment #1)
> > Is this not a bug in kscreenlocker? 
> > 
> > If I'm not mistaken the logic which correctly detects the inhibition in the
> > battery monitor is here:
> > 
> > https://invent.kde.org/plasma/powerdevil/-/blob/master/applets/
> > batterymonitor/plugin/powermanagementcontrol.cpp
> > 
> > But kscreensaver fails to detect that the screen has to be locked:
> > 
> > https://invent.kde.org/plasma/kscreenlocker/-/blob/master/
> > powermanagement_inhibition.cpp
> 
> Does the applet depend on kscreenlocker somehow?

No, but if I understand the bug report correctly (and how I experience it) the applet does correctly indicate that screen locking *should* be blocked. Which means it's a bug in kscreenlocker that should also block with org.freedesktop.portal.Inhibit
Comment 5 Wyatt Childers 2024-07-31 17:19:37 UTC
(In reply to Emil from comment #4)
> (In reply to Wyatt Childers from comment #3)
> > (In reply to Emil from comment #1)
> > > Is this not a bug in kscreenlocker? 
> > > 
> > > If I'm not mistaken the logic which correctly detects the inhibition in the
> > > battery monitor is here:
> > > 
> > > https://invent.kde.org/plasma/powerdevil/-/blob/master/applets/
> > > batterymonitor/plugin/powermanagementcontrol.cpp
> > > 
> > > But kscreensaver fails to detect that the screen has to be locked:
> > > 
> > > https://invent.kde.org/plasma/kscreenlocker/-/blob/master/
> > > powermanagement_inhibition.cpp
> > 
> > Does the applet depend on kscreenlocker somehow?
> 
> No, but if I understand the bug report correctly (and how I experience it)
> the applet does correctly indicate that screen locking *should* be blocked.
> Which means it's a bug in kscreenlocker that should also block with
> org.freedesktop.portal.Inhibit

Nate Graham was quite adamant in the Bug 485376 that the power management behavior is right but the applet is wrong.

I don't agree with him (https://bugs.kde.org/show_bug.cgi?id=485376#c15), but none the less I filed this bug to request that Plasma at least be consistent by displaying what it's doing. So no, this is not the bug you're looking for. You may want to leave a comment in Bug 485376.
Comment 6 Nate Graham 2024-07-31 18:15:16 UTC
You were right all along. But that bug was actually just fixed today. See Bug 486506.

With that fixed, I'm not sure if there's anything else to do for this issue specifically, or if all that's left of it is covered by Bug 418433.
Comment 7 Wyatt Childers 2024-07-31 18:20:57 UTC
(In reply to Nate Graham from comment #6)
> You were right all along. But that bug was actually just fixed today. See
> Bug 486506.
> 
> With that fixed, I'm not sure if there's anything else to do for this issue
> specifically, or if all that's left of it is covered by Bug 418433.

Great! Let's assume Bug 418433 will take care of any remaining discrepancies.

*** This bug has been marked as a duplicate of bug 418433 ***
Comment 8 Nate Graham 2024-07-31 18:23:46 UTC
Indeed!