Files
roytam1 45b8007f3d import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1150717 - Test request with no params in the Network Monitor. r=brings (a60e9e8d9)
- Bug 1168077 - Remove remaining spidermonkey js specific syntax from browser/devtools; r=miker (c98f20c30)
- Bug 1168125 - Fix existing tests, r=jsantell (b1dfa101e)
- Bug 1169439 - Pull out marker definitions into its own file, and move formatter and collapse functions into marker-utils. r=vp (17eb24ab3)
- Bug 1173654 - Part 1: Add logging methods for SurfaceType and ImageFormat. r=Bas (22f2fa019)
- Bug 1169125 - Part 1: Allow sending any DataSourceSurface-backed image over WebRTC and fix failure cases. r=bwc (1fb0def92)
- Bug 1169125 - Part 2: Use UniquePtr for scoped delete of yuv data in MediaPipeline. r=bwc (cdb79e201)
- Bug 1173654 - Part 2: Use namespaces in MediaPipeline.cpp. r=bwc (311696260)
- Bug 1173654 - Part 3: Attempt to GetDataSurface() and convert if sending pure I420 fails. r=bwc, r=jesup (58520b820)
- Bug 1173654 - Part 4: Add detailed logging and asserts to MediaPipeline::ProcessVideoChunk. r=bwc (ba08ae5bc)
- Bug 1155089 - Part 1: Reset |TrackID| for MediaPipelineTransmit::PipelineListener on replaceTrack(). r=bwc (304fb8703)
- adapted Bug 1142688 - Wait for actual audio data on remote side before checking audio sanity. r=jesup,padenot (479f6356c)
- Bug 858927 - Move the mozilla::TimeStamp into mozglue. r=glandium (751938e09)
- Bug 1166559 - Add documentation for ProfileTimelineMarkers from a dev tools perspective. r=fitzgen (ed1563dfb)
- Bug 1141614 - Part 4: Expose cycle collection markers in the devtools frontend; r=jsantell (2eb830de7)
2021-07-30 11:25:34 +08:00

153 lines
5.0 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/. */
"use strict";
const { ViewHelpers } = require("resource:///modules/devtools/ViewHelpers.jsm");
/**
* Localization convenience methods.
+ TODO: merge these into a single file: Bug 1082695.
*/
const L10N = new ViewHelpers.MultiL10N([
"chrome://browser/locale/devtools/timeline.properties",
"chrome://browser/locale/devtools/profiler.properties"
]);
/**
* A list of preferences for this tool. The values automatically update
* if somebody edits edits about:config or the prefs change somewhere else.
*/
const PREFS = new ViewHelpers.Prefs("devtools.performance", {
"show-platform-data": ["Bool", "ui.show-platform-data"],
"hidden-markers": ["Json", "timeline.hidden-markers"],
"memory-sample-probability": ["Float", "memory.sample-probability"],
"memory-max-log-length": ["Int", "memory.max-log-length"],
"profiler-buffer-size": ["Int", "profiler.buffer-size"],
"profiler-sample-frequency": ["Int", "profiler.sample-frequency-khz"],
}, {
monitorChanges: true
});
/**
* Details about each profile entry cateogry.
* @see CATEGORY_MAPPINGS.
*/
const CATEGORIES = [{
color: "#5e88b0",
abbrev: "other",
label: L10N.getStr("category.other")
}, {
color: "#46afe3",
abbrev: "css",
label: L10N.getStr("category.css")
}, {
color: "#d96629",
abbrev: "js",
label: L10N.getStr("category.js")
}, {
color: "#eb5368",
abbrev: "gc",
label: L10N.getStr("category.gc")
}, {
color: "#df80ff",
abbrev: "network",
label: L10N.getStr("category.network")
}, {
color: "#70bf53",
abbrev: "graphics",
label: L10N.getStr("category.graphics")
}, {
color: "#8fa1b2",
abbrev: "storage",
label: L10N.getStr("category.storage")
}, {
color: "#d99b28",
abbrev: "events",
label: L10N.getStr("category.events")
}];
/**
* Mapping from category bitmasks in the profiler data to additional details.
* To be kept in sync with the js::ProfileEntry::Category in ProfilingStack.h
*/
const CATEGORY_MAPPINGS = {
"16": CATEGORIES[0], // js::ProfileEntry::Category::OTHER
"32": CATEGORIES[1], // js::ProfileEntry::Category::CSS
"64": CATEGORIES[2], // js::ProfileEntry::Category::JS
"128": CATEGORIES[3], // js::ProfileEntry::Category::GC
"256": CATEGORIES[3], // js::ProfileEntry::Category::CC
"512": CATEGORIES[4], // js::ProfileEntry::Category::NETWORK
"1024": CATEGORIES[5], // js::ProfileEntry::Category::GRAPHICS
"2048": CATEGORIES[6], // js::ProfileEntry::Category::STORAGE
"4096": CATEGORIES[7], // js::ProfileEntry::Category::EVENTS
};
/**
* Get the numeric bitmask (or set of masks) for the given category
* abbreviation. See CATEGORIES and CATEGORY_MAPPINGS above.
*
* CATEGORY_MASK can be called with just a name if it is expected that the
* category is mapped to by exactly one bitmask. If the category is mapped
* to by multiple masks, CATEGORY_MASK for that name must be called with
* an additional argument specifying the desired id (in ascending order).
*/
const [CATEGORY_MASK, CATEGORY_MASK_LIST] = (function () {
let bitmasksForCategory = {};
let all = Object.keys(CATEGORY_MAPPINGS);
for (let category of CATEGORIES) {
bitmasksForCategory[category.abbrev] = all
.filter(mask => CATEGORY_MAPPINGS[mask] == category)
.map(mask => +mask)
.sort();
}
return [
function (name, index) {
if (!(name in bitmasksForCategory)) {
throw new Error(`Category abbreviation '${name}' does not exist.`);
}
if (arguments.length == 1) {
if (bitmasksForCategory[name].length != 1) {
throw new Error(`Expected exactly one category number for '${name}'.`);
} else {
return bitmasksForCategory[name][0];
}
} else {
if (index > bitmasksForCategory[name].length) {
throw new Error(`Index '${index}' too high for category '${name}'.`);
} else {
return bitmasksForCategory[name][index - 1];
}
}
},
function (name) {
if (!(name in bitmasksForCategory)) {
throw new Error(`Category abbreviation '${name}' does not exist.`);
}
return bitmasksForCategory[name];
}
];
})();
// Human-readable "other" category bitmask. Older Geckos don't have all the
// necessary instrumentation in the sampling profiler backend for creating
// a categories graph, in which case we default to the "other" category.
const CATEGORY_OTHER = CATEGORY_MASK('other');
// Human-readable JIT category bitmask. Certain pseudo-frames in a sample,
// like "EnterJIT", don't have any associated `cateogry` information.
const CATEGORY_JIT = CATEGORY_MASK('js');
// Exported symbols.
exports.L10N = L10N;
exports.PREFS = PREFS;
exports.CATEGORIES = CATEGORIES;
exports.CATEGORY_MAPPINGS = CATEGORY_MAPPINGS;
exports.CATEGORY_MASK = CATEGORY_MASK;
exports.CATEGORY_MASK_LIST = CATEGORY_MASK_LIST;
exports.CATEGORY_OTHER = CATEGORY_OTHER;
exports.CATEGORY_JIT = CATEGORY_JIT;