I have an element with a "pointerMove" EventListener added to it. Now when moving my mouse around, I can measure the number of data points "pointerMove" delivers per second (pps) by counting the total number of points drawn since "pointerDown" and dividing this by the time that passed since "pointerDown". So far, so good. What is strange though is the fact that I get a higher pps rate when the developer console is opened.
Example: Pressing my mouse button and then moving the cursor around chaotically gives me about 60pps. But when opening the developer console and then doing exactly the same, my pps rises to about 235 - almost 400% increase!
This test was done in Chrome 76 on Windows 10. Similar results may be obtained using Firefox. This issue also concerns input via touch or pen and is present in Chrome OS as well (behaviour on other operating systems has not yet been examined). Interestingly though Microsoft Edge seems not to be affected.
So the question is: Why does this happen? And how may I get the higher number of pps without having to open the developer console?
Executable example here: https://jsfiddle.net/Galveston01/unxmrchw/
var pointerid = undefined;
var start, count;
var canvas;
function startup() {
canvas = document.getElementById("canvas");
canvas.addEventListener("pointerdown", pointerdown, false);
canvas.addEventListener("pointermove", pointermove, false);
canvas.addEventListener("pointerup", pointerup, false);
canvas.addEventListener("pointercancel", pointerup, false);
canvas.addEventListener("touchstart", touch, false);
canvas.addEventListener("touchmove", touch, false);
canvas.addEventListener("touchend", touch, false);
canvas.addEventListener("touchcancel", touch, false);
}
function pointerdown(event) {
event.preventDefault();
rect = canvas.getBoundingClientRect();
if ((event.pointerType == "pen" || event.pointerType == "mouse") && pointerid == undefined) {
pointerid = event.pointerId;
var x = event.clientX - rect.left,
y = event.clientY - rect.top;
start = new Date().getTime();
count = 1;
}
}
function pointermove(event) {
event.preventDefault();
if (pointerid == event.pointerId) {
var x = event.clientX - rect.left,
y = event.clientY - rect.top;
count++;
}
}
function pointerup(event) {
event.preventDefault();
if (pointerid == event.pointerId) {
var x = event.clientX - rect.left,
y = event.clientY - rect.top;
pointerid = undefined;
count++;
console.log((count / (new Date().getTime() - start) * 1000) + "pps");
}
}
function touch(event) {
if (pointerid != undefined) {
event.preventDefault();
}
}
startup();
<div id="canvas" style="width:2000px; height:2000px; ">
</div>