diff --git a/html5/js/Client.js b/html5/js/Client.js index a0100abc..614d8699 100644 --- a/html5/js/Client.js +++ b/html5/js/Client.js @@ -425,7 +425,7 @@ XpraClient.prototype.initialize_workers = function() { decode_worker.addEventListener('message', function(e) { const data = e.data; if (data['draw']) { - me.do_process_draw(data['draw']); + me.do_process_draw(data['draw'], data['start']); return; } if (data['error']) { @@ -2881,6 +2881,7 @@ XpraClient.prototype._process_draw = function(packet, ctx) { const coding = packet[6]; let img_data = packet[7]; const raw_buffers = []; + const now = Utilities.monotonicTime(); if (coding!="scroll") { if (!(img_data instanceof Uint8Array)) { //the legacy bencoder can give us a string here @@ -2890,16 +2891,16 @@ XpraClient.prototype._process_draw = function(packet, ctx) { raw_buffers.push(img_data.buffer); } if (ctx.decode_worker) { - ctx.decode_worker.postMessage({'cmd': 'decode', 'packet' : packet}, raw_buffers); + ctx.decode_worker.postMessage({'cmd': 'decode', 'packet' : packet, 'start' : now}, raw_buffers); //the worker draw event will call do_process_draw } else { - ctx.do_process_draw(packet); + ctx.do_process_draw(packet, now); } } XpraClient.prototype._process_eos = function(packet, ctx) { - ctx.do_process_draw(packet); + ctx.do_process_draw(packet, 0); const wid = packet[1]; ctx.decode_worker_eos(wid); }; @@ -2948,10 +2949,11 @@ XpraClient.prototype.do_send_damage_sequence = function(packet_sequence, wid, wi if (!protocol) { return; } - protocol.send(["damage-sequence", packet_sequence, wid, width, height, decode_time, message]); + const packet = ["damage-sequence", packet_sequence, wid, width, height, decode_time, message]; + protocol.send(packet); } -XpraClient.prototype.do_process_draw = function(packet) { +XpraClient.prototype.do_process_draw = function(packet, start) { if(!packet){ //no valid draw packet, likely handle errors for that here return; @@ -2967,8 +2969,7 @@ XpraClient.prototype.do_process_draw = function(packet) { return; } - const start = Utilities.monotonicTime(), - x = packet[2], + const x = packet[2], y = packet[3], width = packet[4], height = packet[5], @@ -3002,11 +3003,11 @@ XpraClient.prototype.do_process_draw = function(packet) { if(flush==0) { me.request_redraw(win); } - if (error) { + if (error || start==0) { me.request_redraw(win); } else { - decode_time = Math.round(Utilities.monotonicTime() - start); + decode_time = 1000*Math.round(Utilities.monotonicTime() - start); } me.debug("draw", "decode time for ", coding, " sequence ", packet_sequence, ": ", decode_time, ", flush=", flush); send_damage_sequence(decode_time, error || ""); diff --git a/html5/js/DecodeWorker.js b/html5/js/DecodeWorker.js index f12db6e8..66053878 100644 --- a/html5/js/DecodeWorker.js +++ b/html5/js/DecodeWorker.js @@ -105,13 +105,13 @@ function decode_eos(wid) { } } -function decode_draw_packet(packet) { +function decode_draw_packet(packet, start) { const wid = packet[1], width = packet[4], height = packet[5], coding = packet[6], packet_sequence = packet[8]; - //console.log("packet to decode:", data.packet); + //console.log("decode worker sequence "+packet_sequence+": start="+start); function send_back(raw_buffers) { //console.log("send_back: wid_hold=", wid_hold); const wid_hold = on_hold.get(wid); @@ -131,13 +131,13 @@ function decode_draw_packet(packet) { } } } - self.postMessage({'draw': packet}, raw_buffers); + do_send_back(packet, raw_buffers); } function do_send_back(p, raw_buffers) { - self.postMessage({'draw': p}, raw_buffers); + self.postMessage({'draw': p, 'start' : start}, raw_buffers); } function decode_error(msg) { - self.postMessage({'error': ""+msg, 'packet' : packet}); + self.postMessage({'error': ""+msg, 'packet' : packet, 'start' : start}); } function hold() { @@ -344,7 +344,7 @@ onmessage = function(e) { decode_eos(data.wid); break; case 'decode': - decode_draw_packet(data.packet); + decode_draw_packet(data.packet, data.start); break default: console.error("decode worker got unknown message: "+data.cmd);