waydabber / BetterDisplay

Unlock your displays on your Mac! Flexible HiDPI scaling, XDR/HDR extra brightness, virtual screens, DDC control, extra dimming, PIP/streaming, EDID override and lots more!
https://betterdisplay.pro
18.97k stars 336 forks source link

App fails to reapply last set DDC value on wake when `Reapply DDC settings on wake` is enabled (for displays that forget DDC settings on sleep) #3350

Closed thekoc closed 3 weeks ago

thekoc commented 4 weeks ago

Hi, here is a test build with these features. I added an UI to change wake and config delays as well (under Application/Advanced).

https://github.com/waydabber/BetterDisplay/releases/download/v2.0.0-pre-release/BetterDisplay-v2.3.4-b30036-pre.zip

Hi, I have latest version (3.0.4) and set the Additional delay after wake to reapply DDC settings to be 10 seconds but still the problem exists. Upon wake up, the display forgets its brightness and BetterDisplay failed to restore the values.

At this point, if I manually change the value, it works. If I quite the app and reopen it, it works.

Could you please have an another look at this issue?

CleanShot-2024-08-26@00 59 08@2x

My monitor model: AOC U27U2DS

Originally posted by @thekoc in https://github.com/waydabber/BetterDisplay/issues/2962#issuecomment-2308927793

thekoc commented 4 weeks ago

I tested manually setting the brightness via command line interface after the wake up:

/Applications/BetterDisplay.app/Contents/MacOS/BetterDisplay set --name=U27U2G6R4B --brightness=1.0

This command does nothing. If I read the value:

/Applications/BetterDisplay.app/Contents/MacOS/BetterDisplay get --name=U27U2G6R4B --brightness

This reads 1.0, my screen (in reality) is a lot dimmer than that however.

But If I set the value to 0.99, then 1.0, the brightness finally applies. Not sure if this causes the problem.

waydabber commented 4 weeks ago

Can you try setting the brightness with a direct brightness DDC command before sleep to 50 (or some other value you know the display does not remember) and then after wake again to 50 (for the sake of testing, set the startup setting back to "assume valid")? It might be that the display board actually remembers the setting but only the panel forgets it, and the board getting the value it currently thinks is the current one, it does not apply it even though the app sends the command.

If this is the case, then the display needs a very special treatment - setting a different value first, then resetting the proper value.

Let me know of the result! Thank you!

thekoc commented 4 weeks ago

Can you try setting the brightness with a direct brightness DDC command before sleep to 50 (or some other value you know the display does not remember) and then after wake again to 50 (for the sake of testing, set the startup setting back to "assume valid")? It might be that the display board actually remembers the setting but only the panel forgets it, and the board getting the value it currently thinks is the current one, it does not apply it even though the app sends the command.

If this is the case, then the display needs a very special treatment - setting a different value first, then resetting the proper value.

Let me know of the result! Thank you!

  1. Select Assume last used or default values are valid and turn off Reapply DCC settings on wake.
  2. Set the brightness to minimum through monitor's native OSD menu.
  3. Set the brightness to 1.0 through command: /Applications/BetterDisplay.app/Contents/MacOS/BetterDisplay set --name=U27U2G6R4B --brightness=1.0
  4. Sleep the mac.
  5. Upon wake up, the brightness falls back to the minimum level as set in the OSD menu.
  6. run /Applications/BetterDisplay.app/Contents/MacOS/BetterDisplay set --name=U27U2G6R4B --brightness=1.0 again.
  7. The brightness remains unchanged.
  8. run /Applications/BetterDisplay.app/Contents/MacOS/BetterDisplay set --name=U27U2G6R4B --brightness=0.99
  9. The brightness goes up significantly.
  10. Do all below again, expect:
    1. Select Write last used values to display.
    2. Upon wake up, instead of running commands, quit and reopen BetterDisplay.
    3. The brightness changed to 1.0 correctly.
waydabber commented 4 weeks ago

Sorry, I meant to use direct DDC, like

./BetterDisplay set -n=u27 -ddc=80 -vcp=brightness

for 80% brightness for example. This skips the managed brightness control (sliders won't update either) and directly talks to the display.

waydabber commented 4 weeks ago

But now I went through all the code and I see an optimization issue, meaning the app simply won't send the DDC brightness command if it thinks this is the same as the last one sent (to avoid excessive communication). This however prevents restoring the last set value. I'll now add a time limit there so this optimization won't take place beyond a second or so for example. So this is most probably a BetterDisplay bug that prevents the entire feature to work as intended. :)

waydabber commented 4 weeks ago

Added an update with the possible fix, please check if it works. Enable app Settings > Application > Updates > Receive pre-Release… and then also Receive internal pre-Release….

thekoc commented 4 weeks ago

Added an update with the possible fix, please check if it works. Enable app Settings > Application > Updates > Receive pre-Release… and then also Receive internal pre-Release….

Thanks a a lot! I’m deeply impressed by your efficiency 😮

thekoc commented 3 weeks ago

Added an update with the possible fix, please check if it works. Enable app Settings > Application > Updates > Receive pre-Release… and then also Receive internal pre-Release….

Hi, I've tested the new version and the problem seems to be resolved 🎉.

waydabber commented 3 weeks ago

Thank you!