Skip to content

Commit

Permalink
GUACAMOLE-377: Enforce lower bound on duration of guac_display frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-jumper committed Sep 9, 2024
1 parent c4c40a6 commit 9627a2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libguac/display-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
*/
#define GUAC_DISPLAY_MAX_LAG_COMPENSATION 500

/**
* The minimum amount of time that must elapse between subsequent frames, in
* millisconds. After a frame is written, any further frames will be combined
* and deferred until after this amount of time has elapsed.
*/
#define GUAC_DISPLAY_MIN_FRAME_DURATION 16

/*
* IMPORTANT: All functions defined within the internals of guac_display that
* DO NOT acquire locks on their own are given prefixes based on whether they
Expand Down
8 changes: 8 additions & 0 deletions src/libguac/display-worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ void* guac_display_worker_thread(void* data) {
if (required_wait > GUAC_DISPLAY_MAX_LAG_COMPENSATION)
required_wait = GUAC_DISPLAY_MAX_LAG_COMPENSATION;

/* Apply a reasonable lower bound on the amount of time
* between subsequent frames (reduces server-side
* processing load in the event that the caller starts
* trying to flush a ton of small frames) */
int frame_remaining = GUAC_DISPLAY_MIN_FRAME_DURATION - latency;
if (frame_remaining >= required_wait)
required_wait = frame_remaining;

/* Allow connected clients to catch up if they're taking
* longer to process frames than the server is taking to
* generate them */
Expand Down

0 comments on commit 9627a2f

Please sign in to comment.