From e33408cbe31ee5720e15e7ee2cdc00d6c3e17937 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 13 Apr 2017 21:58:03 -0700 Subject: [PATCH] GUACAMOLE-250: Unblock image rendering tasks if image decode fails. --- .../src/main/webapp/modules/Display.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Display.js b/guacamole-common-js/src/main/webapp/modules/Display.js index 2c9ede6d8..be5bf6c52 100644 --- a/guacamole-common-js/src/main/webapp/modules/Display.js +++ b/guacamole-common-js/src/main/webapp/modules/Display.js @@ -548,13 +548,20 @@ Guacamole.Display = function() { // Draw and free blob URL when ready var task = scheduleTask(function __display_drawBlob() { - layer.drawImage(x, y, image); + + // Draw the image only if it loaded without errors + if (image.width && image.height) + layer.drawImage(x, y, image); + + // Blob URL no longer needed URL.revokeObjectURL(url); + }, true); // Load image from URL var image = new Image(); image.onload = task.unblock; + image.onerror = task.unblock; image.src = url; }; @@ -572,11 +579,16 @@ Guacamole.Display = function() { this.draw = function(layer, x, y, url) { var task = scheduleTask(function __display_draw() { - layer.drawImage(x, y, image); + + // Draw the image only if it loaded without errors + if (image.width && image.height) + layer.drawImage(x, y, image); + }, true); var image = new Image(); image.onload = task.unblock; + image.onerror = task.unblock; image.src = url; };