GUACAMOLE-346: Always replay frames asynchronously when seeking.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/744574d0
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/744574d0
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/744574d0

Branch: refs/heads/master
Commit: 744574d026d9077e8cf36a838c3f47e55e787b42
Parents: 1d6e8d2
Author: Michael Jumper <[email protected]>
Authored: Sat Jul 15 16:06:32 2017 -0700
Committer: Michael Jumper <[email protected]>
Committed: Sat Jul 15 16:08:55 2017 -0700

----------------------------------------------------------------------
 .../src/main/webapp/modules/SessionRecording.js | 61 ++++++++++----------
 1 file changed, 31 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/744574d0/guacamole-common-js/src/main/webapp/modules/SessionRecording.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js 
b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js
index 74eeb0b..a89bd70 100644
--- a/guacamole-common-js/src/main/webapp/modules/SessionRecording.js
+++ b/guacamole-common-js/src/main/webapp/modules/SessionRecording.js
@@ -315,11 +315,10 @@ Guacamole.SessionRecording = function 
SessionRecording(tunnel) {
 
     /**
      * Moves the playback position to the given frame, resetting the state of
-     * the playback client and replaying frames as necessary. If the seek
-     * cannot be completed quickly, the seek operation may proceed
-     * asynchronously. If a seek operation is already in progress, that seek is
-     * first aborted. The progress of the seek operation can be observed
-     * through the onseek handler and the provided callback.
+     * the playback client and replaying frames as necessary. The seek
+     * operation will proceed asynchronously. If a seek operation is already in
+     * progress, that seek is first aborted. The progress of the seek operation
+     * can be observed through the onseek handler and the provided callback.
      *
      * @private
      * @param {Number} index
@@ -358,39 +357,42 @@ Guacamole.SessionRecording = function 
SessionRecording(tunnel) {
         // Advance to frame index after current state
         startIndex++;
 
-        var startTime = new Date().getTime();
+        // Replay frames asynchronously
+        seekTimeout = window.setTimeout(function continueSeek() {
 
-        // Replay any applicable incremental frames
-        for (; startIndex <= index; startIndex++) {
+            var startTime = new Date().getTime();
 
-            // Stop seeking if the operation is taking too long
-            var currentTime = new Date().getTime();
-            if (currentTime - startTime >= MAXIMUM_SEEK_TIME)
-                break;
+            // Replay any applicable incremental frames
+            for (; startIndex <= index; startIndex++) {
 
-            replayFrame(startIndex);
-        }
+                // Stop seeking if the operation is taking too long
+                var currentTime = new Date().getTime();
+                if (currentTime - startTime >= MAXIMUM_SEEK_TIME)
+                    break;
 
-        // Current frame is now at requested index
-        currentFrame = startIndex - 1;
+                replayFrame(startIndex);
+            }
 
-        // Notify of changes in position
-        if (recording.onseek)
-            recording.onseek(recording.getPosition());
+            // Current frame is now at requested index
+            currentFrame = startIndex - 1;
 
-        // If the seek operation has not yet completed, schedule continuation
-        if (currentFrame !== index)
-            seekTimeout = window.setTimeout(function continueSeek() {
+            // Notify of changes in position
+            if (recording.onseek)
+                recording.onseek(recording.getPosition());
+
+            // If the seek operation has not yet completed, schedule 
continuation
+            if (currentFrame !== index)
                 seekToFrame(index, callback);
-            }, 0);
 
-        else {
+            else {
 
-            // Notify that the requested seek has completed
-            if (callback)
-                callback();
+                // Notify that the requested seek has completed
+                if (callback)
+                    callback();
 
-        }
+            }
+
+        }, 0);
 
     };
 
@@ -598,8 +600,7 @@ Guacamole.SessionRecording = function 
SessionRecording(tunnel) {
      * currently being played back, playback will continue after the seek is
      * performed. If the recording is currently paused, playback will be
      * paused after the seek is performed. If a seek operation is already in
-     * progress, that seek is first aborted. Depending on how much processing
-     * the seek operation requires, the seek operation may proceed
+     * progress, that seek is first aborted. The seek operation will proceed
      * asynchronously.
      *
      * @param {Number} position

Reply via email to