GUACAMOLE-884: Leverage createImageBitmap() for reading image data where supported.

Some browsers suffer from a memory leak when reading image data
repeatedly using the Image object. Reading from Blobs does not exhibit
the same behavior. While reading from Blobs has previously been seen to
perform poorly compared to data URIs, this was observed when reading
using createObjectURL(). The createImageBitmap() function appears to
perform identically to reading data URIs using Image.
This commit is contained in:
Michael Jumper
2019-09-29 21:57:02 -07:00
parent 5ff81f7735
commit 4e130d2afd
2 changed files with 86 additions and 21 deletions

View File

@@ -1190,13 +1190,10 @@ Guacamole.Client = function(tunnel) {
// Create stream
var stream = streams[stream_index] = new Guacamole.InputStream(guac_client, stream_index);
var reader = new Guacamole.DataURIReader(stream, mimetype);
// Draw image when stream is complete
reader.onend = function drawImageBlob() {
display.setChannelMask(layer, channelMask);
display.draw(layer, x, y, reader.getURI());
};
// Draw received contents once decoded
display.setChannelMask(layer, channelMask);
display.drawStream(layer, x, y, stream, mimetype);
},