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
20.45k stars 350 forks source link

Apple HW control might not be detected properly when connecting an LG-Apple display #3213

Closed julioromano closed 3 months ago

julioromano commented 3 months ago

HW Configuration:

SW Configuration:

Steps to reproduce:

Quitting and reopening BetterDisplay fixes it and makes it recognize also the second display as having Apple HW Control.

Screenshots before restarting BetterDisplay:

before1 before2

Screenshots after restarting BetterDisplay:

after1 after2
waydabber commented 3 months ago

This is not right indeed.

julioromano commented 3 months ago

This is not right indeed.

  • How are displays connected? Thunderbolt (directly to the MBP)

  • Does it matter in how quick succession, in what order and into what ports are you connecting the two displays? If I connect them in a slow succession it's always the second one that is not detected properly. If I connect them in quick succession at times both are not detected properly.

  • Does it get fixed if you use Tools/Displays.../Redetect? It does! Didn't know about this, thanks!

waydabber commented 3 months ago

Hi, can you try increasing configuration delay to 2 seconds from the default 0.2 seconds? Does this fix the issue? If so, can you try lowering the configuration delay to 1.0 seconds then to 0.5 seconds and see which is the lowest value that still performs properly?

The reason might be that the display's capabilities are not properly configured by the system and the app is trying to determine native brightness control too soon (it's just a guess).

Screenshot 2024-07-24 at 16 50 09

Thank you!

julioromano commented 3 months ago

Hi, can you try increasing configuration delay to 2 seconds from the default 0.2 seconds? Does this fix the issue? If so, can you try lowering the configuration delay to 1.0 seconds then to 0.5 seconds and see which is the lowest value that still performs properly?

The reason might be that the display's capabilities are not properly configured by the system and the app is trying to determine native brightness control too soon (it's just a guess).

Screenshot 2024-07-24 at 16 50 09

Thank you!

I've tried with 2 secs and It worked once, but then at the second try it failed again.

waydabber commented 3 months ago

Hmm. I see. If only one display is connected, it works reliably? I am not entirely sure what could be the issue. I can add an option to always use Apple control for a display though (this will work if the display is otherwise correctly identified - it's UUID is not changing erratically, you can check this under Display Information...).

julioromano commented 3 months ago

Hmm. I see. If only one display is connected, it works reliably? I am not entirely sure what could be the issue. I can add an option to always use Apple control for a display though (this will work if the display is otherwise correctly identified - it's UUID is not changing erratically, you can check this under Display Information...).

Yes with only one display it seems reliable. If you'd add such an option II'll gladly test it out. Though in the past these same displays had issues with erratically changing display info... (see: https://github.com/MonitorControl/MonitorControl/discussions/1384 )

waydabber commented 3 months ago

It would be educational to see app logs to figure out why the two displays are conflated and maybe you can send over the config file of the app by exporting it: https://github.com/waydabber/BetterDisplay/wiki/Export-and-import-app-settings

You can start the app with the following command to log to Terminal:

/Applications/BetterDisplay.app/Contents/MacOS/BetterDisplay -v

You should start the app so the two displays are properly show up, then disconnect and reconnect displays and then close the app.

You can copy the log text from the beginning to the end to a text file and send it over.

You can of course directly log to a text file in terminal as usual (add>log.txt to the end of the command) if you wish.

julioromano commented 3 months ago

Done, can I send them over privately to avoid leaking any PII?

waydabber commented 3 months ago

Sure, just contact me on the app's Discord channel (you can send a DM).

waydabber commented 3 months ago

I got the logs. I am somewhat at loss analyzing them though. :) Can you briefly describe exactly what happened and when? In what sequence did you disconnect and reconnect the display in (approximately) what time intervals? Thank you!

julioromano commented 3 months ago

Exactly as you asked: I got both displays connected and working properly with the app closed. Then launched the app to grab the logs. Waited some time then disconnected both display at the same time. Then waited some more time and reconnected the first display. Then waited some more time then reconnected the second display. That's it!

Hope this helps!

waydabber commented 3 months ago

Ok. And the result was that after reconnecting the first display, it appeared fine and when the second display was connected "LG Ultrafine 2", it did not appear in the app, right?

julioromano commented 3 months ago

Ok. And the result was that after reconnecting the first display, it appeared fine and when the second display was connected "LG Ultrafine 2", it did not appear in the app, right?

The second one did appear. But was not detected as Apple HW control.

waydabber commented 3 months ago

Oh, ok sorry. Sometimes with all the support stuff going in parallel I loose track on what the issue is about lol + this explains why I could not pinpoint the issue I was looking for in the logs... 😆

The bad news is that sadly I did not put much emphasis on logging the hardware control selection process - checking the code the selection is simply based on whether the OS responds to having DisplayServices control available or not during detection time.

Can you try a pre-release version for me whether that has the same issue? If so, I'll add some more logging and provide a build to test.

Here is the download: https://github.com/waydabber/BetterDisplay/releases/tag/pre (see the latest 3.0.0 build under Assets).

waydabber commented 3 months ago

Note: when the app does not detect Apple HW control, system settings shows the brightness slider for the display and control center brightness control works? So it is not a macOS level issue (which causes the app to fail in this regard but the root cause is outside of the app), only an app level issue, right?

UPDATE: You mentioned that "Quitting and reopening BetterDisplay fixes it and makes it recognize also the second display as having Apple HW Control", so the answer is obviously that it's an app level issue. :)

julioromano commented 3 months ago

Oh, ok sorry. Sometimes with all the support stuff going in parallel I loose track on what the issue is about lol + this explains why I could not pinpoint the issue I was looking for in the logs... 😆

The bad news is that sadly I did not put much emphasis on logging the hardware control selection process - checking the code the selection is simply based on whether the OS responds to having DisplayServices control available or not during detection time.

Can you try a pre-release version for me whether that has the same issue? If so, I'll add some more logging and provide a build to test.

Here is the download: https://github.com/waydabber/BetterDisplay/releases/tag/pre (see the latest 3.0.0 build under Assets).

Ok! will give it a spin for a few days and report back, thanks!

waydabber commented 3 months ago

All right. I added some additional flags and log outputs so I see what happens better so next time we'll see more.

waydabber commented 3 months ago

An updated pre-release build is available here with extended logging. If you can re-do the test sometime, we might know more.

https://github.com/waydabber/BetterDisplay/releases/tag/pre (get the latest one at the bottom of the list)

julioromano commented 3 months ago

Sent them over Discord. This time what I did was:

waydabber commented 3 months ago

Thank you!

I checked the logs. The problem is clear, even though the display becomes available and triggers a configuration request, the relevant (private) API (DisplayServices) reports that it cannot control the display's brightness. Because of this, the app classifies the display as nonAppleRealDisplay and tries to configure DDCController instead of AppleController. This however is still within 0.2 seconds after the display is detected and it seems like LG UltraFine displays simply need more time to negotiate this capability it seems.

What I could do is to add a sort of "after-configuration" - maybe checking back a every few seconds 3 or 4 times to see if DisplayServices control becomes available or not and then reconfigure the display accordingly. An other option is just to simply white-list the display for AppleController based on its identifiers (vendor/model).

I know we did some tests by increasing the configuration time earler, but can we do a test again?

  1. Set the configuration delay to 3 seconds
  2. Connect the new display
  3. See if brightness control works or not.
  4. If it works, try decreasing to 2, then 1, then to 0.5 seconds so we might see what is the cut-off time.

It is important that you connect only one display, not two - if you connect two displays, the first will trigger a configuration event which will also cover the second display (which might be connected half a second later for example) which might just be enough that it is outside of the proper window - so one display will then work fine, the other won't and it will be difficult to interpret the results.

julioromano commented 3 months ago

Done, here are the results:

0.2s NOT OK 1.5s NOT OK 2.0s NOT OK 2.5s OK 3.0s OK

I've re checked them multiple times to be sure it wasn't random.

waydabber commented 3 months ago

Ok, thank you! I'll add some changes with this in mind. Meanwhile you should set the config delay to 2.5 seconds.

waydabber commented 3 months ago

I made some changes to the app. Now when a display is newly connected, the app will check whether Apple brightness services become available 1.5, 3.0 and 4.5 seconds after configuring stuff. If it finds that brightness control becomes available, it reconfigures settings. Let me know if you'd like to test it (I'll build a version then).

julioromano commented 3 months ago

I made some changes to the app. Now when a display is newly connected, the app will check whether Apple brightness services become available 1.5, 3.0 and 4.5 seconds after configuring stuff. If it finds that brightness control becomes available, it reconfigures settings. Let me know if you'd like to test it (I'll build a version then).

Sure I'll gladly test it.

waydabber commented 3 months ago

Here it is. Let me know if this works as I had no chance testing this issue. You can check the logs to see what's happening.

https://github.com/waydabber/BetterDisplay/releases/download/pre/BetterDisplay-v3.0.1-b32907-pre.zip

julioromano commented 3 months ago

Just gave it a quick spin and it seems to indeed detect the second display (when waiting a few seconds after connecting the first one). I'll report back if I find out more.

waydabber commented 3 months ago

Nice, thank you!