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

Random full system freeze #743

Open
rzfzr opened this issue Apr 7, 2024 · 4 comments
Open

Random full system freeze #743

rzfzr opened this issue Apr 7, 2024 · 4 comments

Comments

@rzfzr
Copy link

rzfzr commented Apr 7, 2024

I have not yet looked at any source code, but I'm very willing to try and solve it.

I have a thinkpad T14G2, connected to a USB dock 40AY0090BR, I'm trying to control both of my external monitors, Samsung UR55.

On first install, first glance, everything works perfectly, but sometimes, when I click the tray icon the whole system freezes, as in the mouse, video playing, task manager refreshing etc all hangs for >5 seconds, then moves a little bit, hangs again and repeat.

When it hangs, I can either painfully drag the mouse over the icon, right click and close the app, or disconnect/reconnect the dock, powercycle the monitors, sometimes just refresh the screens from the app, but either way then both monitors show up as having no DDC features at all, requiring rebooting to work again.
Might be related to #175

I was trying to solve the issue on my end, I noticed both my monitors were using the default drivers from MS, I installed the Samsung ones, made no difference.

I just fleshly installed the gh version 1.15.4, tried running for the first time with the -console command, It froze instantly, here's the log till roughly the moment it stopped freezing, not sure if on its own or if when I hovered the tray icon, hard to tell:

Starting Twinkle Tray...
Unloaded module: uuid/v4
Function: getThemeRegistry
Analytics: sending with UUID 2d545e36-7d44-4a2d-9eac-889cc5863b8a

Monitor.js starting. If you see this more than once, something bad happened.
-------------- Refresh Monitors --------------
Doing full refresh.
Running wmi-bridge test...
WMI-BRIDGE TEST: READY
WMI-BRIDGE TEST: OK
getMonitorsWMIC() Total: 68ms
getMonitorsWin32() Total: 2ms
Event: handleMonitorChange
Pausing mouse events...
Couldn't refresh monitors Monitor thread timed out.
----------------------------------------------
Setting brightness for known displays false false 1
Creating panel...
Event: handleBackgroundUpdate
getFeaturesDDC Timed out.
getFeaturesDDC() failed! {}
Checking for updates...
Unloaded module: node-fetch
Event: handleBackgroundUpdate

-------------- Refresh Monitors --------------
Doing full refresh.
Thread busy. Cancelling refresh.
Couldn't refresh monitors No monitors recieved!
----------------------------------------------
Function: getThemeRegistry
Function: getThemeRegistry
Panel ready!
getBrightnessWMIC() Total: 114ms
getBrightnessWMI() skipped due to previous failure.
getAllMonitors() total: 16936ms
Monitors found: 4&196c961d&0&UID45381,4&196c961d&0&UID41029,4&196c961d&0&UID8388688
getForegroundWindow: 68368
~~~~~ MAIN WINDOW MINIMIZED ~~~~~~
trySetForegroundWindow: 68368

-------------- Refresh Monitors --------------
Doing full refresh.
trySetForegroundWindow: 68368
trySetForegroundWindow: 68368
Found version: v1.15.4
trySetForegroundWindow: 68368
getForegroundWindow: 68368
trySetForegroundWindow: 68368
getMonitorsWMIC() Total: 125ms
getMonitorsWMI() skipped due to previous failure.
getMonitorsWin32() Total: 2ms
trySetForegroundWindow: 68368
trySetForegroundWindow: 68368
trySetForegroundWindow: 68368
Couldn't refresh monitors Monitor thread timed out.
----------------------------------------------
getFeaturesDDC Timed out.
getFeaturesDDC() failed! {}
getBrightnessWMIC() Total: 2453ms
getBrightnessWMI() skipped due to previous failure.
getAllMonitors() total: 22766ms
Monitors found: 4&196c961d&0&UID45381,4&196c961d&0&UID41029,4&196c961d&0&UID8388688
Event: handleBackgroundUpdate

-------------- Refresh Monitors --------------
Resuming mouse events...
getBrightnessWMIC() Total: 78ms
----------------------------------------------
Pausing mouse events...
Resuming mouse events...
getForegroundWindow: 265842
trySetForegroundWindow: 265842
trySetForegroundWindow: 265842
trySetForegroundWindow: 265842
trySetForegroundWindow: 265842

Tried running a second time just after, it hanged again, plus gave me a type error:

Starting Twinkle Tray...
Unloaded module: uuid/v4
Function: getThemeRegistry
Analytics: sending with UUID fc12c3a2-74d6-4c12-bc10-cb97059320d3

-------------- Refresh Monitors --------------
Doing full refresh.
Monitor.js starting. If you see this more than once, something bad happened.
Running wmi-bridge test...
WMI-BRIDGE TEST: READY
WMI-BRIDGE TEST: OK
getMonitorsWMIC() Total: 119ms
getMonitorsWin32() Total: 3ms
Event: handleMonitorChange
Pausing mouse events...
Couldn't refresh monitors Monitor thread timed out.
----------------------------------------------
Setting brightness for known displays false false 1
Could not update brightness

TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at updateBrightness (C:\Users\capit\AppData\Local\Programs\twinkle-tray\resources\app.asar\src\electron.js:1420:24)
    at applyProfile (C:\Users\capit\AppData\Local\Programs\twinkle-tray\resources\app.asar\src\electron.js:685:11)
    at setKnownBrightness (C:\Users\capit\AppData\Local\Programs\twinkle-tray\resources\app.asar\src\electron.js:659:3)
    at C:\Users\capit\AppData\Local\Programs\twinkle-tray\resources\app.asar\src\electron.js:2284:39

Creating panel...
Event: handleBackgroundUpdate
getFeaturesDDC Timed out.
getFeaturesDDC() failed! {}
Checking for updates...
Unloaded module: node-fetch
Event: handleBackgroundUpdate
@rzfzr
Copy link
Author

rzfzr commented Apr 7, 2024

I just restarted to make it work again, the monitor are showing up but brightness control is not working still, before restarting:
Screenshot 2024-04-07 115122
After:
image

  • Not sure why the internal display did not show up the second time, the laptop is closed as always.
  • When it freezes, from what I can see in the open taskmanager, it is not an issue of consuming 100% of CPU or other res, the app consumes ~15% when hanging, which of course is high, but would not be freezing the PC by itself.

@rzfzr rzfzr closed this as completed Apr 7, 2024
@rzfzr rzfzr reopened this Apr 7, 2024
@rzfzr
Copy link
Author

rzfzr commented Apr 11, 2024

Still investigating this issue, I was using a ahk wrapper for accessing the win32 API, got the same issue there, SetMonitorBrightness and GetMonitorBrightness works sometimes, but sometimes it freezes the computer all the same.

Funny enough the SetDeviceGammaRamp call does not freak out, it is not ideal, but maybe an alternative solution.

@xanderfrangos
Copy link
Owner

Still investigating this issue, I was using a ahk wrapper for accessing the win32 API, got the same issue there, SetMonitorBrightness and GetMonitorBrightness works sometimes, but sometimes it freezes the computer all the same.

Funny enough the SetDeviceGammaRamp call does not freak out, it is not ideal, but maybe an alternative solution.

Unfortunately, some monitors react poorly to communicating via DDC/CI. SetMonitorBrightness and GetMonitorBrightness use DDC/CI (as does Twinkle Tray), so the problem is the communication between Windows and the monitor. The line getFeaturesDDC Timed out. makes me think that the display is taking an absurdly long time to respond.

It could potentially be the USB hub. Have you tried connecting a display directly to the laptop as a test?

I've seen some monitor settings mess up DDC/CI, so you may be able to work around it with that. Usually it's stuff related to "automatic brightness" or certain profile-specific settings. But if those don't help, then there may not be anything you can do.

Regarding your bullet points:

Not sure why the internal display did not show up the second time, the laptop is closed as always.

The process for detecting displays is failing due to DDC/CI taking too long, which is probably why the internal display sometimes doesn't show as well. v1.16.0+ may handle this a little more gracefully.

When it freezes, from what I can see in the open taskmanager, it is not an issue of consuming 100% of CPU or other res, the app consumes ~15% when hanging, which of course is high, but would not be freezing the PC by itself.

Yeah, I'm not quite sure how Windows handles DDC/CI communication, but this is expected. It tends to lock up the whole PC momentarily. It's not due to activity, but waiting for a response. Windows seems to do something at a low-level that blocks... well, everything. For most users it's so short they don't notice. But in your case it's taking way longer than it should.

@rzfzr
Copy link
Author

rzfzr commented Apr 13, 2024

Yeah, it really seems to be an issue with my specific DDC/CI communication, I didn't test without the dock as I would need to find a dp cable adapter, so it might be the dock.
It doesn't look to me like a delay issue, as though it takes a long time, when it unblocks the command does not go through, if it is a timing issue then it must be failing because of it.

As I thought it might be a queue cleanup issue, I tried to reset the monitor settings via DDC/CI call, in between other calls, that changed nothing.

The gamma change is in the same win32 API but it doesn't actually use DDC/CI, it is entirely a GPU thing, cycling the gamma from 1 till 129 is actually working fine for me, leaving brightness at 100, not perfect but good enough, here is the script for reference.

Would you be interested in accepting a PR where I add a toggle besides the WMI or DDC, inside the monitor options?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants