From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>,
Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH] fix #6223: fit terminal after 'OK' message
Date: Wed, 26 Mar 2025 11:19:44 +0100 [thread overview]
Message-ID: <2732d922-8d1c-4483-9a01-43bfcb00b7f5@proxmox.com> (raw)
In-Reply-To: <37855440-f4af-45ce-a7ac-781bb0151ed1@proxmox.com>
Am 26.03.25 um 09:11 schrieb Dominik Csapak:
> On 3/25/25 19:44, Thomas Lamprecht wrote:
>> Am 18.03.25 um 10:09 schrieb Dominik Csapak:
>>> instead of simply waiting 250ms after we send the credentials, wait
>>> until after the server responded with 'OK' to fit the terminal size.
>>> Still keep the timeout to not do that in the onmessage handler itself,
>>> but rather at a later point in time.
>>
>> potential dumb question, but what's the reason to keep the 250ms in
>> that case?
>
> not a dumb question at all, and you're right: the exact value of 250ms is strictly not necessary.
> I wanted to keep the code in a timeout, so it does not block the 'onmessage' handler,
> but rather that it runs later when the browser has idle cycles.
>
> We could of course reduce the timeout, but in my experience, sometimes browsers behave unexpected
> when it's too short (e.g., it then runs immediatly after the JS code, without a render cycle in
> between, which is what i want to avoid here)
any reference for that, especially w.r.t. unexpected behavior, as that
rather just sounds like expected behavior as nothing in the setTimeout
function is designed for being able to order with (re)paint events.
>
> In practice, omitting the timeout here would naturally work too here, but possibly delay the content
> of the terminal in favor of resizing.
I mean, lowering to something between 20 an 50 ms would be IMO a better
heuristic with less latency, as if the tab is active repaints will happen
at display rate if anything changes and assuming 50 Hz (20 ms period) as
lower bound seems OK, if we want to play it safe then 50 ms would be OK
to.
Alternatively, if what you actually want is to wait one paint we could also
use requestAnimationFrame [0] for that, e.g. something like the following
// wait at least one or more frames
function callbackAfterRepaint(callbackFn) {
let firstTimestamp;
let wrapperFn;
wrapperFn = timestamp => {
if (firstTimestamp === undefined) {
firstTimestamp = timestamp;
requestAnimationFrame(wrapperFn);
} else if (firstTimestamp === timestamp) {
requestAnimationFrame(wrapperFn);
} else {
callbackFn();
}
};
requestAnimationFrame(wrapperFn);
}
I think comparing the timestamp isn't even a requirement, as nesting this
will lead to two calls for separate frames, but that would need checking
more closely. And the time comparison was based on the following docs:
> When multiple callbacks queued by requestAnimationFrame() begin to fire
> in a single frame, each receives the same timestamp even though time has
> passed during the computation of every previous callback's workload.
But again, probably not required as requisting an animation frame from
inside the callback allways gives the next one already anyway.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame
Using requestAnimationFrame is not a must, I just stumbled upon this again
and wanted to try it, and it feels a bit nicer than waiting some arbitrary
amount if letting pass at least one paint cycle is the goal; I can also
apply as is and just lower the wait period to 50 ms, just tell me what you
think after reading this.
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-03-26 10:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 9:09 Dominik Csapak
2025-03-25 18:44 ` Thomas Lamprecht
2025-03-26 8:11 ` Dominik Csapak
2025-03-26 10:19 ` Thomas Lamprecht [this message]
2025-03-26 10:42 ` Dominik Csapak
2025-04-04 16:54 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2732d922-8d1c-4483-9a01-43bfcb00b7f5@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal