Dark mode activates automatically based on your systemâs mode, and can be enabled manually otherwise, using the button to the left of your profile picture
Hello, Iâm coming back to this topic because for some time (a lot?) Iâve had more than strange behavior with the light/dark mode.
Knowing that Iâm not a big fan of dark mode in general (except in a good old terminal with green letters ), my phone (iOS) is always in light mode, no automatic switching enabled.
And yet, when I launch Gladys or GladysPlus, more than half the time I end up with dark mode as the default display, and I must admit that itâs annoying (for me) to switch back to light mode each time.
Important point: this never happens on my Mac with Firefox.
On iOS Safari / PWA / Gladys Plus, WebKit is known to emit spurious prefers-color-scheme events (background return, tab change, etc.), sometimes with an incorrect value. This explains:
the intermittent behavior (âmore than half the timeâ)
the absence of the issue on Firefox macOS (more stable behavior)
the fact that the user has to switch back to light mode each time
Other possible factors (in addition)
Loss of localStorage on iOS (memory pressure, 7 days without a visit) â return to âfollow systemâ mode
Site settings in Safari: Settings â Safari â Advanced â âWebsite Appearanceâ can force dark mode for a domain
Gladys Plus in WebView: may have different behavior than classic Safari
The logic is: if localStorage contains the key dark-mode, we use it. Otherwise, we read prefers-color-scheme.
The bug is here in updateDarkModeFromSystem:
This function reads prefers-color-scheme at the wrong time (during the launch of the PWA on iOS where the value may be unstable) and saves the result in localStorage. Result: dark-mode = true gets recorded, and on the next launch, Gladys reads the localStorage key and applies dark mode, even if your system is in light mode.
This is a real bug. The right issue to open would be: updateDarkModeFromSystem should not overwrite localStorage when the user already has an explicit choice â or this function should not be called at all if a user preference is already saved.