fune/browser/base/content/browser-graphics-utils.js
Andrew Osmond 84731cd82b Bug 1561367 - Implement initial support for capturing multiple frames. r=kvark
This patch adds support for the capture and replaying of multiple frames
during normal operation of Firefox. Ctrl + Shift + 6 starts capturing
and pressing it again stops capturing. It attempts to capture the minimum
amount of data required to replay a sequence for debugging purposes.

There are several known limitations, particularly surrounding replaying
when transitioning between snapshots of the resource cache. It will
reload the entire document set, causing greater delay between frames.
Should you advance too quickly, it may also panic due to a race between
the current frame still being generated, and the new frame resetting the
resource cache state. These should be resolved with time, and the
current implementation should be workable to at least capture/debug most
animated issues with some effort.

It also adds support for loading dynamic properties which is necessary
for accurate replaying of a captured frame (sequence or individual)
which are in the middle of an animation.

Differential Revision: https://phabricator.services.mozilla.com/D59755
2020-04-20 16:03:53 +00:00

52 lines
1.5 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This file is loaded into the browser window scope.
/* eslint-env mozilla/browser-window */
/**
* Global browser interface with graphics utilities.
*/
var gGfxUtils = {
_isRecording: false,
_isTransactionLogging: false,
init() {
if (Services.prefs.getBoolPref("gfx.webrender.enable-capture")) {
document.getElementById("wrCaptureCmd").removeAttribute("disabled");
document
.getElementById("wrToggleCaptureSequenceCmd")
.removeAttribute("disabled");
}
},
/**
* Toggle composition recording for the current window.
*/
toggleWindowRecording() {
window.windowUtils.setCompositionRecording(!this._isRecording);
this._isRecording = !this._isRecording;
},
/**
* Trigger a WebRender capture of the current state into a local folder.
*/
webrenderCapture() {
window.windowUtils.wrCapture();
},
/**
* Trigger a WebRender capture of the current state and future state
* into a local folder. If called again, it will stop capturing.
*/
toggleWebrenderCaptureSequence() {
window.windowUtils.wrToggleCaptureSequence();
},
/**
* Toggle transaction logging to text file.
*/
toggleTransactionLogging() {
window.windowUtils.setTransactionLogging(!this._isTransactionLogging);
this._isTransactionLogging = !this._isTransactionLogging;
},
};