This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.18 by this push:
     new cb0874f5b9e novnc: Send console text slower to avoid overloading 
remote keyboard buffer (#7477)
cb0874f5b9e is described below

commit cb0874f5b9e8b8bc3fc5c71be7fbebd903ba2523
Author: Marcus Sorensen <marcus_soren...@apple.com>
AuthorDate: Mon May 8 00:24:08 2023 -0600

    novnc: Send console text slower to avoid overloading remote keyboard buffer 
(#7477)
    
    This PR slows down the console paste text function in the console ever so 
slightly, adding 25ms between each character. It was found that when large text 
is pasted, say an SSH key or something over 100 characters, it would stop 
somewhere in the 100-200 character range, and if the last character was 
capitalized it would be stuck with left shift held down.
    
    In debugging, I ran noVNC locally with websockify against a Qemu VNC and 
took the whole console proxy out of the equation and was still able to 
reproduce it. I traced the websocket packets and we were clearly firing off all 
of the keypresses just fine, but the ones on the end were getting dropped VNC 
server side. It seems we are overloading a keyboard buffer, or something along 
those lines when we send all of the keypress messages at once. It was also 
observed that we were able to sen [...]
    
    This sendText function doesn't seem to exist in upstream noVNC, so just 
patching it here seems reasonable. I suspect we added this for feature parity 
with whatever noVNC replaced.
    
    In testing it is now much more reliable in sending a few paragraphs of 
text, and not visibly slower than before, but obviously still too slow to do 
anything really big with it. It isn't really the goal to be able to paste full 
documents.
    
    Co-authored-by: Marcus Sorensen <m...@apple.com>
---
 systemvm/agent/noVNC/core/rfb.js | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/systemvm/agent/noVNC/core/rfb.js b/systemvm/agent/noVNC/core/rfb.js
index f92255808e3..b795aaa7525 100644
--- a/systemvm/agent/noVNC/core/rfb.js
+++ b/systemvm/agent/noVNC/core/rfb.js
@@ -433,21 +433,30 @@ export default class RFB extends EventTargetMixin {
         this._resumeAuthentication();
     }
 
-    sendText(text) {
-        for (var i = 0; i < text.length; i++) {
-            const character = text.charAt(i);
-            var charCode = USKeyTable[character] || false;
-            if (charCode) {
-                this.sendKey(charCode, character, true);
-                this.sendKey(charCode, character, false);
-            } else {
-                charCode = text.charCodeAt(i)
-                this.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", true);
-                this.sendKey(charCode, character, true);
-                this.sendKey(charCode, character, false);
-                this.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", false);
+     sendText(text) {
+        const sleep = (time) => {
+            return new Promise(resolve => setTimeout(resolve, time))
+        }
+
+        const keyboardTypeText = async () => {
+            for (var i = 0; i < text.length; i++) {
+                const character = text.charAt(i);
+                var charCode = USKeyTable[character] || false;
+                if (charCode) {
+                    this.sendKey(charCode, character, true);
+                    this.sendKey(charCode, character, false);
+                } else {
+                    charCode = text.charCodeAt(i)
+                    this.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", true);
+                    this.sendKey(charCode, character, true);
+                    this.sendKey(charCode, character, false);
+                    this.sendKey(KeyTable.XK_Shift_L, "ShiftLeft", false);
+                }
+                await sleep(25)
             }
         }
+
+        keyboardTypeText()
     }
 
     sendCtrlAltDel() {

Reply via email to