Bug 487901

Summary: kwin_nightlight: Error in time calculation. Deactivating Night Light
Product: [Plasma] kwin Reporter: Iyán M. V. <me>
Component: night colorAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kde, nate
Priority: NOR    
Version First Reported In: git-stable-Plasma/6.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.1
Sentry Crash Report:
Attachments: Configuration Night Light

Description Iyán M. V. 2024-06-01 22:12:24 UTC
Created attachment 170054 [details]
Configuration Night Light

SUMMARY


STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT
After upgrading to Plasma 6.1 Beta I get this error message (visible with journalctl -p err):

kwin_wayland[1181]: kwin_nightlight: Error in time calculation. Deactivating Night Light.

But the night color seems to work just fine... The error happens always exactly one minute before the end of the transition duration.

I attach a screenshot with my configuration of the Night Light. So in my case, I configured the to change the color at 22:30 for 30 mins, and the error happened at 22:29:59.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.90
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1
Kernel Version: 6.9.3-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 7900X3D 12-Core Processor
Memory: 93.5 GiB of RAM
Graphics Processor: AMD Radeon RX 7900 XT
Manufacturer: ASUS
Comment 1 Iyán M. V. 2024-06-01 22:13:27 UTC
Sorry, for the wrong formatting of the report. I copy-paste from my notes directly in the observed result section...
Comment 2 Vlad Zahorodnii 2024-06-07 07:48:16 UTC
I cannot reproduce it. I set the transition time as in the screenshot and then used "sudo timedatectl set-time 22:29" and waited until the time crosses 22:30.

What's your timezone?
Comment 3 David Edmundson 2024-06-07 08:02:43 UTC
Waiting for info on timezone
Comment 4 Vlad Zahorodnii 2024-06-07 08:10:11 UTC
Nvm, I've found a way to reproduce it. In my case, the error occurs at the start of the transition
Comment 5 Bug Janitor Service 2024-06-07 08:43:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5851
Comment 6 Iyán M. V. 2024-06-07 09:21:04 UTC
Hi Vlad,

I use /usr/share/zoneinfo/Europe/Zurich
Comment 7 Vlad Zahorodnii 2024-06-07 15:26:37 UTC
Git commit 83502e29a94c5972787357f3c5995697b5715304 by Vlad Zahorodnii.
Committed on 07/06/2024 at 15:16.
Pushed by vladz into branch 'master'.

plugins/nightlight: Fix current time changing after updating transitions

When the slow update timer fires, it's going to pass m_next.first as the
current time in order to calculate the next transition timings. After
the timings have been calculated, the slow update timer will be started
with an interval of "todayNow.msecsTo(m_next.first)". Since todayNow
is a reference to m_next.first, the time diff will be 0, which will
throw off the night light manager. To fix that, make a copy of m_next.first
and then pass the copy as the current date time to resetSlowUpdateTimers().

M  +2    -1    src/plugins/nightlight/nightlightmanager.cpp

https://invent.kde.org/plasma/kwin/-/commit/83502e29a94c5972787357f3c5995697b5715304
Comment 8 Vlad Zahorodnii 2024-06-07 15:36:55 UTC
Git commit 35b3fc0bb1b59423fedb7a4a45603418c20a8881 by Vlad Zahorodnii.
Committed on 07/06/2024 at 15:27.
Pushed by vladz into branch 'Plasma/6.1'.

plugins/nightlight: Fix current time changing after updating transitions

When the slow update timer fires, it's going to pass m_next.first as the
current time in order to calculate the next transition timings. After
the timings have been calculated, the slow update timer will be started
with an interval of "todayNow.msecsTo(m_next.first)". Since todayNow
is a reference to m_next.first, the time diff will be 0, which will
throw off the night light manager. To fix that, make a copy of m_next.first
and then pass the copy as the current date time to resetSlowUpdateTimers().


(cherry picked from commit 83502e29a94c5972787357f3c5995697b5715304)

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>

M  +2    -1    src/plugins/nightlight/nightlightmanager.cpp

https://invent.kde.org/plasma/kwin/-/commit/35b3fc0bb1b59423fedb7a4a45603418c20a8881