diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/reproduceriter.js | 3 | ||||
-rwxr-xr-x | tools/reproduceriter.py | 23 | ||||
-rw-r--r-- | tools/reproduceriter_shell.js | 27 |
3 files changed, 39 insertions, 14 deletions
diff --git a/tools/reproduceriter.js b/tools/reproduceriter.js index 715052fb..9dce8199 100644 --- a/tools/reproduceriter.js +++ b/tools/reproduceriter.js @@ -40,7 +40,8 @@ var Recorder = (function() { return ret; }; recorder.pnows = []; - recorder.pnow = performance.now; + var pnow = performance.now || performance.webkitNow || performance.mozNow || performance.oNow || performance.msNow; + recorder.pnow = function() { return pnow.call(performance) }; performance.now = function() { var ret = recorder.pnow(); recorder.pnows.push(ret); diff --git a/tools/reproduceriter.py b/tools/reproduceriter.py index 89fcc41c..a1912396 100755 --- a/tools/reproduceriter.py +++ b/tools/reproduceriter.py @@ -1,9 +1,6 @@ #!/usr/bin/env python ''' - -* This is a work in progress * - Reproducer Rewriter =================== @@ -30,7 +27,8 @@ Usage: specified, we will make a build that runs in the shell and not in a browser. WINDOW_LOCATION is the fake window.location we set in the fake DOM, and ON_IDLE is code that runs when the fake main browser - event loop runs out of actions. + event loop runs out of actions. (Note that only a browser build can + do recording, shell builds just replay.) You will need to call @@ -86,7 +84,24 @@ Examples emscripten/tools/reproduceriter.py bb bench js/game-setup.js game.html?low,low,reproduce=repro.data "function(){ print('triggering click'); document.querySelector('.fullscreen-button.low-res').callEventListeners('click'); window.onIdle = null; }" + for a shell build, or + + emscripten/tools/reproduceriter.py bb bench js/game-setup.js + + for a browser build. Since only a browser build can do recording, you would normally + make a browser build, record a trace, then make a shell build and copy the trace + there so you can run it. + The last parameter specifies what to do when the event loop is idle: We fire an event and then set onIdle (which was this function) to null, so this is a one-time occurence. + +Notes + + * Replay can depend on browser state. One case is if you are replaying a fullscreen + game with pointer lock, then you will need to manually allow pointer lock if it + isn't already on for the machine. If you do it too early or too late, the replay + can be different, since mousemove events mean different things depending on + whether the pointer is locked or not. + ''' import os, sys, shutil, re diff --git a/tools/reproduceriter_shell.js b/tools/reproduceriter_shell.js index 05138797..f425df82 100644 --- a/tools/reproduceriter_shell.js +++ b/tools/reproduceriter_shell.js @@ -86,7 +86,8 @@ var document = { getElementById: function(id) { switch(id) { case 'canvas': { - return { + if (this.canvas) return this.canvas; + return this.canvas = { getContext: function(which) { switch(which) { case 'experimental-webgl': { @@ -650,6 +651,9 @@ var document = { bindRenderbuffer: function(){}, renderbufferStorage: function(){}, framebufferRenderbuffer: function(){}, + scissor: function(){}, + colorMask: function(){}, + lineWidth: function(){}, }; } case '2d': { @@ -668,18 +672,23 @@ var document = { } }, requestPointerLock: function() { - document.callEventListeners('pointerlockchange'); + document.pointerLockElement = document.getElementById('canvas'); + window.setTimeout(function() { + document.callEventListeners('pointerlockchange'); + }); }, style: {}, eventListeners: {}, addEventListener: document.addEventListener, callEventListeners: document.callEventListeners, requestFullScreen: function() { - var that = this; + document.fullscreenElement = document.getElementById('canvas'); window.setTimeout(function() { - that.callEventListeners('fullscreenchange'); + document.callEventListeners('fullscreenchange'); }); }, + offsetTop: 0, + offsetLeft: 0, }; } case 'status-text': case 'progress': { @@ -835,11 +844,11 @@ var Worker = function(workerPath) { }; Worker.id = 0; Worker.messageId = 0; -var screen = { - width: 800, - height: 600, - availWidth: 800, - availHeight: 600, +var screen = { // XXX these values may need to be adjusted + width: 2100, + height: 1313, + availWidth: 2100, + availHeight: 1283, }; var console = { log: function(x) { |