xanderfrangos / twinkle-tray

Easily manage the brightness of your monitors in Windows from the system tray
https://twinkletray.com
MIT License
5.57k stars 182 forks source link

Monitor DDC not detected sometimes (new wmi-bridge on beta) #809

Open eikaramba opened 2 months ago

eikaramba commented 2 months ago

I have the LG 34GN850-B Monitor which offers DDC. Working 100% in ClickMonitorDDC (https://github.com/chrismah/ClickMonitorDDC7.2)

Now i switched to Twinkle-Tray because ClickMonitor crashes after hibernation.

Twinkle-Tray was detecting my monitor with the default settings, however today it stopped working and no restart, switching to legacy mode etc did not helped. Then i started ClickMonitor again to see if it is working. Low and behold after THEN exiting ClickMonitor and starting Twinkle it was able to detect the Monitor. Weird right? Is there any way i can help debugging the issue?

I am on latest beta 1.16.0-beta7

eikaramba commented 2 months ago

i cloned the repo on the beta branch and started it locally, there i can see that i get "Sorry, no updates right now!" all the time. so it seems the monitorthread is never launched somehow or there is a race condition. so clickMonitorDDC does not seem to have anything to do with it. i also don't see "WMI-BRIDGE TEST" in that case.

trying it again after a few times it works and i can see my monitor. will see if i can pinpoint the exact cause

eikaramba commented 2 months ago

ok i think there is something going on in the getWMIMonitors c++ code. how can i see the log statements from the c++ code so that i can better see what is going on? @xanderfrangos

eikaramba commented 2 months ago

i found out how to print the debug lines here is the log where the monitor was not detected. i can now say he is stalling at this line and never continues and resolves the promise https://github.com/xanderfrangos/twinkle-tray/blob/master/src/wmi-bridge-test.js#L22

Starting Twinkle Tray...
Starting Parcel bundler server...
[PIPE] Starting named pipe...
[PIPE] Server listening at \\.\pipe\twinkle-tray\cmds
Function: getThemeRegistry
Creating panel...
Running wmi-bridge test...
getting monitors
Line: getWMIMonitors 1
Line: wmiConnect 1
Line: wmiConnect 2
Line: wmiConnect 3
Line: wmiConnect 4 END
Line: getWMIMonitors 2
Line: getWMIMonitors 3
Line: getWMIMonitors 4
Line: getWMIMonitors 5
Line: getWMIMonitors 6
Line: bstr_to_str 1
Line: bstr_to_str 2
Line: bstr_to_str 3
Line: bstr_to_str 4
Line: bstr_to_str 5 END
Line: getWMIMonitors 7
Line: getWMIClassUINTString 1
Line: getWMIClassUINTString 2
Line: getWMIClassUINTString 3b
Line: getWMIClassUINTString 4
Line: getWMIClassUINTString 5
Line: getWMIClassUINTString 6
Line: getWMIClassUINTString 7
Line: getWMIClassUINTString 8 END
Line: getWMIMonitors 8
Line: getWMIMonitors 12
WMI-BRIDGE TEST: READY
[UDP] Starting local UDP Server...
Function: getThemeRegistry
Function: getThemeRegistry
[UDP] UDP server listening at 127.0.0.1:14715
Function: getThemeRegistry
Panel ready!
~~~~~ MAIN WINDOW MINIMIZED ~~~~~~
Sorry, no updates right now! false false
Function: getThemeRegistry
~~~~~ MAIN WINDOW RESTORED ~~~~~~
overlayType: safe
~~~~~ MAIN WINDOW MINIMIZED ~~~~~~
eikaramba commented 2 months ago

i suspect the loop https://github.com/xanderfrangos/twinkle-tray/blob/master/src/modules/wmi-bridge/wmi-bridge.cc#L243 is never finishing, i am now trying to debug this. unfortunately once the monitor was detected after a few attempts i need to wait again until the error happens. maybe it is caused by hibernation? let's see

xanderfrangos commented 2 months ago

@eikaramba If you disable WMI-Bridge under General -> Troubleshooting -> Enabled monitor detection methods, does that fix the issue?

Do you ever get WMI-BRIDGE TEST: OK or WMI-BRIDGE TEST: Killing thread in your logs? The test should time out after 2 seconds.

Also, are you on a laptop or desktop?

eikaramba commented 2 months ago

For the rest i need to check again, because the error unfortunately only happens sometimes... update: still waiting for it to happen again, somehow it did not happen in the last days.

xanderfrangos commented 2 months ago

@eikaramba Rolled out a new beta that might help. It's possible there was a race condition that caused the test to never finish.

eikaramba commented 2 months ago

thanks i will test it. on the old version disabling wmi bridge did not help. unfortunately i rarely happened in the last days so i wasn't able to debug it more but will test the new version. if it does not happen in the next 3 months i will close this issue