Initial frame stat tracking
This commit is contained in:
parent
67466077c0
commit
f9f5b01cc2
|
@ -21,6 +21,8 @@ export default class Display {
|
||||||
this._fbWidth = 0;
|
this._fbWidth = 0;
|
||||||
this._fbHeight = 0;
|
this._fbHeight = 0;
|
||||||
|
|
||||||
|
this._renderMs = 0;
|
||||||
|
|
||||||
this._prevDrawStyle = "";
|
this._prevDrawStyle = "";
|
||||||
|
|
||||||
Log.Debug(">> Display.constructor");
|
Log.Debug(">> Display.constructor");
|
||||||
|
@ -91,6 +93,13 @@ export default class Display {
|
||||||
return this._fbHeight;
|
return this._fbHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get renderMs() {
|
||||||
|
return this._renderMs;
|
||||||
|
}
|
||||||
|
set renderMs(val) {
|
||||||
|
this._renderMs = val;
|
||||||
|
}
|
||||||
|
|
||||||
// ===== PUBLIC METHODS =====
|
// ===== PUBLIC METHODS =====
|
||||||
|
|
||||||
viewportChangePos(deltaX, deltaY) {
|
viewportChangePos(deltaX, deltaY) {
|
||||||
|
@ -470,6 +479,7 @@ export default class Display {
|
||||||
|
|
||||||
_scanRenderQ() {
|
_scanRenderQ() {
|
||||||
let ready = true;
|
let ready = true;
|
||||||
|
let before = Date.now();
|
||||||
while (ready && this._renderQ.length > 0) {
|
while (ready && this._renderQ.length > 0) {
|
||||||
const a = this._renderQ[0];
|
const a = this._renderQ[0];
|
||||||
switch (a.type) {
|
switch (a.type) {
|
||||||
|
@ -513,5 +523,8 @@ export default class Display {
|
||||||
this._flushing = false;
|
this._flushing = false;
|
||||||
this.onflush();
|
this.onflush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let elapsed = Date.now() - before;
|
||||||
|
this._renderMs += elapsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
39
core/rfb.js
39
core/rfb.js
|
@ -142,6 +142,8 @@ export default class RFB extends EventTargetMixin {
|
||||||
this._maxVideoResolutionX = 960;
|
this._maxVideoResolutionX = 960;
|
||||||
this._maxVideoResolutionY = 540;
|
this._maxVideoResolutionY = 540;
|
||||||
|
|
||||||
|
this._trackFrameStats = false;
|
||||||
|
|
||||||
this._clipboardText = null;
|
this._clipboardText = null;
|
||||||
this._clipboardServerCapabilitiesActions = {};
|
this._clipboardServerCapabilitiesActions = {};
|
||||||
this._clipboardServerCapabilitiesFormats = {};
|
this._clipboardServerCapabilitiesFormats = {};
|
||||||
|
@ -2250,11 +2252,18 @@ export default class RFB extends EventTargetMixin {
|
||||||
let first, ret;
|
let first, ret;
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case 0: // FramebufferUpdate
|
case 0: // FramebufferUpdate
|
||||||
|
let before = Date.now();
|
||||||
|
this._display.renderMs = 0;
|
||||||
ret = this._framebufferUpdate();
|
ret = this._framebufferUpdate();
|
||||||
if (ret && !this._enabledContinuousUpdates) {
|
if (ret && !this._enabledContinuousUpdates) {
|
||||||
RFB.messages.fbUpdateRequest(this._sock, true, 0, 0,
|
RFB.messages.fbUpdateRequest(this._sock, true, 0, 0,
|
||||||
this._fbWidth, this._fbHeight);
|
this._fbWidth, this._fbHeight);
|
||||||
}
|
}
|
||||||
|
let elapsed = Date.now() - before;
|
||||||
|
if (this._trackFrameStats) {
|
||||||
|
RFB.messages.sendFrameStats(this._sock, elapsed, this._display.renderMs);
|
||||||
|
this._trackFrameStats = false;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
case 1: // SetColorMapEntries
|
case 1: // SetColorMapEntries
|
||||||
|
@ -2287,6 +2296,10 @@ export default class RFB extends EventTargetMixin {
|
||||||
case 178: // KASM bottleneck stats
|
case 178: // KASM bottleneck stats
|
||||||
return this._handle_server_stats_msg();
|
return this._handle_server_stats_msg();
|
||||||
|
|
||||||
|
case 179: // KASM requesting frame stats
|
||||||
|
this._trackFrameStats = true;
|
||||||
|
return true;
|
||||||
|
|
||||||
case 248: // ServerFence
|
case 248: // ServerFence
|
||||||
return this._handleServerFenceMsg();
|
return this._handleServerFenceMsg();
|
||||||
|
|
||||||
|
@ -3035,6 +3048,32 @@ RFB.messages = {
|
||||||
sock.flush();
|
sock.flush();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sendFrameStats(sock, allMs, renderMs) {
|
||||||
|
const buff = sock._sQ;
|
||||||
|
const offset = sock._sQlen;
|
||||||
|
|
||||||
|
if (buff == null) { return; }
|
||||||
|
|
||||||
|
buff[offset] = 179; // msg-type
|
||||||
|
|
||||||
|
buff[offset + 1] = 0; // padding
|
||||||
|
buff[offset + 2] = 0; // padding
|
||||||
|
buff[offset + 3] = 0; // padding
|
||||||
|
|
||||||
|
buff[offset + 4] = allMs >> 24;
|
||||||
|
buff[offset + 5] = allMs >> 16;
|
||||||
|
buff[offset + 6] = allMs >> 8;
|
||||||
|
buff[offset + 7] = allMs;
|
||||||
|
|
||||||
|
buff[offset + 8] = renderMs >> 24;
|
||||||
|
buff[offset + 9] = renderMs >> 16;
|
||||||
|
buff[offset + 10] = renderMs >> 8;
|
||||||
|
buff[offset + 11] = renderMs;
|
||||||
|
|
||||||
|
sock._sQlen += 12;
|
||||||
|
sock.flush();
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
enableContinuousUpdates(sock, enable, x, y, width, height) {
|
enableContinuousUpdates(sock, enable, x, y, width, height) {
|
||||||
const buff = sock._sQ;
|
const buff = sock._sQ;
|
||||||
|
|
Loading…
Reference in New Issue