GUACAMOLE-377: Revise processing lag calculations to consider cumulative processing lag.

This commit is contained in:
Michael Jumper 2021-08-31 10:47:35 -07:00
parent dd85c54961
commit c19eab9691

View File

@ -120,14 +120,27 @@ int __guac_handle_sync(guac_user* user, int argc, char** argv) {
/* Calculate length of frame, including network and processing lag */ /* Calculate length of frame, including network and processing lag */
frame_duration = current - timestamp; frame_duration = current - timestamp;
/* Update lag statistics if at least one frame has been rendered */ /* Calculate processing lag portion of length of frame */
int frame_processing_lag = 0;
if (user->last_frame_duration != 0) { if (user->last_frame_duration != 0) {
/* Calculate lag using the previous frame as a baseline */ /* Calculate lag using the previous frame as a baseline */
int processing_lag = frame_duration - user->last_frame_duration; frame_processing_lag = frame_duration - user->last_frame_duration;
/* Adjust back to zero if cumulative error leads to a negative /* Adjust back to zero if cumulative error leads to a negative
* value */ * value */
if (frame_processing_lag < 0)
frame_processing_lag = 0;
}
/* Record baseline duration of frame by excluding lag (this is the
* network round-trip time) */
int estimated_rtt = frame_duration - frame_processing_lag;
user->last_frame_duration = estimated_rtt;
/* Calculate cumulative accumulated processing lag relative to server timeline */
int processing_lag = current - user->last_received_timestamp - estimated_rtt;
if (processing_lag < 0) if (processing_lag < 0)
processing_lag = 0; processing_lag = 0;
@ -135,16 +148,11 @@ int __guac_handle_sync(guac_user* user, int argc, char** argv) {
} }
/* Record baseline duration of frame by excluding lag */
user->last_frame_duration = frame_duration - user->processing_lag;
}
/* Log received timestamp and calculated lag (at TRACE level only) */ /* Log received timestamp and calculated lag (at TRACE level only) */
guac_user_log(user, GUAC_LOG_TRACE, guac_user_log(user, GUAC_LOG_TRACE,
"User confirmation of frame %" PRIu64 "ms received " "User confirmation of frame %" PRIu64 "ms received "
"at %" PRIu64 "ms (processing_lag=%ims)", "at %" PRIu64 "ms (processing_lag=%ims, estimated_rtt=%ims)",
timestamp, current, user->processing_lag); timestamp, current, user->processing_lag, user->last_frame_duration);
if (user->sync_handler) if (user->sync_handler)
return user->sync_handler(user, timestamp); return user->sync_handler(user, timestamp);