Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeePassXC doesn't properly switch between light and dark appearance on macOS #7615

Closed
le-jawa opened this issue Mar 23, 2022 · 15 comments · Fixed by #8615
Closed

KeePassXC doesn't properly switch between light and dark appearance on macOS #7615

le-jawa opened this issue Mar 23, 2022 · 15 comments · Fixed by #8615

Comments

@le-jawa
Copy link

le-jawa commented Mar 23, 2022

Overview

I've experienced a problem with KeePassXC on Macs (currently macOS 12) with the appearance set to change automatically. If I run KeePassXC during the day (light appearance) and keep it running until after the appearance switches to dark, then the next morning (light again) KeePassXC will display with a mix of light and dark elements.

Steps to Reproduce

  1. Turn on automatic appearance switching on your Mac (macOS 10.15 or higher required)
  2. Run KeePassXC during the day (light appearance) and leave it running until after the appearance switches to dark.
  3. Shut down the Mac.
  4. The next morning (light appearance) boot the Mac and open KeePassXC. The interface will be a mix of light and dark elements.

Expected Behavior

KeePassXC will switch between light and dark appearances flawlessly.

Actual Behavior

The interface is a mix of light and dark elements when going to light appearance after KeePassXC has been running during the day and into the night, and then again the next morning.

Context

This has happened since automatic appearance switching support was added in KeePassXC 2.6.4.
I've been able to work around the issue by manually switching my Mac appearance to "Light", then back to "Auto".

KeePassXC - VERSION 2.7.0
Revision: d7a9ef4

Operating System: macOS

Screen Shot 2022-03-23 at 09 07 31
Screen Shot 2022-03-23 at 09 07 57

@le-jawa le-jawa added the bug label Mar 23, 2022
@droidmonkey
Copy link
Member

droidmonkey commented Mar 23, 2022

Cannot reproduce this.

2022-03-23_10-45-51

This is both 2.6.6 and 2.7.0.

@le-jawa
Copy link
Author

le-jawa commented Mar 23, 2022

My work-around for the problem is to use General Settings applet; that "fixes" it, not causes it. The only time I see this is when I do as reported above. I realize that's a pretty long cycle for bug testing/reproduction, but that is when/how I encounter it.

I'll do some additional testing to see if I can find other avenues for reproduction, and will test on an additional Mac. If I can find something that either shortens or clarifies the steps to reproduce, I'll post it here.

@varjolintu
Copy link
Member

The isDarkTheme() check needs an extra check for the new Auto value. It should be a small fix. Testing it soon.

@phoerious
Copy link
Member

I have used KeePassXC on macOS with auto theme switching for a long time and it has always worked perfectly.

@varjolintu
Copy link
Member

@phoerious Including steps 3 and 4 where you shutdown you computer when the theme is dark and then boot back when it's already turned light?

@phoerious
Copy link
Member

phoerious commented Mar 24, 2022

I haven't tried that, but it should send the same signals. Although I would consider it a real edge case. If you really shut down your Mac, it should restart KeePassXC on boot. Are you just putting your Mac in hibernate mode?

@varjolintu
Copy link
Member

varjolintu commented Mar 24, 2022

Here's an example in Swift how it's a bit different from the old Mojave implementation. The example doesn't check for the Auto value though.
https://github.com/ruiaureliano/macOS-Appearance/blob/master/Appearance/Source/AppDelegate.swift

@le-jawa
Copy link
Author

le-jawa commented Mar 25, 2022

Reproduced on my personal laptop last night and this morning. (The other is my work laptop.) Interesting, the screen shots didn't capture the "about" boxes. That's 2.6.6. and 2.7.0.

Since this is reproducible and it does appear to be a bug, can we re-label this a bug and remove the "not reproducible" label?

Screen Shot 2022-03-25 at 13 04 23

Screen Shot 2022-03-25 at 12 36 43

@droidmonkey
Copy link
Member

How did you reproduce it? The wait 12 hours while asleep method?

@le-jawa
Copy link
Author

le-jawa commented Mar 25, 2022

That depends on who's doing the sleeping. ;-)

I did just what I noted in the original report. I first saw this on my work laptop, and the steps to recreate this are fairly normal routine for me.

  1. I had appearance auto-switching on (it always is).
  2. I started my workday during daylight hours, and the light appearance was, of course, on. I loaded KeePassXC, along with my other work apps and got to work. In order to re-test this, I also started my personal laptop during the day, and opened KeePassXC. I left my personal laptop (MacBook Pro) running all day.
  3. That day happened to be a long one, so my laptop was still running, and KeePassXC open, when it got late, and my MacBook Air (my work laptop) switched from light to dark appearance. KeePassXC successfully switched with it. The same happened on my MacBook Pro.
  4. After I was done for the evening, I let my Air go to sleep, and shutdown my Pro.
  5. The next morning, I woke up my Air and KeePassXC had successfully switched back to the light appearance (the behavior you're seeing). When I booted my Pro, on the other hand, and started KeePassXC (both 2.6.6 and 2.7.0) it started with the mashup of the light and dark appearance you see in the screen shots above. To get you the screenshots from my Air (the ones from the original report) I had shutdown my Air at night and restarted it the next morning.

Bottom line, you have to shut it down after the everything switches to the dark appearance, not put it to sleep.

This is common routine for me, so I don't "consider it a real edge case". I have a hard time believing that Mac owners who are also KeePassXC users don't go through a similar routine and encounter the same issue.

@michaelk83
Copy link

michaelk83 commented Mar 26, 2022

@le-jawa can you reduce the test cycle by adjusting the transition schedule? So it would take 1-2 minutes or so?

@andkopp
Copy link

andkopp commented Jul 4, 2022

I have the same bug running macOS Monterey (12.4) and KeePassXC 2.7.1. Auto-switching is on. Normally my Macbook runs for weeks without shutting down. And like @le-jawa the first time I experienced this was when I had shutdown my Macbook Pro 16" in the evening (dark mode) and started it again in the morning - at the Apple Store for diagnostics. I didn't login there. First login was in the evening (dark mode again) and then I also got the mixed representation.

@opa334
Copy link
Contributor

opa334 commented Oct 22, 2022

The issue is that there is a macOS bug where the AppleInterfaceStyle key in .GlobalPreferences.plist doesn't change when the system is shut down while the "automatic transition" happens, I have fixed this issue by not relying on that key for dark mode detection and will submit a PR shortly.

opa334 added a commit to opa334/keepassxc that referenced this issue Oct 22, 2022
…e key for dark mode detection, as it's not always correct
@pablosavigne
Copy link

Same issue MacOS 13.1 M1, just switch appearance to auto in Mac, and shutdown by night, and the next day will load in mixed dark. I'm changing this manually, since I installed the app!

@j-lakeman
Copy link

Can reproduce on macOS 11.6.8 Big Sur with KeepassXC 2.7.4 from Homebrew.

@keepassxreboot keepassxreboot locked and limited conversation to collaborators Jan 14, 2023
droidmonkey pushed a commit that referenced this issue Jan 30, 2023
* Fix #7615 - Don't rely on AppleInterfaceStyle preference key for dark mode detection, as it's not always correct
dmaslenko pushed a commit to dmaslenko/keepassxc that referenced this issue Jan 30, 2023
…#8615)

* Fix keepassxreboot#7615 - Don't rely on AppleInterfaceStyle preference key for dark mode detection, as it's not always correct
pull bot pushed a commit to tigerwill90/keepassxc that referenced this issue Jan 30, 2023
…#8615)

* Fix keepassxreboot#7615 - Don't rely on AppleInterfaceStyle preference key for dark mode detection, as it's not always correct
pull bot pushed a commit to contropist/keepassxc that referenced this issue Jan 30, 2023
…#8615)

* Fix keepassxreboot#7615 - Don't rely on AppleInterfaceStyle preference key for dark mode detection, as it's not always correct
droidmonkey pushed a commit that referenced this issue Feb 18, 2023
* Fix #7615 - Don't rely on AppleInterfaceStyle preference key for dark mode detection, as it's not always correct
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants