Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

Keystroke throttling on Windows 8.1 server

Post Reply
LRN
8
8
Posts: 21
Joined: 2014-04-16 23:54

Keystroke throttling on Windows 8.1 server

Post by LRN »

UltraVNC 1.2.0.1 installed on an x86 Windows 8.1 machine, into C:\Program Files\UltraVNC
Using x86_64 UltraVNC 1.2.0.1 viewer to connect. Also tried TightVNC Java viewer (see below for the difference it makes).
w8hook is installed, schook is not. Mirror driver is not installed.
Tried different settings (Poll fullscreen on/off, System Hook on/off), no effect.

Porblem is that keystrokes sent by the viewer to the server cause the server to hang up for a short period of time.
This happens when there are multiple keystrokes in quick succession (around 4).
I.e. open anything with keyboard input, start typing something, fast, and the server will hang up.

Hanged server does not send screen updates and does not accept mouse input from the viewer (and keyboard input too, obviously).
On server side keystrokes are realized, a few at a time. I.e. if you typed "qweqweqweqweqweqwe", you will see "qweq", then, after a couple of seconds, "qweqwe", then, after waiting a bit, "qweqweqweq", and so on, until all the keystrokes the viewer sent are there. Once the keystroke buffer is emptied, the server unhangs and starts sending updates and accept input. Until you start typing something fast again, that is.

Also, while this is happening, Windows 8.1 on the server side becomes nearly 100% unresponsive to mouse clicks. It still reacts to local keyboard input normally, and still registers local mouse movement (interactive elements react when you hover mouse over them), but clicks almost never get through.

Also, while this is happening, dwm.exe CPU and GPU consumption, which is usually fairly high during VNC session, drops to zero (i.e. screen capture is not functioning on server side).
While server is hung up, winvnc.exe (the second process; the child, not the parent) consumes 100% of a CPU core. Since i have no debug symbols for winvnc.exe that are compatible with Process Hacker's thread call stack viewer, i have no idea what kinds of functions are being called, the top stack elements after winvnc.exe are:

Code: Select all

0, ntoskrnl.exe!KiDeliverApc+0x128
1, ntoskrnl.exe!KeSetEvent+0xa2c
2, ntoskrnl.exe!ExReleaseResourceLite+0x355
3, ntoskrnl.exe!ExReleaseResourceAndLeavePriorityRegion+0xd
4, ntoskrnl.exe!wcsncpy_s+0x7a87
5, ntdll.dll!KiFastSystemCallRet
One difference when using TightVNC Java viewer:
1) Sending repeating keystrokes of one single key does not cause server to hang up. I.e. pressing a single key and keeping it pressed down works OK. Both for character keys and for functional keys (at least for Backspace).

Removing w8hook.dll does not remove the problem, but does eliminate winvnc.exe 100% CPU consumption while server is hung up.
Removing uvnckeyboardhelper.exe removes the problem (obviously that is not a solution, as uvnckeyboardhelper is needed at the very least for Alt-Tab to work).
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6863
Joined: 2004-04-23 10:21
Contact:

Re: Keystroke throttling on Windows 8.1 server

Post by Rudi De Vos »

w8hook is the desktop duplication engine, this actual create a copy of the screen and give the updated parts.
Normal the copy should only habben every 30-100 ms, to avoid 100% cpu usage...
Looks like the keyboard injection is causing some loop at this level.

Thanks for the input, this limit a debugging to the keyboardhelper and it's interaction with the duplication engine.
The keyboardhelper was a hell to make as you need to play with permission and settings to do wath win8 is actual trying to avoid.
LRN
8
8
Posts: 21
Joined: 2014-04-16 23:54

Re: Keystroke throttling on Windows 8.1 server

Post by LRN »

Anything else you need? I can produce stack traces, if you give me debug symbols (well, ProcessHacker's stack traces for VS debug symbols; gdb stack traces for MinGW debug symbols). Or maybe create a special version of winvnc.exe with added stack trace dumper, and i'll send you the logs. Or i can just send you the logs (which debug level will be sufficient?), if they already have enough information.

You can also write small test applications that simulate "receiving" multiple keystrokes from a viewer in a quick succession and inject these into the system, measuring the time it takes to inject each keystroke. I'll run them and report the timing they output. This way we'll narrow the problem down to a small testcase that is easy to compile and play with. Maybe i'll even figure out what's wrong with it.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6863
Joined: 2004-04-23 10:21
Contact:

Re: Keystroke throttling on Windows 8.1 server

Post by Rudi De Vos »

I will try to reproduce it next week, ned to finish other stuff this weekedn.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6863
Joined: 2004-04-23 10:21
Contact:

Re: Keystroke throttling on Windows 8.1 server

Post by Rudi De Vos »

I think i found a solution.
What version do you need for testing
win8 x86/X64

Changes are done in winvnc.exe and the way it handle the keyboard events and communication with the helper.
LRN
8
8
Posts: 21
Joined: 2014-04-16 23:54

Re: Keystroke throttling on Windows 8.1 server

Post by LRN »

x86 Windows 8
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6863
Joined: 2004-04-23 10:21
Contact:

Re: Keystroke throttling on Windows 8.1 server

Post by Rudi De Vos »

http://www.uvnc.eu/download/1201/winvnc_keyboard.zip

32/64bit winvnc.exe

Please test if this behave better + special keys still function with win8
LRN
8
8
Posts: 21
Joined: 2014-04-16 23:54

Re: Keystroke throttling on Windows 8.1 server

Post by LRN »

Tried it.

Special keys still work (Alt-tab definitely works; not sure which other keys you need to be tested).
Behaves better - keystrokes are processed normally.
szymon.nowak
20
20
Posts: 52
Joined: 2011-12-09 22:21

Re: Keystroke throttling on Windows 8.1 server

Post by szymon.nowak »

wk2 build please
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6863
Joined: 2004-04-23 10:21
Contact:

Re: Keystroke throttling on Windows 8.1 server

Post by Rudi De Vos »

The w2k build wil not work.
The win8 desktop duplication engine doesn't exist in the w2k build as the compiler doesn't support the new win8 function.

The w2k build use the old VS 2008 compiler
The win8 build use the VS 2013 compiler
Source is the same except from the parts that are not supported with the old compiler.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6863
Joined: 2004-04-23 10:21
Contact:

Re: Keystroke throttling on Windows 8.1 server

Post by Rudi De Vos »

LRN,
Src has been updated in svn.
I will try to release a minor update 1.2.02 in september.
Post Reply