wslg icon indicating copy to clipboard operation
wslg copied to clipboard

Displays do not go to sleep when WSLg is enabled after unlocking Windows lock screen using modifier key (such as left-ctrl)

Open desultory-zz opened this issue 5 years ago • 73 comments

Environment

Windows build number:  Version 10.0.22000.100
Your Distribution version:  Gentoo 17.1 Hardened
Your WSLg version:  1.0.24

Steps to reproduce

Just have WSLg running

C:\WINDOWS\system32>powercfg /requests
DISPLAY:
[PROCESS] \Device\HarddiskVolume4\Windows\System32\mstsc.exe
RAIL Power Request

Expected behavior

Screen should go to sleep after 15 minutes

Actual behavior

Display never goes to sleep when WSL is running

desultory-zz avatar Jul 24 '21 17:07 desultory-zz

@desultory, thanks for reporting the issue. Do you run any Linux GUI application ? and if so, could that application be updating screen periodically? Please refer https://github.com/microsoft/wslg/issues/172. thanks!

hideyukn88 avatar Jul 26 '21 18:07 hideyukn88

This happens even if I just open WSL session with no GUI. I only installed tigerVNC to test wslg, nothing else.

desultory-zz avatar Jul 26 '21 19:07 desultory-zz

@desultory , would you please take a look /mnt/wslg/weston.log and see if you have any log with "rdp_rail_idle_handler is called" or "rdp_rail_wake_handler is called" ? thanks!

hideyukn88 avatar Jul 29 '21 17:07 hideyukn88

@hideyukn88

1700 is when I booted, 0200 is when I had a VNC session

This is that file, grepped for "rail" with lines above and below

               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 9.0.0-30-ged4f3bbb
[17:33:34.242] Command line: /usr/bin/weston --backend=rdp-backend.so --xwayland --shell=rdprail-shell.so --logger-scopes=log,rdp-backend,rdprail-shell --log=/mnt/wslg/weston.log
[17:33:34.242] OS: Linux, 5.10.43.3-microsoft-standard-WSL2, #1 SMP Wed Jun 16 23:47:55 UTC 2021, x86_64
[17:33:34.243] Using config file '/home/wslg/.config/weston.ini'
[17:33:34.244] Output repaint window is 7 ms maximum.
--
[17:33:34.256] RDP backend: Environment dump - end
[17:33:34.256] Using external fd for incoming connections: 3
[17:33:34.256] Default head is being added
[17:33:34.256] Registered plugin API 'weston_rdprail_api_v1' of size 56
[17:33:34.256] RDPAPPLIST_MODULEDIR is set to /usr/lib/rdpapplist
[17:33:34.258] RDP backend: use_rdpapplist = 1
[17:33:34.267] RDP backend: use_gfxredir = 1
--
               screen capture uses y-flip: no
               presentation clock: CLOCK_MONOTONIC_RAW, id 4
               presentation clock resolution: 0.000000001 s
[17:33:34.270] Loading module '/usr/lib/weston/rdprail-shell.so'
[17:33:34.271] RDPRAIL-shell: WESTON_RDPRAIL_SHELL_DEBUG_LEVEL: 3.
Date: 2021-07-29 CDT
[17:33:34.271] wet_shell_init: distro name Gentoo (6)
--
[17:33:34.274] WSL2_DEFAULT_APP_OVERLAY_ICON:/usr/share/icons/wsl/linux.png
[17:33:34.274] WESTON_RDPRAIL_SHELL_DISABLE_BLEND_OVERLAY_ICON_TASKBAR:1
[17:33:34.274] WESTON_RDPRAIL_SHELL_DISABLE_BLEND_OVERLAY_ICON_APPLIST:1
[17:33:34.274] rdp_rail_shell_initialize_notify: shell: distro name: Gentoo
[17:33:34.275] app_list_monitor_thread: running in system-distro with user-distro: Gentoo
[17:33:34.275] app_list_monitor_thread: open(/proc/self/ns/mnt)
[17:33:34.275] app_list_monitor_thread: open(/proc/2/ns/mnt)
--
[17:33:35.061] Translated workarea:(1920,0)-(3840,1032) at rdp-0:(1920,0)-(3840,1080)
[17:33:35.061] Client ExecOrder program terminated
[17:33:35.061] dummy-entry exited with status 255
[17:33:35.061] rdp_rail_notify_app_list(): rdp_peer 0x56148b049130
[17:33:35.061]     inSync: 1
[17:33:35.061]     syncStart: 1
[17:33:35.061]     syncEnd: 0
--
[17:33:35.061]     appDesc: FLUID (Gentoo)
[17:33:35.061]     appIcon: 0x7fb758002070
[17:33:35.061]     appProvider: (null)
[17:33:35.062] rdp_rail_notify_app_list(): rdp_peer 0x56148b049130
[17:33:35.062]     inSync: 1
[17:33:35.062]     syncStart: 0
[17:33:35.062]     syncEnd: 1
--
[17:33:35.141] Audio sink thread: Listening for audio connection.
[17:33:39.292] Audio sink thread: connection successful on socket (82).
[17:33:39.292] RDP Sink version (1 - 1)
[17:38:35.045] rdp_rail_idle_handler is called on peerCtx:0x56148b049130
[21:22:28.204] rdp_rail_wake_handler is called on peerCtx:0x56148b049130
[21:27:28.204] rdp_rail_idle_handler is called on peerCtx:0x56148b049130
Date: 2021-07-30 CDT
[00:22:19.154] Client: DisplayLayoutChange: monitor count:0x3
[00:22:19.154] Client: DisplayControl: monitor count:0x3
--
[02:03:30.967] xfixes selection notify event: owner 2097153
[02:03:30.967] our window, skipping
[02:03:50.556] Didn't find output containing (-31, -12), return default
[02:03:50.584] rdp_rail_wake_handler is called on peerCtx:0x56148b049130
[02:03:50.694] Client: ClientGetAppidReq: pid:156 appId:Vncviewer
[02:03:52.583] !!!cursor role is added after creation - WindowId:0x1
[02:04:10.947] Didn't find output containing (-31, -12), return default

desultory-zz avatar Jul 30 '21 07:07 desultory-zz

Also have this issue, powercfg -requests in an elevated powershell prompt gives

PS C:\WINDOWS\system32> powercfg -requests
DISPLAY:
[PROCESS] \Device\HarddiskVolume4\Windows\System32\mstsc.exe
RAIL Power Request

SYSTEM:
[PROCESS] \Device\HarddiskVolume4\Windows\System32\mstsc.exe
RAIL Power Request

AWAYMODE:
None.

EXECUTION:
None.

PERFBOOST:
None.

ACTIVELOCKSCREEN:
None.

zero wslg windows open

gordallott avatar Aug 24 '21 16:08 gordallott

Updating my kernel seemed to fix it temporarily, but I noticed that if I ever opened a WSLg window, it would not go to sleep normally until I rebooted the whole system. I have not used WSLg since then but at least it goes to sleep when running normally through the terminal.

desultory-zz avatar Aug 24 '21 20:08 desultory-zz

Hi @desultory, thanks for providing more info. Do you observe this issue with any WSLg app? for example, if you launch 'xclock', then close 'xclock' (so no more WSLg app is running on desktop), then display never turned off? Or is this only happens when ' tigerVNC' is ever used? thanks!

hideyukn88 avatar Aug 26 '21 19:08 hideyukn88

to note, this happens with any wslg app, opening xclock and closing xclock keeps the display open, as my comment pointed out, mstsc.exe keeps the remote desktop connection going which keeps the system from sleeping

gordallott avatar Sep 06 '21 09:09 gordallott

I've started seeing similar behavior within the last week or so. (If it seems like this is a different bug, let me know and I'd be happy to file separately). My computer seems to not go to sleep if WSL is running at all, even if I've never started a WSLg app. If I run wsl --shutdown, then everything seems to get cleaned up. I dumped logs at https://gist.github.com/ebroder/7143b922985281cd817a535d938cab31 but can grab more if helpful.

ebroder avatar Oct 09 '21 00:10 ebroder

I just installed Windows 11 and then WSLg, and also found that my computer no longer sleeps. Disabling WSLg by putting

[wsl2]
guiApplications=false

in .wslconfig got my computer sleeping again (but no WSLg of course).

jclark avatar Oct 09 '21 00:10 jclark

For me just starting WSL is not enough to trigger this. I had to run some app which would use WSLg, then until WSL is explicitly shutdown displays would not turn off.

vladimir-novoseltsev avatar Oct 09 '21 10:10 vladimir-novoseltsev

Hi @desultory, thanks for providing more info. Do you observe this issue with any WSLg app? for example, if you launch 'xclock', then close 'xclock' (so no more WSLg app is running on desktop), then display never turned off? Or is this only happens when ' tigerVNC' is ever used? thanks!

most recently I noticed it keeping my computer awake when using firefox. I was using it with Selenium for what it's worth and when I closed that program it seemed to sleep properly.

desultory-zz avatar Oct 31 '21 21:10 desultory-zz

I am seeing WSLg apps blocking the screen saver / display off as well.

wsl --version
WSL version: 0.48.2.0
Kernel version: 5.10.60.1
WSLg version: 1.0.29
Windows version: 10.0.22000.282

While Emacs is running via XWayland via WSLg weston, powercfg /requests reports the following:

DISPLAY:
[PROCESS] \Device\HarddiskVolume3\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.48.2.0_x64__8wekyb3d8bbwe\msrdc.exe
RAIL Power Request

In practice, this means my displays stay on indefinitely, whilst I would prefer for screen saver and later automatic display power off to happen.

If I exit Emacs and wait a few minutes, powercfg /requests reports NO more blockers.

cpbotha avatar Nov 01 '21 17:11 cpbotha

@cpbotha, thanks for info, this is the result of temporary workaround since WSLg doesn't have real DPMS (Display Power Management Signaling), thus WSLg keeps screen turned on as long as application updates the screen, and most of case, this works just fine since well-behave application stops updating screen when there is no interaction from user, but certain legacy application, like Emacs, might not. And the reason for placing that "temporary workaround" is due to avoid screen being turned off while playing video on WSLg (for example on Firefox Browser or VLC), so we understand there is pros/cons. we are welcoming feedback on this, please let us know, thanks!

hideyukn88 avatar Nov 02 '21 20:11 hideyukn88

@cpbotha, thanks for info, this is the result of temporary workaround since WSLg doesn't have real DPMS (Display Power Management Signaling), thus WSLg keeps screen turned on as long as application updates the screen, and most of case, this works just fine since well-behave application stops updating screen when there is no interaction from user, but certain legacy application, like Emacs, might not. And the reason for placing that "temporary workaround" is due to avoid screen being turned off while playing video on WSLg (for example on Firefox Browser or VLC), so we understand there is pros/cons. we are welcoming feedback on this, please let us know, thanks!

If it's a temporary workaround with known issues, make it a toggle? This has been happening for many months now so I don't think it makes sense to call this temporary.

desultory-zz avatar Nov 02 '21 20:11 desultory-zz

Just a bit of good news from my side: My Emacs configuration had some code that would write a message to the minibuffer (the line at the bottom of the display) at regular intervals. When I disabled that message output, Windows idle display off started working again! (in other words, I can keep Emacs running on WSLg, my screens switch off automatically after a few minutes idle)

Still great that you were able to make this configurable @hideyukn88 in weston-mirror PR49. Thank you for all of your efforts with WSLg, it's a great system!

cpbotha avatar Nov 04 '21 08:11 cpbotha

As a temporary workaround, running the following command sets an override that causes Windows to ignore the power requests from WSLg: powercfg /requestsoverride PROCESS mstsc.exe DISPLAY SYSTEM

fefrei avatar Dec 13 '21 08:12 fefrei

Still having this problem on the Windows insider beta, not sure if the fix has made it there yet though:

Field Value
Edition Windows 11 Pro
Version 22H2
OS build 22621.1
Experience Windows Feature Experience Pack 1000.22632.1000.0

ssg avatar May 20 '22 07:05 ssg

Hi @ssg , I encountered the same problem but I've solved it after a few survey. I disabled cursor blinking of Windows in control panel. By doing so, the wsl terminal will stop blinking and updating its window, then my computer can sleep after 5 min. (less than 5 min still does not work for me since this is the wsl default value)

superpi15 avatar May 23 '22 18:05 superpi15

@superpi15 thanks, I worked it around by running this on an elevated command prompt:

powercfg -requestsoverride PROCESS msrdc.exe DISPLAY SYSTEM

ssg avatar May 23 '22 18:05 ssg