S053: remove vendor crates, gst-mse, assets/servo, epaint patch, spike harness
This commit is contained in:
parent
4153c5a851
commit
38fd033745
1892 changed files with 3 additions and 488133 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -793,6 +793,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epaint"
|
name = "epaint"
|
||||||
version = "0.37.0"
|
version = "0.37.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "97bac86ae3dde93fc3951e790951caea739ff39a6c89d909cdaf1d9278dbb1bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,3 @@ opt-level = 1
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
opt-level = 2
|
opt-level = 2
|
||||||
|
|
||||||
# epaint 0.37.0 panicked when Servo's canvas enabled vello_cpu multithreading; the vendored copy renders glyphs
|
|
||||||
# single-threaded (vendor/epaint/src/text/font_face.rs, end of file). Kept until S053 re-checks egui text without Servo.
|
|
||||||
[patch.crates-io]
|
|
||||||
epaint = { path = "vendor/epaint" }
|
|
||||||
|
|
|
||||||
|
|
@ -1,223 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>about:memory</title>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", start);
|
|
||||||
|
|
||||||
function insertNode(root, report) {
|
|
||||||
let currentNode = root;
|
|
||||||
for (let path of report.path) {
|
|
||||||
if (!currentNode[path]) {
|
|
||||||
currentNode[path] = { total: 0, container: true };
|
|
||||||
}
|
|
||||||
currentNode = currentNode[path];
|
|
||||||
currentNode.total += report.size;
|
|
||||||
}
|
|
||||||
currentNode.size = report.size;
|
|
||||||
currentNode.container = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatBytes(bytes) {
|
|
||||||
if (bytes < 1024) {
|
|
||||||
return bytes + " B";
|
|
||||||
} else if (bytes < 1024 * 1024) {
|
|
||||||
return (bytes / 1024).toFixed(2) + " KiB";
|
|
||||||
} else if (bytes < 1024 * 1024 * 1024) {
|
|
||||||
return (bytes / (1024 * 1024)).toFixed(2) + " MiB";
|
|
||||||
} else {
|
|
||||||
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GiB";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formattedSize(size) {
|
|
||||||
// Use enough padding to take into account the "MiB" part.
|
|
||||||
return formatBytes(size).padStart(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertNodeToDOM(node, name = null) {
|
|
||||||
let result = document.createDocumentFragment();
|
|
||||||
|
|
||||||
if (node.container) {
|
|
||||||
let details = document.createElement("details");
|
|
||||||
let summary = document.createElement("summary");
|
|
||||||
summary.textContent = `${formattedSize(node.total)} -- ${name}`;
|
|
||||||
details.append(summary);
|
|
||||||
result.append(details);
|
|
||||||
|
|
||||||
// Add the children in descending order of total size.
|
|
||||||
let entries = Object.entries(node)
|
|
||||||
.filter((item) => {
|
|
||||||
return !["total", "size", "container"].includes(item[0]);
|
|
||||||
})
|
|
||||||
.sort((a, b) => b[1].total - a[1].total)
|
|
||||||
.forEach((item) =>
|
|
||||||
details.append(convertNodeToDOM(item[1], item[0]))
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
let inner = document.createElement("div");
|
|
||||||
inner.textContent = `${formattedSize(node.size)} -- ${name}`;
|
|
||||||
result.append(inner);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function reportsForProcess(processReport) {
|
|
||||||
let explicitRoot = {};
|
|
||||||
let nonExplicitRoot = {};
|
|
||||||
|
|
||||||
let jemallocHeapReportedSize = 0;
|
|
||||||
let systemHeapReportedSize = 0;
|
|
||||||
|
|
||||||
let jemallocHeapAllocatedSize = NaN;
|
|
||||||
let systemHeapAllocatedSize = NaN;
|
|
||||||
|
|
||||||
// In content processes, get the list of urls.
|
|
||||||
let urls = new Set();
|
|
||||||
|
|
||||||
processReport.reports.forEach((report) => {
|
|
||||||
if (report.path[0].startsWith("url(")) {
|
|
||||||
// This can be a list of urls.
|
|
||||||
let path_urls = report.path[0].slice(4, -1).split(", ");
|
|
||||||
path_urls.forEach((url) => urls.add(url));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add "explicit" to the start of the path, when appropriate.
|
|
||||||
if (report.kind.startsWith("Explicit")) {
|
|
||||||
report.path.unshift("explicit");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the reported fractions of the heaps, when appropriate.
|
|
||||||
if (report.kind == "ExplicitJemallocHeapSize") {
|
|
||||||
jemallocHeapReportedSize += report.size;
|
|
||||||
} else if (report.kind == "ExplicitSystemHeapSize") {
|
|
||||||
systemHeapReportedSize += report.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Record total size of the heaps, when we see them.
|
|
||||||
if (report.path.length == 1) {
|
|
||||||
if (report.path[0] == "jemalloc-heap-allocated") {
|
|
||||||
jemallocHeapAllocatedSize = report.size;
|
|
||||||
} else if (report.path[0] == "system-heap-allocated") {
|
|
||||||
systemHeapAllocatedSize = report.size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert this report at the proper position.
|
|
||||||
insertNode(
|
|
||||||
report.kind.startsWith("Explicit") ? explicitRoot : nonExplicitRoot,
|
|
||||||
report
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Compute and insert the heap-unclassified values.
|
|
||||||
if (!isNaN(jemallocHeapAllocatedSize)) {
|
|
||||||
insertNode(explicitRoot, {
|
|
||||||
path: ["explicit", "jemalloc-heap-unclassified"],
|
|
||||||
size: jemallocHeapAllocatedSize - jemallocHeapReportedSize,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!isNaN(systemHeapAllocatedSize)) {
|
|
||||||
insertNode(explicitRoot, {
|
|
||||||
path: ["explicit", "system-heap-unclassified"],
|
|
||||||
size: systemHeapAllocatedSize - systemHeapReportedSize,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the DOM structure for each process report:
|
|
||||||
// <div class=process> <h4>...<h4> <pre> ...</pre> </div>
|
|
||||||
let container = document.createElement("div");
|
|
||||||
container.classList.add("process");
|
|
||||||
let reportTitle = document.createElement("h4");
|
|
||||||
reportTitle.textContent = `${
|
|
||||||
processReport.isMainProcess ? "Main Process" : "Content Process"
|
|
||||||
} (pid ${processReport.pid}) ${[...urls.values()].join(", ")}`;
|
|
||||||
|
|
||||||
container.append(reportTitle);
|
|
||||||
let reportNode = document.createElement("pre");
|
|
||||||
reportNode.classList.add("report");
|
|
||||||
container.append(reportNode);
|
|
||||||
|
|
||||||
reportNode.append(convertNodeToDOM(explicitRoot.explicit, "explicit"));
|
|
||||||
|
|
||||||
for (let prop in nonExplicitRoot) {
|
|
||||||
reportNode.append(convertNodeToDOM(nonExplicitRoot[prop], prop));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we always put the main process first.
|
|
||||||
if (processReport.isMainProcess) {
|
|
||||||
window.reports.prepend(container);
|
|
||||||
} else {
|
|
||||||
window.reports.append(container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function start() {
|
|
||||||
window.gcButton.onclick = async () => {
|
|
||||||
window.gcButton.disabled = true;
|
|
||||||
navigator.servo.garbageCollectAllContexts();
|
|
||||||
window.gcButton.disabled = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
window.startButton.onclick = async () => {
|
|
||||||
let content = await navigator.servo.reportMemory();
|
|
||||||
let reports = JSON.parse(content);
|
|
||||||
if (reports.error) {
|
|
||||||
console.error(reports.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.reports.innerHTML = "";
|
|
||||||
window.reports.classList.remove("hidden");
|
|
||||||
|
|
||||||
if (!Array.isArray(reports)) {
|
|
||||||
console.error("Unexpected memory report format!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
reports.forEach(reportsForProcess);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
details,
|
|
||||||
details div {
|
|
||||||
margin-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
summary:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.process {
|
|
||||||
margin: 0.5em;
|
|
||||||
border: 2px solid gray;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 5px;
|
|
||||||
background-color: lightgray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report {
|
|
||||||
line-height: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report > details {
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>Memory Reports</h2>
|
|
||||||
<button id="startButton">Measure</button>
|
|
||||||
<button id="gcButton">Force GC</button>
|
|
||||||
<div id="reports" class="hidden"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>This page crashed</title>
|
|
||||||
<style>
|
|
||||||
:root { font-family: system-ui, sans-serif; --bg: #fdfbff; --text: #1a1b1f; --muted: #44474e; --card: #f1f0f4; --primary: #415f91; --on-primary: #ffffff; --tonal: #d6e3ff; --on-tonal: #001b3e; --error: #ffdad6; --on-error: #410002; --line: #c4c6d0; }
|
|
||||||
@media (prefers-color-scheme: dark) { :root { --bg: #101114; --text: #e3e2e6; --muted: #c4c6d0; --card: #1d1e22; --primary: #aac7ff; --on-primary: #0a305f; --tonal: #284777; --on-tonal: #d6e3ff; --error: #93000a; --on-error: #ffdad6; --line: #44474e; } }
|
|
||||||
html { background: var(--bg); color: var(--text); }
|
|
||||||
body { max-width: 600px; margin: 14vh auto; padding: 0 24px; line-height: 1.5; text-align: center; background: var(--bg); color: var(--text); }
|
|
||||||
.mark { width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 50%; background: var(--error); color: var(--on-error); font-size: 34px; font-weight: 600; line-height: 72px; }
|
|
||||||
h1 { font-size: 1.75em; font-weight: 600; margin: 0 0 8px; }
|
|
||||||
p { margin: 8px 0; color: var(--muted); }
|
|
||||||
p.url { word-break: break-all; color: var(--text); }
|
|
||||||
code, pre { font-family: ui-monospace, monospace; word-break: break-all; }
|
|
||||||
.detail { font-size: 0.85em; }
|
|
||||||
.actions { margin-top: 28px; }
|
|
||||||
button { font: inherit; font-weight: 600; height: 40px; padding: 0 24px; margin: 0 4px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--primary); cursor: pointer; }
|
|
||||||
button.main { border-color: transparent; background: var(--primary); color: var(--on-primary); }
|
|
||||||
button:hover { filter: brightness(1.08); }
|
|
||||||
details { margin-top: 20px; text-align: left; color: var(--muted); }
|
|
||||||
details pre { white-space: pre-wrap; font-size: 12px; background: var(--card); padding: 12px; border-radius: 12px; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="mark">!</div>
|
|
||||||
<h1>This page crashed</h1>
|
|
||||||
<p>Something on the page broke the engine. Reloading usually fixes it. The details are also written to pages.log in Nacre's data folder.</p>
|
|
||||||
<!-- Reloading turns a POST into a GET; see whatwg/html#6600. -->
|
|
||||||
<div class="actions"><button class="main" onclick="location.reload()">Reload</button></div>
|
|
||||||
<details><summary>Details</summary><pre><plaintext>
|
|
||||||
${details}
|
|
||||||
|
|
@ -1,957 +0,0 @@
|
||||||
if ("dbg" in this) {
|
|
||||||
throw new Error("Debugger script must not run more than once!");
|
|
||||||
}
|
|
||||||
|
|
||||||
const dbg = new Debugger;
|
|
||||||
const debuggeesToPipelineIds = new Map;
|
|
||||||
const debuggeesToWorkerIds = new Map;
|
|
||||||
const sourceIdsToScripts = new Map;
|
|
||||||
const frameActorsToFrames = new Map;
|
|
||||||
const objectActorsToObjects = new Map;
|
|
||||||
const environmentsToEnvironmentActors = new Map;
|
|
||||||
const blackboxing = new Map;
|
|
||||||
let suspendedFrame = null;
|
|
||||||
let lastPauseLocation = null;
|
|
||||||
let debuggerPaused = false;
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/thread.js#155>
|
|
||||||
// Possible values for the `why.type` attribute in "paused" event
|
|
||||||
const PAUSE_REASONS = {
|
|
||||||
INTERRUPTED: "interrupted", // Associated with why.onNext attribute
|
|
||||||
RESUME_LIMIT: "resumeLimit",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find script by scriptId within a script tree
|
|
||||||
function findScriptById(script, scriptId) {
|
|
||||||
if (script.sourceStart === scriptId) {
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
for (const child of script.getChildScripts()) {
|
|
||||||
const found = findScriptById(child, scriptId);
|
|
||||||
if (found) return found;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Walk script tree and call callback for each script
|
|
||||||
function walkScriptTree(script, callback) {
|
|
||||||
callback(script);
|
|
||||||
for (const child of script.getChildScripts()) {
|
|
||||||
walkScriptTree(child, callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a key by a value in a map
|
|
||||||
function findKeyByValue(map, search) {
|
|
||||||
for (const [key, value] of map) {
|
|
||||||
if (value === search) return key;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The === operator isn't really applicable to pipelineId
|
|
||||||
function findDebuggeeByPipelineId(search) {
|
|
||||||
for (const [key, value] of debuggeesToPipelineIds) {
|
|
||||||
if (value.namespaceId == search.namespaceId && value.index == search.index) {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbg.uncaughtExceptionHook = function(error) {
|
|
||||||
console.error(`[debugger] Uncaught exception at ${error.fileName}:${error.lineNumber}:${error.columnNumber}: ${error.name}: ${error.message}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
dbg.onNewScript = function(script) {
|
|
||||||
// TODO: handle wasm (`script.source.introductionType == wasm`)
|
|
||||||
sourceIdsToScripts.set(script.source.id, script);
|
|
||||||
notifyNewSource({
|
|
||||||
pipelineId: debuggeesToPipelineIds.get(script.global),
|
|
||||||
workerId: debuggeesToWorkerIds.get(script.global),
|
|
||||||
spidermonkeyId: script.source.id,
|
|
||||||
url: script.source.url,
|
|
||||||
urlOverride: script.source.displayURL,
|
|
||||||
text: script.source.text,
|
|
||||||
introductionType: script.source.introductionType ?? null,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Track a new debuggee global
|
|
||||||
addEventListener("addDebuggee", event => {
|
|
||||||
const {global, pipelineId, workerId} = event;
|
|
||||||
const debuggerObject = dbg.addDebuggee(global);
|
|
||||||
debuggeesToPipelineIds.set(debuggerObject, pipelineId);
|
|
||||||
if (workerId !== undefined) {
|
|
||||||
debuggeesToWorkerIds.set(debuggerObject, workerId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Convert debuggee value to property descriptor value
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/object/utils.js#116>
|
|
||||||
function createValueGrip(value, depth) {
|
|
||||||
switch (typeof value) {
|
|
||||||
case "undefined":
|
|
||||||
return "VoidValue";
|
|
||||||
case "boolean":
|
|
||||||
return { BooleanValue: value };
|
|
||||||
case "number":
|
|
||||||
if (value === Infinity) {
|
|
||||||
return { NumberValue: "Infinity" };
|
|
||||||
} else if (value === -Infinity) {
|
|
||||||
return { NumberValue: "-Infinity" };
|
|
||||||
} else if (Number.isNaN(value)) {
|
|
||||||
return { NumberValue: "NaN" };
|
|
||||||
} else if (Object.is(value, -0)) {
|
|
||||||
return { NumberValue: "-0" };
|
|
||||||
}
|
|
||||||
return { NumberValue: value };
|
|
||||||
case "string":
|
|
||||||
return { StringValue: value };
|
|
||||||
case "object":
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/object/utils.js#153>
|
|
||||||
if (value === null) {
|
|
||||||
return { NullValue: false };
|
|
||||||
}
|
|
||||||
if (value.uninitialized) {
|
|
||||||
return { NullValue: true };
|
|
||||||
}
|
|
||||||
if (value.optimizedOut || value.missingArguments) {
|
|
||||||
return { NullValue: false };
|
|
||||||
}
|
|
||||||
// TODO: handle typed arrays and storage independently
|
|
||||||
const ownPropertyLength = value.getOwnPropertyNamesLength();
|
|
||||||
let objectActorId = findKeyByValue(objectActorsToObjects, value);
|
|
||||||
const objectValue = {
|
|
||||||
class: value.class,
|
|
||||||
ownPropertyLength: Number.isFinite(ownPropertyLength) ? ownPropertyLength : undefined,
|
|
||||||
};
|
|
||||||
// Debugger.Object - get preview using registered previewers
|
|
||||||
// <https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.object/index.html>
|
|
||||||
const preview = getPreview(value, depth + 1);
|
|
||||||
if (!preview) {
|
|
||||||
// Reusing an actor with a stored preview can cause recursion, we should handle it properly at some point.
|
|
||||||
return { ObjectValue: objectValue };
|
|
||||||
}
|
|
||||||
objectValue.preview = preview;
|
|
||||||
|
|
||||||
if (!objectActorId) {
|
|
||||||
objectActorId = registerObjectActor(JSON.stringify({ ObjectValue: objectValue }));
|
|
||||||
if (!objectActorId) {
|
|
||||||
console.error("[debugger] Couldn't create object actor");
|
|
||||||
return { ObjectValue: objectValue };
|
|
||||||
}
|
|
||||||
objectActorsToObjects.set(objectActorId, value);
|
|
||||||
}
|
|
||||||
objectValue.actor = objectActorId;
|
|
||||||
return { ObjectValue: objectValue };
|
|
||||||
default:
|
|
||||||
return { StringValue: String(value) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract own properties from a debuggee object
|
|
||||||
// <https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.object/index.html#function-properties-of-the-debugger-object-prototype>
|
|
||||||
function extractOwnProperties(obj, depth) {
|
|
||||||
const ownProperties = [];
|
|
||||||
let totalLength = 0;
|
|
||||||
|
|
||||||
let names;
|
|
||||||
try {
|
|
||||||
names = obj.getOwnPropertyNames();
|
|
||||||
totalLength = names.length;
|
|
||||||
} catch (e) {
|
|
||||||
return { ownProperties, ownPropertiesLength: 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const name of names) {
|
|
||||||
try {
|
|
||||||
const desc = obj.getOwnPropertyDescriptor(name);
|
|
||||||
if (desc) {
|
|
||||||
const prop = {
|
|
||||||
name: name,
|
|
||||||
configurable: desc.configurable ?? false,
|
|
||||||
enumerable: desc.enumerable ?? false,
|
|
||||||
writable: desc.writable ?? false,
|
|
||||||
isAccessor: desc.get !== undefined || desc.set !== undefined,
|
|
||||||
value: createValueGrip(undefined, depth + 1),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (desc.value !== undefined) {
|
|
||||||
prop.value = createValueGrip(desc.value, depth + 1);
|
|
||||||
} else if (desc.get) {
|
|
||||||
try {
|
|
||||||
const result = desc.get.call(obj);
|
|
||||||
if (result && "return" in result) {
|
|
||||||
prop.value = createValueGrip(result.return, depth + 1);
|
|
||||||
}
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
ownProperties.push(prop);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// For now skip properties that throw on access
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { ownProperties, ownPropertiesLength: totalLength };
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://searchfox.org/mozilla-central/source/devtools/server/actors/object/previewers.js#80>
|
|
||||||
const previewers = {};
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/shared/DevToolsUtils.js#182>
|
|
||||||
function getProperty(object, name) {
|
|
||||||
const root = object;
|
|
||||||
while (object) {
|
|
||||||
let desc;
|
|
||||||
try {
|
|
||||||
desc = object.getOwnPropertyDescriptor(name);
|
|
||||||
} catch (e) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (desc) {
|
|
||||||
if ("value" in desc) {
|
|
||||||
return desc.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (desc.get) {
|
|
||||||
try {
|
|
||||||
return desc.get.call(root)?.return;
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
object = object.proto;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calls the property with the given `name` on the given `object`, where
|
|
||||||
// `name` is a string, and `object` a Debugger.Object instance.
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/shared/DevToolsUtils.js#943>
|
|
||||||
function callPropertyOnObject(object, name, ...args) {
|
|
||||||
let descriptor;
|
|
||||||
let proto = object;
|
|
||||||
do {
|
|
||||||
descriptor = proto.getOwnPropertyDescriptor(name);
|
|
||||||
if (descriptor !== undefined) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
proto = proto.proto;
|
|
||||||
} while (proto !== null);
|
|
||||||
|
|
||||||
if (descriptor === undefined) {
|
|
||||||
throw new Error("No such property");
|
|
||||||
}
|
|
||||||
|
|
||||||
const value = descriptor.value;
|
|
||||||
if (typeof value !== "object" || value === null || !("callable" in value)) {
|
|
||||||
throw new Error("Not a callable object.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value.script !== undefined) {
|
|
||||||
throw new Error(
|
|
||||||
"The property isn't a native function and will execute code in the debuggee"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = value.call(object, ...args);
|
|
||||||
if (result === null) {
|
|
||||||
throw new Error("Code was terminated.");
|
|
||||||
}
|
|
||||||
if ("throw" in result) {
|
|
||||||
throw result.throw;
|
|
||||||
}
|
|
||||||
return result.return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/shared/DevToolsUtils.js#983>
|
|
||||||
function* makeDebuggeeIterator(object) {
|
|
||||||
while (true) {
|
|
||||||
const nextValue = callPropertyOnObject(object, "next");
|
|
||||||
if (getProperty(nextValue, "done")) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
yield getProperty(nextValue, "value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://searchfox.org/mozilla-central/source/devtools/server/actors/object/previewers.js#125>
|
|
||||||
previewers.Function = [ function FunctionPreviewer(obj, depth) {
|
|
||||||
let functionDetails = {
|
|
||||||
name: obj.name,
|
|
||||||
displayName: obj.displayName,
|
|
||||||
parameterNames: obj.parameterNames ? obj.parameterNames: [],
|
|
||||||
isAsync: obj.isAsyncFunction,
|
|
||||||
isGenerator: obj.isGeneratorFunction,
|
|
||||||
}
|
|
||||||
|
|
||||||
let preview = { kind: "Object", function: functionDetails };
|
|
||||||
if (depth > 1) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { ownProperties, ownPropertiesLength } = extractOwnProperties(obj, depth);
|
|
||||||
preview.ownProperties = ownProperties;
|
|
||||||
preview.ownPropertiesLength = ownPropertiesLength;
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
} ];
|
|
||||||
|
|
||||||
// <https://searchfox.org/mozilla-central/source/devtools/server/actors/object/previewers.js#172>
|
|
||||||
previewers.Array = [ function ArrayPreviewer(obj, depth) {
|
|
||||||
const lengthDescriptor = obj.getOwnPropertyDescriptor("length");
|
|
||||||
const arrayLength = lengthDescriptor ? lengthDescriptor.value : 0;
|
|
||||||
|
|
||||||
let preview = { kind: "ArrayLike", arrayLength };
|
|
||||||
if (depth > 1) {
|
|
||||||
return preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
preview.items = [];
|
|
||||||
for (let i = 0; i < arrayLength; i++) {
|
|
||||||
const desc = obj.getOwnPropertyDescriptor(i);
|
|
||||||
if (desc && desc.value !== undefined) {
|
|
||||||
preview.items.push(createValueGrip(desc.value, depth + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
} ];
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/object/property-iterator.js#298>
|
|
||||||
function enumMapEntries(obj, depth) {
|
|
||||||
const entries = makeDebuggeeIterator(callPropertyOnObject(obj, "entries"));
|
|
||||||
return {
|
|
||||||
*[Symbol.iterator]() {
|
|
||||||
for (const entry of entries) {
|
|
||||||
yield [
|
|
||||||
getProperty(entry, 0),
|
|
||||||
getProperty(entry, 1),
|
|
||||||
].map(value => createValueGrip(value, depth));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/object/previewers.js#450>
|
|
||||||
previewers.Map = [ function MapPreviewer(object, depth) {
|
|
||||||
const size = getProperty(object, "size");
|
|
||||||
if (typeof size !== "number") {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
let preview = { kind: "MapLike", size };
|
|
||||||
if (depth > 1) {
|
|
||||||
return preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
preview.entries = [];
|
|
||||||
for (const entry of enumMapEntries(object, depth)) {
|
|
||||||
preview.entries.push(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
} ];
|
|
||||||
|
|
||||||
// Generic fallback for object previewer
|
|
||||||
// <https://searchfox.org/mozilla-central/source/devtools/server/actors/object/previewers.js#856>
|
|
||||||
previewers.Object = [ function ObjectPreviewer(obj, depth) {
|
|
||||||
let preview = { kind: "Object" };
|
|
||||||
if (depth > 1) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { ownProperties, ownPropertiesLength } = extractOwnProperties(obj, depth);
|
|
||||||
preview.ownProperties = ownProperties;
|
|
||||||
preview.ownPropertiesLength = ownPropertiesLength;
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
} ];
|
|
||||||
|
|
||||||
function getPreview(obj, depth) {
|
|
||||||
const className = obj.class;
|
|
||||||
|
|
||||||
// <https://searchfox.org/mozilla-central/source/devtools/server/actors/object.js#295>
|
|
||||||
const typePreviewers = previewers[className] || previewers.Object;
|
|
||||||
for (const previewer of typePreviewers) {
|
|
||||||
try {
|
|
||||||
const result = previewer(obj, depth);
|
|
||||||
if (result) return result;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[debugger] Couldn't populate ${className} preview: ${e}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Evaluate some javascript code in the global context of the debuggee
|
|
||||||
// See executeInGlobal() at <https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.object/index.html#function-properties-of-the-debugger-object-prototype>
|
|
||||||
addEventListener("eval", event => {
|
|
||||||
const { code, pipelineId, workerId, frameActorId } = event;
|
|
||||||
|
|
||||||
let frame;
|
|
||||||
if (frameActorId) {
|
|
||||||
frame = frameActorsToFrames.get(frameActorId);
|
|
||||||
}
|
|
||||||
let global = workerId !== undefined ?
|
|
||||||
findKeyByValue(debuggeesToWorkerIds, workerId) :
|
|
||||||
findDebuggeeByPipelineId(pipelineId);
|
|
||||||
|
|
||||||
let noSideEffectDebugger;
|
|
||||||
if (event.eager) {
|
|
||||||
noSideEffectDebugger = createSideEffectFreeDebugger(global);
|
|
||||||
|
|
||||||
// We need to eval in the context of the temporary debugger to apply side-effect tracking
|
|
||||||
if (frame) {
|
|
||||||
frame = noSideEffectDebugger.adoptFrame(frame);
|
|
||||||
} else {
|
|
||||||
global = noSideEffectDebugger.adoptDebuggeeValue(global);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
let completionValue;
|
|
||||||
if (frame) {
|
|
||||||
// <https://searchfox.org/firefox-main/source/js/src/doc/Debugger/Debugger.Frame.md#223>
|
|
||||||
if (frame?.onStack) {
|
|
||||||
completionValue = frame.eval(code);
|
|
||||||
} else {
|
|
||||||
completionValue = { throw: "Frame not available" };
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
completionValue = global.executeInGlobal(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Completion values: <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#completion-values>
|
|
||||||
let resultValue;
|
|
||||||
if (completionValue === null) {
|
|
||||||
resultValue = {
|
|
||||||
value: createValueGrip(undefined, 0),
|
|
||||||
hasException: false,
|
|
||||||
};
|
|
||||||
} else if ("throw" in completionValue) {
|
|
||||||
let exceptionMessage = null;
|
|
||||||
if (typeof completionValue.throw.unsafeDereference === "function") {
|
|
||||||
const deref = completionValue.throw.unsafeDereference();
|
|
||||||
if (typeof deref.message === "string") {
|
|
||||||
exceptionMessage = deref.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!exceptionMessage) {
|
|
||||||
exceptionMessage = `Uncaught ${completionValue.throw}`;
|
|
||||||
}
|
|
||||||
resultValue = {
|
|
||||||
value: createValueGrip(completionValue.throw, 0),
|
|
||||||
exceptionMessage,
|
|
||||||
hasException: true,
|
|
||||||
};
|
|
||||||
} else if ("return" in completionValue) {
|
|
||||||
resultValue = {
|
|
||||||
value: createValueGrip(completionValue.return, 0),
|
|
||||||
hasException: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
evalResult(event, {
|
|
||||||
serializedValue: JSON.stringify(resultValue.value),
|
|
||||||
exceptionMessage: resultValue.hasException ? resultValue.exceptionMessage : null,
|
|
||||||
hasException: resultValue.hasException,
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
if (noSideEffectDebugger) {
|
|
||||||
noSideEffectDebugger.onNativeCall = undefined;
|
|
||||||
noSideEffectDebugger.shouldAvoidSideEffects = false;
|
|
||||||
|
|
||||||
// This must be called last as the cleanup above depends on the list of debuggees
|
|
||||||
noSideEffectDebugger.removeAllDebuggees();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/webconsole/eval-with-debugger.js#436>
|
|
||||||
function createSideEffectFreeDebugger(debuggee) {
|
|
||||||
const eagerDbg = new Debugger;
|
|
||||||
|
|
||||||
// Special flag in order to ensure that any evaluation or call being
|
|
||||||
// made via this debugger will be ignored by all debuggers except this one.
|
|
||||||
eagerDbg.exclusiveDebuggerOnEval = true;
|
|
||||||
|
|
||||||
// TODO: Add other debuggees that the evaluation might use
|
|
||||||
eagerDbg.addDebuggee(debuggee.unsafeDereference());
|
|
||||||
|
|
||||||
const timeoutDuration = 100;
|
|
||||||
const endTime = Date.now() + timeoutDuration;
|
|
||||||
let count = 0;
|
|
||||||
function shouldCancel() {
|
|
||||||
// To keep the evaled code as quick as possible, we avoid querying the
|
|
||||||
// current time on ever single step and instead check every 100 steps
|
|
||||||
// as an arbitrary count that seemed to be "often enough".
|
|
||||||
return ++count % 100 === 0 && Date.now() > endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
const executedScripts = new Set();
|
|
||||||
const handler = {
|
|
||||||
hit: () => null,
|
|
||||||
};
|
|
||||||
// null means abort; undefined means continue
|
|
||||||
eagerDbg.onEnterFrame = frame => {
|
|
||||||
if (shouldCancel()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
frame.onStep = () => {
|
|
||||||
if (shouldCancel()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const script = frame.script;
|
|
||||||
if (executedScripts.has(script)) {
|
|
||||||
// Skip setting breakpoints in the same script again
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
executedScripts.add(script);
|
|
||||||
|
|
||||||
const offsets = script.getEffectfulOffsets();
|
|
||||||
for (const offset of offsets) {
|
|
||||||
script.setBreakpoint(offset, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
eagerDbg.onNativeCall = (_callee, _reason) => {
|
|
||||||
// TODO: Allow side-effect-free native calls
|
|
||||||
// Aborting on all native calls is naïve but safe
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
eagerDbg.shouldAvoidSideEffects = true;
|
|
||||||
|
|
||||||
return eagerDbg;
|
|
||||||
}
|
|
||||||
|
|
||||||
addEventListener("getPossibleBreakpoints", event => {
|
|
||||||
const {spidermonkeyId} = event;
|
|
||||||
const script = sourceIdsToScripts.get(spidermonkeyId);
|
|
||||||
const result = [];
|
|
||||||
walkScriptTree(script, (currentScript) => {
|
|
||||||
for (const location of currentScript.getPossibleBreakpoints()) {
|
|
||||||
location["scriptId"] = currentScript.sourceStart;
|
|
||||||
result.push(location);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getPossibleBreakpointsResult(event, result);
|
|
||||||
});
|
|
||||||
|
|
||||||
function createFrameActor(frame, pipelineId) {
|
|
||||||
let frameActorId = findKeyByValue(frameActorsToFrames, frame);
|
|
||||||
if (!frameActorId) {
|
|
||||||
// TODO: Check if we already have an actor for this frame
|
|
||||||
frameActorId = registerFrameActor(pipelineId, {
|
|
||||||
// TODO: Some properties throw if terminated is true
|
|
||||||
// TODO: arguments: frame.arguments,
|
|
||||||
displayName: frame.script.displayName ?? null,
|
|
||||||
onStack: frame.onStack,
|
|
||||||
oldest: frame.older == null,
|
|
||||||
serializedThis: JSON.stringify(createValueGrip(frame.this, 0)),
|
|
||||||
terminated: frame.terminated,
|
|
||||||
type_: frame.type,
|
|
||||||
url: frame.script.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!frameActorId) {
|
|
||||||
console.error("[debugger] Couldn't create frame");
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
frameActorsToFrames.set(frameActorId, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
return frameActorId;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePauseAndRespond(frame, pauseReason) {
|
|
||||||
// https://searchfox.org/firefox-main/source/devtools/server/actors/thread.js#1706
|
|
||||||
// We don't handle nested pauses correctly. Don't try - if we're
|
|
||||||
// paused, just continue running whatever code triggered the pause.
|
|
||||||
if (debuggerPaused) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbg.onEnterFrame = undefined;
|
|
||||||
clearSteppingHooks(frame);
|
|
||||||
|
|
||||||
// Get the pipeline ID for this debuggee
|
|
||||||
const pipelineId = debuggeesToPipelineIds.get(frame.script.global);
|
|
||||||
if (!pipelineId) {
|
|
||||||
console.error("[debugger] No pipeline ID for frame's global");
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
let frameActorId = createFrameActor(frame, pipelineId);
|
|
||||||
|
|
||||||
// <https://github.com/mozilla-firefox/firefox/blob/63719d122f9214f37fd1d285a91897b8345b88b0/js/src/doc/Debugger/Debugger.Script.md?plain=1#L293-L303>
|
|
||||||
const offset = frame.offset;
|
|
||||||
const offsetMetadata = frame.script.getOffsetMetadata(offset);
|
|
||||||
const frameOffset = {
|
|
||||||
frameActorId,
|
|
||||||
column: offsetMetadata.columnNumber - 1,
|
|
||||||
line: offsetMetadata.lineNumber
|
|
||||||
};
|
|
||||||
lastPauseLocation = { line: offsetMetadata.lineNumber, column: offsetMetadata.columnNumber };
|
|
||||||
|
|
||||||
const source = frame.script.source;
|
|
||||||
if (source != null && isBlackBoxed(source.id, frameOffset.line, frameOffset.column)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify devtools and enter pause loop. This blocks until Resume.
|
|
||||||
debuggerPaused = true;
|
|
||||||
try {
|
|
||||||
pauseAndRespond(
|
|
||||||
pipelineId,
|
|
||||||
frameOffset,
|
|
||||||
pauseReason
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
debuggerPaused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://web.archive.org/web/20251212212538/https://firefox-source-docs.mozilla.org/js/Debugger/Conventions.html#resumption-values>
|
|
||||||
// Return undefined to continue execution normally after resume.
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
addEventListener("frames", event => {
|
|
||||||
const {pipelineId, start, count} = event;
|
|
||||||
let frameList = handleListFrames(pipelineId, start, count);
|
|
||||||
|
|
||||||
listFramesResult(frameList);
|
|
||||||
})
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/thread.js#1425>
|
|
||||||
function handleListFrames(pipelineId, start, count) {
|
|
||||||
let frame = dbg.getNewestFrame()
|
|
||||||
|
|
||||||
const walkToParentFrame = () => {
|
|
||||||
if (!frame) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentFrame = frame;
|
|
||||||
frame = null;
|
|
||||||
|
|
||||||
if (currentFrame.older) {
|
|
||||||
frame = currentFrame.older;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let i = 0;
|
|
||||||
while (frame && i < start) {
|
|
||||||
walkToParentFrame();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return count frames, or all remaining frames if count is not defined.
|
|
||||||
const frames = [];
|
|
||||||
for (; frame && (!count || i < start + count); i++, walkToParentFrame()) {
|
|
||||||
const frameActorId = createFrameActor(frame, pipelineId);
|
|
||||||
frames.push(frameActorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
addEventListener("setBreakpoint", event => {
|
|
||||||
const {spidermonkeyId, scriptId, offset} = event;
|
|
||||||
const script = sourceIdsToScripts.get(spidermonkeyId);
|
|
||||||
const target = findScriptById(script, scriptId);
|
|
||||||
if (target) {
|
|
||||||
target.setBreakpoint(offset, {
|
|
||||||
// setBreakpoint(offset, handler) in <https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.script/index.html#function-properties-of-the-debugger-script-prototype-object>
|
|
||||||
// The hit handler receives a Debugger.Frame instance representing the currently executing stack frame.
|
|
||||||
hit: (frame) => handlePauseAndRespond(frame, {type_: "breakpoint"})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// <https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.frame/index.html>
|
|
||||||
addEventListener("interrupt", event => {
|
|
||||||
dbg.onEnterFrame = (frame) => handlePauseAndRespond(
|
|
||||||
frame,
|
|
||||||
{ type_: PAUSE_REASONS.INTERRUPTED, onNext: true }
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/thread.js#1088>
|
|
||||||
function hasMoved(frame) {
|
|
||||||
if (!lastPauseLocation) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const meta = frame.script.getOffsetMetadata(frame.offset);
|
|
||||||
return meta.lineNumber !== lastPauseLocation.line ||
|
|
||||||
meta.columnNumber !== lastPauseLocation.column;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeSteppingHooks(steppingType, startFrame) {
|
|
||||||
return {
|
|
||||||
onEnterFrame: function (frame) {
|
|
||||||
const { onStep, onPop } = makeSteppingHooks("next", frame);
|
|
||||||
frame.onStep = onStep;
|
|
||||||
frame.onPop = onPop;
|
|
||||||
},
|
|
||||||
onStep: function () {
|
|
||||||
const meta = this.script.getOffsetMetadata(this.offset);
|
|
||||||
if (!meta.isBreakpoint || !hasMoved(this)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (this !== startFrame || meta.isStepStart) {
|
|
||||||
return handlePauseAndRespond(this, { type_: PAUSE_REASONS.RESUME_LIMIT });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onPop: function (completion) {
|
|
||||||
this.reportedPop = true;
|
|
||||||
suspendedFrame = this;
|
|
||||||
attachSteppingHooks(steppingType, this);
|
|
||||||
return undefined;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNextStepFrame(frame) {
|
|
||||||
const endOfFrame = frame.reportedPop;
|
|
||||||
const stepFrame = endOfFrame ? frame.older : frame;
|
|
||||||
if (!stepFrame || !stepFrame.script) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return stepFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/thread.js#1235>
|
|
||||||
function attachSteppingHooks(steppingType, frame) {
|
|
||||||
if (steppingType === "finish" && frame.reportedPop) {
|
|
||||||
steppingType = "next";
|
|
||||||
}
|
|
||||||
|
|
||||||
const stepFrame = getNextStepFrame(frame);
|
|
||||||
if (!stepFrame) {
|
|
||||||
steppingType = "step";
|
|
||||||
}
|
|
||||||
|
|
||||||
const { onEnterFrame, onStep, onPop } = makeSteppingHooks(
|
|
||||||
steppingType,
|
|
||||||
frame,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (steppingType === "step") {
|
|
||||||
dbg.onEnterFrame = onEnterFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stepFrame) {
|
|
||||||
switch (steppingType) {
|
|
||||||
case "step":
|
|
||||||
case "next":
|
|
||||||
if (stepFrame.script) {
|
|
||||||
stepFrame.onStep = onStep;
|
|
||||||
}
|
|
||||||
case "finish":
|
|
||||||
stepFrame.onPop = onPop;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearSteppingHooks(suspendedFrame) {
|
|
||||||
if (suspendedFrame) {
|
|
||||||
suspendedFrame.onStep = undefined;
|
|
||||||
suspendedFrame.onPop = undefined;
|
|
||||||
}
|
|
||||||
let frame = dbg.getNewestFrame();
|
|
||||||
if (frame?.onStack) {
|
|
||||||
while (frame) {
|
|
||||||
frame.onStep = undefined;
|
|
||||||
frame.onPop = undefined;
|
|
||||||
frame = frame.older;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#resuming-a-thread>
|
|
||||||
addEventListener("resume", event => {
|
|
||||||
const {resumeLimitType: steppingType, frameActorID} = event;
|
|
||||||
let frame = dbg.getNewestFrame();
|
|
||||||
if (frameActorID) {
|
|
||||||
frame = frameActorsToFrames.get(frameActorID);
|
|
||||||
if (!frame) {
|
|
||||||
console.error("[debugger] Couldn't find frame");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (steppingType) {
|
|
||||||
// This is a temporary fix until we support async contexts.
|
|
||||||
if (steppingType === "finish") {
|
|
||||||
lastPauseLocation = null;
|
|
||||||
}
|
|
||||||
attachSteppingHooks(steppingType, frame);
|
|
||||||
} else {
|
|
||||||
clearSteppingHooks(frame);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// <https://firefox-source-docs.mozilla.org/devtools-user/debugger-api/debugger.script/index.html#function-properties-of-the-debugger-script-prototype-object>
|
|
||||||
// There may be more than one breakpoint at the same offset with different handlers, but we don’t handle that case for now.
|
|
||||||
addEventListener("clearBreakpoint", event => {
|
|
||||||
const {spidermonkeyId, scriptId, offset} = event;
|
|
||||||
const script = sourceIdsToScripts.get(spidermonkeyId);
|
|
||||||
const target = findScriptById(script, scriptId);
|
|
||||||
if (target) {
|
|
||||||
// If the instance refers to a JSScript, remove all breakpoints set in this script at that offset.
|
|
||||||
target.clearAllBreakpoints(offset);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: Get variables (scopes don't show if they don't have a variable)
|
|
||||||
function createEnvironmentActor(environment) {
|
|
||||||
let info = {};
|
|
||||||
if (environment.type == "declarative") {
|
|
||||||
info.type_ = environment.calleeScript ? "function" : "block";
|
|
||||||
} else {
|
|
||||||
info.type_ = environment.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
info.scopeKind = environment.scopeKind;
|
|
||||||
|
|
||||||
if (environment.calleeScript) {
|
|
||||||
info.functionDisplayName = environment.calleeScript.displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
let parent = null;
|
|
||||||
if (environment.parent) {
|
|
||||||
parent = createEnvironmentActor(environment.parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
let bindingVariables = [];
|
|
||||||
if (environment.type == "declarative") {
|
|
||||||
bindingVariables = buildBindings(environment);
|
|
||||||
}
|
|
||||||
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/environment.js#62>
|
|
||||||
if (environment.type == "object" || environment.type == "with") {
|
|
||||||
info.serializedObject = JSON.stringify(createValueGrip(environment.object, 0));
|
|
||||||
}
|
|
||||||
info.serializedBindings = JSON.stringify(bindingVariables);
|
|
||||||
|
|
||||||
let actor = environmentsToEnvironmentActors.get(environment);
|
|
||||||
actor = registerEnvironmentActor(info, parent, actor);
|
|
||||||
environmentsToEnvironmentActors.set(environment, actor);
|
|
||||||
return actor;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildBindings(environment) {
|
|
||||||
const bindingVariables = [];
|
|
||||||
for (const name of environment.names()) {
|
|
||||||
const value = environment.getVariable(name);
|
|
||||||
const property = {
|
|
||||||
name: name,
|
|
||||||
configurable: false,
|
|
||||||
enumerable: true,
|
|
||||||
writable: !(
|
|
||||||
value &&
|
|
||||||
(value.optimizedOut || value.uninitialized || value.missingArguments)
|
|
||||||
),
|
|
||||||
isAccessor: false,
|
|
||||||
value: createValueGrip(value, 0),
|
|
||||||
};
|
|
||||||
|
|
||||||
bindingVariables.push(property);
|
|
||||||
}
|
|
||||||
return bindingVariables;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a `Debugger.Environment` instance within which evaluation is taking place.
|
|
||||||
// <https://searchfox.org/firefox-main/source/devtools/server/actors/frame.js#109>
|
|
||||||
addEventListener("getEnvironment", event => {
|
|
||||||
const { frameActorId, pipelineId } = event;
|
|
||||||
let environment;
|
|
||||||
if (frameActorId) {
|
|
||||||
environment = frameActorsToFrames.get(frameActorId).environment;
|
|
||||||
} else {
|
|
||||||
environment = findDebuggeeByPipelineId(pipelineId).asEnvironment();
|
|
||||||
}
|
|
||||||
|
|
||||||
const actor = createEnvironmentActor(environment);
|
|
||||||
getEnvironmentResult(actor);
|
|
||||||
});
|
|
||||||
|
|
||||||
addEventListener("blackbox", event => {
|
|
||||||
if (event.coversFullSource) {
|
|
||||||
// Blackbox the entire source
|
|
||||||
blackboxing.set(event.spidermonkeyId, []);
|
|
||||||
} else {
|
|
||||||
// Blackbox only a part of the source
|
|
||||||
let blackbox = blackboxing.get(event.spidermonkeyId);
|
|
||||||
if (blackbox == undefined) {
|
|
||||||
blackbox = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
blackbox.push({
|
|
||||||
start: event.start(),
|
|
||||||
end: event.end()
|
|
||||||
});
|
|
||||||
|
|
||||||
blackboxing.set(event.spidermonkeyId, blackbox);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addEventListener("unblackbox", event => {
|
|
||||||
if (event.coversFullSource) {
|
|
||||||
// Unblackbox the entire source
|
|
||||||
blackboxing.delete(event.spidermonkeyId);
|
|
||||||
} else {
|
|
||||||
// Unblackbox an earlier range of the source
|
|
||||||
const array = blackboxing.get(event.spidermonkeyId);
|
|
||||||
|
|
||||||
const start = event.start();
|
|
||||||
const end = event.end();
|
|
||||||
const index = array.findIndex(range => range.start.line === start.line
|
|
||||||
&& range.start.column === start.column
|
|
||||||
&& range.end.line === end.line
|
|
||||||
&& range.end.column === end.column
|
|
||||||
);
|
|
||||||
if (index !== -1) {
|
|
||||||
array.splice(index, 1);
|
|
||||||
|
|
||||||
// Empty arrays represent a fully blackboxed file
|
|
||||||
// Therefore, if we just made the array empty we will need to remove it from the map
|
|
||||||
if (array.length === 0) {
|
|
||||||
blackboxing.delete(event.spidermonkeyId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function isBlackBoxed(spidermonkeyId, line, column) {
|
|
||||||
const sourceBlackboxing = blackboxing.get(spidermonkeyId);
|
|
||||||
|
|
||||||
if (sourceBlackboxing == undefined) {
|
|
||||||
return false;
|
|
||||||
} else if (sourceBlackboxing.length === 0) {
|
|
||||||
// An empty array represents a fully ignored source
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const range of sourceBlackboxing) {
|
|
||||||
return (range.start.line < line || (range.start.line === line && range.start.column <= column))
|
|
||||||
&& (range.end.line > line || (range.end.line === line && range.end.column >= column))
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Index of</title>
|
|
||||||
<style>
|
|
||||||
h1 {
|
|
||||||
border-bottom: 1px solid black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.listing {
|
|
||||||
margin: 0.5em;
|
|
||||||
display: table;
|
|
||||||
}
|
|
||||||
|
|
||||||
.listing .header,
|
|
||||||
.listing .entry {
|
|
||||||
display: table-row;
|
|
||||||
}
|
|
||||||
|
|
||||||
.listing .header {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.listing .header span,
|
|
||||||
.listing .entry span {
|
|
||||||
display: table-cell;
|
|
||||||
padding-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry span:nth-child(1) {
|
|
||||||
min-width: 20em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry span.size,
|
|
||||||
.entry span.last-modified {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parent_link > a:before {
|
|
||||||
content: "📁 ";
|
|
||||||
}
|
|
||||||
|
|
||||||
.parent_link {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry.directory > .name:before {
|
|
||||||
content: "📁 ";
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry.file > .name:before {
|
|
||||||
content: "📄 ";
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry.symlink > .name:before {
|
|
||||||
content: "🔗 ";
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
function setData(directoryName, parentLink, rows) {
|
|
||||||
document.title += " " + directoryName;
|
|
||||||
document.querySelector("h1").innerHTML += " " + directoryName;
|
|
||||||
|
|
||||||
if (parentLink != "") {
|
|
||||||
document.querySelector(".parent_link > a").href = parentLink;
|
|
||||||
document.querySelector(".parent_link").style.display = "initial";
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.sort((rowA, rowB) => rowA[1].localeCompare(rowB[1]));
|
|
||||||
|
|
||||||
let listing = document.querySelector(".listing");
|
|
||||||
let rowTemplate = document.getElementById("rowTemplate");
|
|
||||||
for (row of rows) {
|
|
||||||
let rowElement = rowTemplate.content.cloneNode(true);
|
|
||||||
rowElement.querySelector(".entry").classList.add(row[0]);
|
|
||||||
rowElement.querySelector(".name > .link").innerText = row[1];
|
|
||||||
rowElement.querySelector(".name > .link").href = row[2];
|
|
||||||
rowElement.querySelector(".size").innerText = row[3];
|
|
||||||
rowElement.querySelector(".last-modified").innerText = row[4];
|
|
||||||
listing.appendChild(rowElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Index of</h1>
|
|
||||||
<div class="parent_link"><a href="">Up to parent directory</a></div>
|
|
||||||
<div class="listing">
|
|
||||||
<div class="header">
|
|
||||||
<span class="name">Name</span>
|
|
||||||
<span class="size">Size</span>
|
|
||||||
<span class="last-modified">Last Modified</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<template id="rowTemplate">
|
|
||||||
<div class="entry">
|
|
||||||
<span class="name"><a class="link"></a></span>
|
|
||||||
<span class="size"></span>
|
|
||||||
<span class="last-modified"></span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
# Source:
|
|
||||||
# https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt
|
|
||||||
# License:
|
|
||||||
# https://github.com/WebBluetoothCG/registries/blob/master/LICENSE
|
|
||||||
|
|
||||||
# This file holds a list of GATT UUIDs that websites using the Web
|
|
||||||
# Bluetooth API are forbidden from accessing.
|
|
||||||
|
|
||||||
## Services
|
|
||||||
|
|
||||||
# org.bluetooth.service.human_interface_device
|
|
||||||
# Direct access to HID devices like keyboards would let web pages
|
|
||||||
# become keyloggers.
|
|
||||||
00001812-0000-1000-8000-00805f9b34fb
|
|
||||||
|
|
||||||
# Firmware update services that don't check the update's signature
|
|
||||||
# present a risk of devices' software being modified by malicious web
|
|
||||||
# pages. Users may connect to a device believing they are enabling
|
|
||||||
# only simple interaction or that they're interacting with the
|
|
||||||
# device's manufacturer, but the site might instead persistently
|
|
||||||
# compromise the device.
|
|
||||||
#
|
|
||||||
# Nordic's Device Firmware Update service, http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/examples_ble_dfu.html:
|
|
||||||
00001530-1212-efde-1523-785feabcd123
|
|
||||||
# TI's Over-the-Air Download service, http://www.ti.com/lit/ug/swru271g/swru271g.pdf:
|
|
||||||
f000ffc0-0451-4000-b000-000000000000
|
|
||||||
|
|
||||||
|
|
||||||
## Characteristics
|
|
||||||
|
|
||||||
# org.bluetooth.characteristic.gap.peripheral_privacy_flag
|
|
||||||
# Don't let web pages turn off privacy mode.
|
|
||||||
00002a02-0000-1000-8000-00805f9b34fb exclude-writes
|
|
||||||
|
|
||||||
# org.bluetooth.characteristic.gap.reconnection_address
|
|
||||||
# Disallow messing with connection parameters
|
|
||||||
00002a03-0000-1000-8000-00805f9b34fb
|
|
||||||
|
|
||||||
# org.bluetooth.characteristic.serial_number_string
|
|
||||||
# Block access to standardized unique identifiers, for privacy reasons.
|
|
||||||
00002a25-0000-1000-8000-00805f9b34fb
|
|
||||||
|
|
||||||
# Blocklisted characteristic used to test readValue function.
|
|
||||||
bad1c9a2-9a5b-4015-8b60-1579bbbf2135 exclude-reads
|
|
||||||
|
|
||||||
|
|
||||||
## Descriptors
|
|
||||||
|
|
||||||
# org.bluetooth.descriptor.gatt.client_characteristic_configuration
|
|
||||||
# Writing to this would let a web page interfere with other pages'
|
|
||||||
# notifications and indications.
|
|
||||||
00002902-0000-1000-8000-00805f9b34fb exclude-writes
|
|
||||||
|
|
||||||
# org.bluetooth.descriptor.gatt.server_characteristic_configuration
|
|
||||||
# Writing to this would let a web page interfere with the broadcasted services.
|
|
||||||
00002903-0000-1000-8000-00805f9b34fb exclude-writes
|
|
||||||
|
|
||||||
# Blocklisted descriptor used to test.
|
|
||||||
07711111-6104-0970-7011-1107105110aa
|
|
||||||
|
|
||||||
# Blocklisted descriptor used to test.
|
|
||||||
aaaaaaaa-aaaa-1181-0510-810819516110 exclude-reads
|
|
||||||
Binary file not shown.
|
|
@ -1,269 +0,0 @@
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: monospace;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
background: #fff;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
#json-raw {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#viewer {
|
|
||||||
display: none;
|
|
||||||
padding: 0.5em 1em;
|
|
||||||
line-height: 1.5;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#toolbar {
|
|
||||||
display: flex;
|
|
||||||
gap: 1em;
|
|
||||||
padding: 0.5em;
|
|
||||||
align-items: center;
|
|
||||||
background: #f5f5f5;
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
|
|
||||||
& button {
|
|
||||||
min-width: 5em;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background: #ddd;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#raw-view {
|
|
||||||
display: none;
|
|
||||||
padding: 0.5em 1em;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-break: break-all;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-error {
|
|
||||||
padding: 0.5em 1em;
|
|
||||||
color: #c00;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Syntax highlighting for Json data types */
|
|
||||||
.json-key {
|
|
||||||
color: #881391;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-string {
|
|
||||||
color: #1a1aa6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-number {
|
|
||||||
color: #1c00cf;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-boolean {
|
|
||||||
color: #0d22aa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-null {
|
|
||||||
color: #808080;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Collapsible tree */
|
|
||||||
.toggle {
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
content: "\25BC";
|
|
||||||
display: inline-block;
|
|
||||||
width: 1em;
|
|
||||||
transition: transform 0.1s;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.collapsed::before {
|
|
||||||
transform: rotate(-90deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.collapsible {
|
|
||||||
margin-left: 1.5em;
|
|
||||||
|
|
||||||
&.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.bracket {
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comma {
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.line {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
// Shortcut to create an element with an optional class and text content.
|
|
||||||
function createElement(name, classes = null, textContent = null) {
|
|
||||||
let node = document.createElement(name);
|
|
||||||
if (classes) {
|
|
||||||
node.className = classes;
|
|
||||||
}
|
|
||||||
if (textContent) {
|
|
||||||
node.textContent = textContent;
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderNode(value, container) {
|
|
||||||
if (value === null) {
|
|
||||||
let s = createElement("span", "json-null", "null");
|
|
||||||
container.append(s);
|
|
||||||
} else if (typeof value === "boolean") {
|
|
||||||
let s = createElement("span", "json-boolean", String(value));
|
|
||||||
container.append(s);
|
|
||||||
} else if (typeof value === "number") {
|
|
||||||
let s = createElement("span", "json-number", String(value));
|
|
||||||
container.append(s);
|
|
||||||
} else if (typeof value === "string") {
|
|
||||||
let s = createElement("span", "json-string", JSON.stringify(value));
|
|
||||||
container.append(s);
|
|
||||||
} else if (Array.isArray(value)) {
|
|
||||||
renderArray(value, container);
|
|
||||||
} else if (typeof value === "object") {
|
|
||||||
renderObject(value, container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderObject(obj, container) {
|
|
||||||
let keys = Object.keys(obj);
|
|
||||||
if (keys.length === 0) {
|
|
||||||
container.append(createElement("span", "bracket", "{}"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let toggle = createElement("span", "toggle");
|
|
||||||
container.append(toggle);
|
|
||||||
|
|
||||||
container.append(createElement("span", "bracket", "{"));
|
|
||||||
|
|
||||||
let inner = createElement("div", "collapsible");
|
|
||||||
container.append(inner);
|
|
||||||
|
|
||||||
keys.forEach((key, i) => {
|
|
||||||
let line = createElement("div", "line");
|
|
||||||
line.append(createElement("span", "json-key", JSON.stringify(key)));
|
|
||||||
line.append(document.createTextNode(": "));
|
|
||||||
renderNode(obj[key], line);
|
|
||||||
if (i < keys.length - 1) {
|
|
||||||
line.append(createElement("span", "comma", ","));
|
|
||||||
}
|
|
||||||
inner.append(line);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.append(createElement("span", "bracket", "}"));
|
|
||||||
|
|
||||||
toggle.onclick = function () {
|
|
||||||
toggle.classList.toggle("collapsed");
|
|
||||||
inner.classList.toggle("hidden");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderArray(arr, container) {
|
|
||||||
if (arr.length === 0) {
|
|
||||||
container.append(createElement("span", "bracket", "[]"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let toggle = createElement("span", "toggle");
|
|
||||||
container.append(toggle);
|
|
||||||
|
|
||||||
container.append(createElement("span", "bracket", "["));
|
|
||||||
|
|
||||||
let inner = createElement("div", "collapsible");
|
|
||||||
container.append(inner);
|
|
||||||
|
|
||||||
arr.forEach((item, i) => {
|
|
||||||
let line = createElement("div", "line");
|
|
||||||
renderNode(item, line);
|
|
||||||
if (i < arr.length - 1) {
|
|
||||||
line.append(createElement("span", "comma", ","));
|
|
||||||
}
|
|
||||||
inner.append(line);
|
|
||||||
});
|
|
||||||
|
|
||||||
container.append(createElement("span", "bracket", "]"));
|
|
||||||
|
|
||||||
toggle.onclick = function () {
|
|
||||||
toggle.classList.toggle("collapsed");
|
|
||||||
inner.classList.toggle("hidden");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
const viewer = document.getElementById("viewer");
|
|
||||||
const prettyButton = document.getElementById("pretty-toggle");
|
|
||||||
const rawButton = document.getElementById("raw-toggle");
|
|
||||||
const rawView = document.getElementById("raw-view");
|
|
||||||
const rawText = rawView.innerText;
|
|
||||||
|
|
||||||
let data;
|
|
||||||
let parseError = null;
|
|
||||||
try {
|
|
||||||
data = JSON.parse(rawText);
|
|
||||||
} catch (e) {
|
|
||||||
parseError = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseError) {
|
|
||||||
let errDiv = createElement(
|
|
||||||
"div",
|
|
||||||
"json-error",
|
|
||||||
"Invalid JSON: " + parseError.message,
|
|
||||||
);
|
|
||||||
viewer.append(errDiv);
|
|
||||||
viewer.append(createElement("pre", null, rawText));
|
|
||||||
} else {
|
|
||||||
renderNode(data, viewer);
|
|
||||||
rawView.textContent = JSON.stringify(data, null, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle buttons
|
|
||||||
prettyButton.onclick = function () {
|
|
||||||
viewer.classList.add("active");
|
|
||||||
rawView.classList.remove("active");
|
|
||||||
|
|
||||||
prettyButton.classList.add("active");
|
|
||||||
rawButton.classList.remove("active");
|
|
||||||
};
|
|
||||||
rawButton.onclick = function () {
|
|
||||||
rawView.classList.add("active");
|
|
||||||
viewer.classList.remove("active");
|
|
||||||
|
|
||||||
rawButton.classList.add("active");
|
|
||||||
prettyButton.classList.remove("active");
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="toolbar">
|
|
||||||
<button id="pretty-toggle" class="active">Pretty</button>
|
|
||||||
<button id="raw-toggle">Raw</button>
|
|
||||||
</div>
|
|
||||||
<div id="viewer" class="active"></div>
|
|
||||||
<pre id="raw-view">
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Couldn't open this page</title>
|
|
||||||
<style>
|
|
||||||
:root { font-family: system-ui, sans-serif; --bg: #fdfbff; --text: #1a1b1f; --muted: #44474e; --card: #f1f0f4; --primary: #415f91; --on-primary: #ffffff; --tonal: #d6e3ff; --on-tonal: #001b3e; --error: #ffdad6; --on-error: #410002; --line: #c4c6d0; }
|
|
||||||
@media (prefers-color-scheme: dark) { :root { --bg: #101114; --text: #e3e2e6; --muted: #c4c6d0; --card: #1d1e22; --primary: #aac7ff; --on-primary: #0a305f; --tonal: #284777; --on-tonal: #d6e3ff; --error: #93000a; --on-error: #ffdad6; --line: #44474e; } }
|
|
||||||
html { background: var(--bg); color: var(--text); }
|
|
||||||
body { max-width: 520px; margin: 14vh auto; padding: 0 24px; line-height: 1.5; text-align: center; background: var(--bg); color: var(--text); }
|
|
||||||
.mark { width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 50%; background: var(--error); color: var(--on-error); font-size: 34px; font-weight: 600; line-height: 72px; }
|
|
||||||
h1 { font-size: 1.75em; font-weight: 600; margin: 0 0 8px; }
|
|
||||||
p { margin: 8px 0; color: var(--muted); }
|
|
||||||
p.url { word-break: break-all; color: var(--text); }
|
|
||||||
code, pre { font-family: ui-monospace, monospace; word-break: break-all; }
|
|
||||||
.detail { font-size: 0.85em; }
|
|
||||||
.actions { margin-top: 28px; }
|
|
||||||
button { font: inherit; font-weight: 600; height: 40px; padding: 0 24px; margin: 0 4px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--primary); cursor: pointer; }
|
|
||||||
button.main { border-color: transparent; background: var(--primary); color: var(--on-primary); }
|
|
||||||
button:hover { filter: brightness(1.08); }
|
|
||||||
details { margin-top: 20px; text-align: left; color: var(--muted); }
|
|
||||||
details pre { white-space: pre-wrap; font-size: 12px; background: var(--card); padding: 12px; border-radius: 12px; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="mark">!</div>
|
|
||||||
<h1>Couldn't open this page</h1>
|
|
||||||
<p class="url" id="url"></p>
|
|
||||||
<p>The server didn't answer or the connection broke. Check that the address is right and that you're online. If you use Nacre's VPN, it may still be connecting.</p>
|
|
||||||
<p class="detail">Details: <code>${reason}</code></p>
|
|
||||||
<div class="actions"><button class="main" onclick="location.reload()">Try again</button><button onclick="history.back()">Go back</button></div>
|
|
||||||
<script>document.getElementById('url').textContent = location.href;</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 144 B |
|
|
@ -1,40 +0,0 @@
|
||||||
# S027 hand-over (MSE DOM to spec) — 2026-11-12
|
|
||||||
|
|
||||||
Branch `s022-mse-proto`, worktree ~/Projects/Nacre-s022 (own target/). Plan: Plans/05 Engine/S027-mse-dom-spec.md (on main).
|
|
||||||
|
|
||||||
## Done (committed on the branch)
|
|
||||||
- DOM rewrite: vendor/servo-script/dom/media/{mediasource,sourcebuffer,sourcebufferlist}.rs. DOM owns spec state; all events
|
|
||||||
queued as media element tasks; attach/detach (htmlmediaelement.rs step 7.3, resource_fetch_algorithm), duration change
|
|
||||||
(element duration from the MediaSource), HTMLMediaElement.buffered/seekable from MediaSource (pure fns + 5 tests in
|
|
||||||
vendor/servo-media-player/mse.rs), activeSourceBuffers from gst active list, removeSourceBuffer, abort, changeType (same
|
|
||||||
container only), sequence mode, live seekable range, endOfStream(error) -> element error steps.
|
|
||||||
- Object URLs: per-global map GlobalScope::media_source_urls, revoke removes one task later, cleared on unload.
|
|
||||||
- Weak event sink: thread-local id -> WeakRef<MediaSource> (MediaSource weakReferenceable). Debug counter: nacre.log
|
|
||||||
"MSE: MediaSource <id> created/freed".
|
|
||||||
- Pref: [Func="MediaSource::enabled"] reads NACRE_DOM_MEDIA_SOURCE_ENABLED (D-017 on main explains why not servo-config).
|
|
||||||
- isTypeSupported: servo_media_player::mse::is_type_well_formed (registry rules) before gst + decoder check.
|
|
||||||
- gst_mse patches 5-9 (vendor/gst-mse, nacre.patch regenerated, docs/engine/gst-mse-patches.md): remove() real, abort()
|
|
||||||
resets parser, reset drops old appsinks (crash), track_feeds keyed by id, appendWindowStart check inverted.
|
|
||||||
C tests tests/gst-mse/mse-fixes.c 5/5 (tools/gst-mse.sh test).
|
|
||||||
- Smoke: tests/smoke/mse.txt (+ pages/mse-spec.html, 11 cases) green; tests/smoke/mse-leak-check.sh ok (MS freed in run);
|
|
||||||
tests/smoke/mse-off.txt green with NACRE_DOM_MEDIA_SOURCE_ENABLED=0. Run mse.txt with SMOKE_TIMEOUT=400.
|
|
||||||
- WPT runner: tools/wpt-mse.sh (+ tests/wpt-mse/), pinned WPT in target/wpt.
|
|
||||||
|
|
||||||
## WPT
|
|
||||||
- Run 1 (before validator/endOfStream error): 246/407 subtests in 60 files.
|
|
||||||
- Run 2 (current build) was running at hand-over; output: /tmp/claude-1000/-home-astar76-Projects-Nacre/9e6752f4-4824-467b-b5b7-80b90b1ca98b/scratchpad/wpt4.out, results /tmp/claude-1000/-home-astar76-Projects-Nacre/9e6752f4-4824-467b-b5b7-80b90b1ca98b/scratchpad/wpt4/wpt/results.json.
|
|
||||||
If gone, rerun: tools/wpt-mse.sh (~45 min). Target in plan: >= 293.
|
|
||||||
|
|
||||||
## Not done / next steps
|
|
||||||
1. Get run-2 count; record in PROGRESS (main). Tick plan box 7 (smoke) and 8 (PROGRESS, INDEX, push) + tracker S027.
|
|
||||||
2. Biggest remaining WPT gaps are player integration (S028): loadedmetadata/HAVE_METADATA after init segment only
|
|
||||||
(duration-boundaryconditions 0/13 time out, play/seek tests 0/1), changetype across containers (gst can't, 1/19 x3),
|
|
||||||
errors before init segment, buffered after removeSourceBuffer should throw ([Throws] attr), same TimeRanges object.
|
|
||||||
3. Opus/fLaC in mp4 unsupported (gst/decoder), 4 WPT subtests.
|
|
||||||
|
|
||||||
## Gotchas
|
|
||||||
- weakReferenceable structs can't impl Drop (codegen does); counter lives in a LiveCount field.
|
|
||||||
- Servo runs no FinalizationRegistry callbacks / WeakRef clearing: leak check must use the log.
|
|
||||||
- WPT tests call alert() on 404s: tests/wpt-mse/testharnessreport.js stubs it; WPT media/ dir needed.
|
|
||||||
- After abort/changeType the next append must start with an init segment (gst reset forgets it).
|
|
||||||
- Negative timestampOffset clamps to 0 (GstClockTime).
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
||||||
# MSE spike (S022)
|
|
||||||
|
|
||||||
Can Nacre get Media Source Extensions into Servo 0.7, so YouTube (and Reddit's HLS player) play in the page?
|
|
||||||
Date: 2026-11-12. Prototype: branch `s022-mse-proto` on origin, worktree `~/Projects/Nacre-s022`.
|
|
||||||
|
|
||||||
## Answer
|
|
||||||
|
|
||||||
Yes. GStreamer ships its own MSE library, **gst_mse** (`libgstmse-1.0`, plugin `mse` with the `msesrc` element, since
|
|
||||||
1.24, Rust bindings `gstreamer-mse` 0.25 matching Servo 0.7's gstreamer-rs 0.25). It runs the MSE algorithms in C:
|
|
||||||
byte-stream parsing (fMP4, WebM, MPEG-TS), coded frame processing, track buffers, buffered ranges, eviction,
|
|
||||||
`remove`, `abort`, `timestampOffset`, append windows, duration and ready states. So Servo only needs a thin DOM and
|
|
||||||
a player source, not its own demuxer. The prototype is ~900 lines on top of vendored crates and:
|
|
||||||
|
|
||||||
- plays a chunk-appended local clip, fMP4 (H.264 + AAC) and WebM (VP9 + Opus): `tests/smoke/mse.txt` passes, and
|
|
||||||
the shots show frames with the clock running (1.68 s, 2.04 s);
|
|
||||||
- takes YouTube from "Your browser can't play this video" to its own player, with controls, captions, the
|
|
||||||
quality menu button and a `blob:` MediaSource src. In one run (AV1 + Opus picked) `currentTime` ran 0→12 s of
|
|
||||||
the 19 s video, with captions following, but showed no picture (no AV1 decoder installed). With VP9 + AAC (after
|
|
||||||
the decoder fix) it stays at readyState 0. That is gst_mse bug 3 below.
|
|
||||||
|
|
||||||
Three gst_mse 1.28.9 defects block YouTube. All three are in C code we can fix (see "Sized plan").
|
|
||||||
|
|
||||||
## Upstream state (step 1)
|
|
||||||
|
|
||||||
| Item | State | Notes |
|
|
||||||
|---|---|---|
|
|
||||||
| [servo#22416](https://github.com/servo/servo/issues/22416) | open since 2018, E-very-complex | Members (2025) prefer "Servo holds an opaque gst_mse handle and calls methods on it". |
|
|
||||||
| [servo#44403](https://github.com/servo/servo/issues/44403) | open, B-roadmap, assigned calvaris (2026-04) | Roadmap item "Implementing the Media Source API"; no code linked. |
|
|
||||||
| [servo#40423](https://github.com/servo/servo/pull/40423) | open draft (2025-11) | WebIDL + stubs (`todo!()`), gst_mse via a servo-media fork; isTypeSupported hard-coded. |
|
|
||||||
| [servo/media#458](https://github.com/servo/media/pull/458) | open, locked, conflicted; repo archived | MSE traits over gst_mse, ~450 lines. Media now lives in the servo monorepo. |
|
|
||||||
| [servo#47269](https://github.com/servo/servo/pull/47269) | closed unmerged 2026-08 (LLM-written, Servo's AI policy) | Own ISO BMFF/WebM parser feeding `servosrc`; one SourceBuffer, no coded frame processing. Ideas only. |
|
|
||||||
| Servo v0.8.0 (2026-11-09) | released | No MSE. |
|
|
||||||
|
|
||||||
Nothing can be backported. Nacre carries its own implementation (same direction as upstream), and drops it when
|
|
||||||
Servo ships MSE.
|
|
||||||
|
|
||||||
## How Nacre carries it (step 3)
|
|
||||||
|
|
||||||
`[patch.crates-io]` like servo-net (D-012): `vendor/servo-script`, `servo-script-bindings` (the WebIDL codegen lives
|
|
||||||
there), `servo-media` (Backend trait), `servo-media-player` (Player trait plus the `mse` traits),
|
|
||||||
`servo-media-gstreamer` (gst_mse backend and player), plus the new dependency `gstreamer-mse = 0.25`.
|
|
||||||
The prototype lives in a worktree with its own `target/` (a btrfs reflink copy of the main target, which takes 1 s).
|
|
||||||
|
|
||||||
Measured rebuilds (`nice cargo build --release -j 2`, warm target):
|
|
||||||
|
|
||||||
| Change | Rebuild |
|
|
||||||
|---|---|
|
|
||||||
| First build after vendoring the 5 crates | 593 s (24 crates: script and everything downstream) |
|
|
||||||
| Edit in `servo-script` / WebIDL | 566 s |
|
|
||||||
| Edit in `servo-media-gstreamer` only | 106 s (3 crates) |
|
|
||||||
|
|
||||||
Vendored `script` costs about 10 minutes per DOM edit. That is fine, but keep DOM edits batched.
|
|
||||||
|
|
||||||
## Prototype (step 4)
|
|
||||||
|
|
||||||
| File (branch `s022-mse-proto`) | What |
|
|
||||||
|---|---|
|
|
||||||
| `vendor/servo-media-player/mse.rs` | `MediaSourceBackend` / `SourceBufferBackend` traits, `MseEvent`, `StreamType::MediaSource`, `Player::set_media_source` (default: unsupported) |
|
|
||||||
| `vendor/servo-media/lib.rs` | `Backend::create_media_source`, `is_media_source_type_supported` (defaults: none) |
|
|
||||||
| `vendor/servo-media-gstreamer/mse.rs` | gst_mse wrapper: events from signals, `buffered` via FFI (no binding in 0.25), settle work-around |
|
|
||||||
| `vendor/servo-media-gstreamer/player.rs` | `mse://` uri, `source-setup` attaches the `GstMediaSource` to `msesrc`; seek and rate allowed |
|
|
||||||
| `vendor/servo-script-bindings/webidls/{MediaSource,SourceBuffer,SourceBufferList}.webidl`, `URL.webidl` | spec IDL (minus ManagedMediaSource, workers); `createObjectURL(Blob or MediaSource)` |
|
|
||||||
| `vendor/servo-script/dom/media/{mediasource,sourcebuffer,sourcebufferlist}.rs` | DOM mirror of the backend state, events through the media element task source |
|
|
||||||
| `htmlmediaelement.rs` | `blob:` URL of a MediaSource → MSE player, no fetch |
|
|
||||||
| `tests/smoke/mse.txt`, `pages/mse-basic.html`, `pages/mse-clip-{mp4,webm}.js` | offline smoke (clips are base64 scripts: Servo refuses `fetch`/XHR of `file://`) |
|
|
||||||
|
|
||||||
Spike shortcuts, which the real plans must replace: object URLs are never freed (pages revoke right after setting
|
|
||||||
`src`), every SourceBuffer counts as active, `mode = "sequence"` and `changeType` are stored only,
|
|
||||||
`removeSourceBuffer` only drops it from the list, `HTMLMediaElement.buffered` still comes from playbin (empty under
|
|
||||||
MSE, so YouTube's "buffer health" reads 0 s), there is no pref switch, and a `Trusted` in the event sink keeps each
|
|
||||||
MediaSource alive.
|
|
||||||
|
|
||||||
## YouTube with the prototype (step 5)
|
|
||||||
|
|
||||||
`watch?v=jNQXAC9IVRw`, hidden smoke run, direct connection:
|
|
||||||
|
|
||||||
1. Before the decoder fix: YouTube picks **AV1 + Opus** because `gst_media_source_is_type_supported` only checks
|
|
||||||
that it can parse the type. Arch has no AV1 decoder (no dav1d plugin). Audio runs, so `currentTime` goes 0→12 s
|
|
||||||
and the captions follow, but the video area stays empty and `videoWidth` is 0. Fixed in the prototype:
|
|
||||||
isTypeSupported also requires Servo's `can_play_type` (decoder present). Opus in WebM then reads unsupported
|
|
||||||
(Servo's registry scanner), so YouTube takes AAC.
|
|
||||||
2. After the fix: **VP9 (242) + AAC (140)**, two SourceBuffers. Both init segments are parsed, but msesrc creates
|
|
||||||
a stream for the video track only (the video init came 2 s before the audio's), so playbin waits at
|
|
||||||
readyState 0 with the spinner. gst_mse **bug 3**.
|
|
||||||
3. Across runs it is flaky (some runs stall at 2 s, one at 0). Also seen once: a later `js` probe never returned,
|
|
||||||
so the script thread may block. `GStreamerPlayer::setup` blocks the script thread until `source-setup` fires.
|
|
||||||
This needs a look in the real plan.
|
|
||||||
|
|
||||||
gst_mse 1.28.9 defects (read from its source, gst-plugins-bad `gst-libs/gst/mse/`, LGPL. Ideas only, no code copied):
|
|
||||||
|
|
||||||
1. **Early `update-end`**: `append_to_buffer_task_func` signals success once the bytes are pushed into the append
|
|
||||||
pipeline (`gst_append_pipeline_append`), before the end-of-append marker has been processed. `buffered` is
|
|
||||||
stale at every `updateend`, which is exactly when players read it. Prototype work-around: wait (≤ 250 ms) for
|
|
||||||
`buffered` to move. Proper fix: signal after the end-of-append message is handled (`consume_all_samples`).
|
|
||||||
2. **Idle ticks**: the same task emits `update` / `update-end` about every second with no pending data.
|
|
||||||
The prototype ignores them when no append is outstanding.
|
|
||||||
3. **Split A/V SourceBuffers**: msesrc exposes streams as soon as one SourceBuffer has its init segment. The spec
|
|
||||||
says HAVE_METADATA only after every SourceBuffer has received one, and WebKit waits for all of them. This blocks
|
|
||||||
YouTube, which always uses separate audio and video buffers.
|
|
||||||
|
|
||||||
What YouTube still lacks after MSE works: DRM videos (no EME, DESIGN.md), AV1 needs the dav1d plugin, and
|
|
||||||
PiP reloads the page in its own web view (D-008), so the MediaSource re-buffers there. Expected to work but
|
|
||||||
unverified: seeking, quality switches, live (`setLiveSeekableRange` is a no-op now).
|
|
||||||
|
|
||||||
## Windows (step 6)
|
|
||||||
|
|
||||||
- GStreamer packages the mse **library** in its binary installers since 1.24.2 ("Package new analytics and mse
|
|
||||||
libraries in binary packages") and the mse **plugin** (`msesrc`) since **1.26.11** (cerbero "gst-plugins-bad:
|
|
||||||
Ship the mse plugin"). The Windows build therefore needs the MSVC runtime ≥ 1.26.11, or 1.28.x.
|
|
||||||
- Official installers: 1.28.8 MSVC x86_64 is an exe of 517 MB (1.28 dropped merge modules), and 1.26.11 is an
|
|
||||||
84 MB msi. Nacre ships a subset next to `nacre.exe`: core, base, good (isomp4, matroska, vpx), bad (mse,
|
|
||||||
dav1d, codecparsers), libav, opus and the audio sinks. Estimate 80–150 MB unpacked. **Not measured or tried in the
|
|
||||||
VM yet.**
|
|
||||||
- Arch (1.28.9) already has everything except an AV1 decoder (`gst-plugin-dav1d`, or `gst-plugins-rs` dav1ddec).
|
|
||||||
An AppImage must bundle GStreamer ≥ 1.26.11 with the mse plugin, because older distros lack it.
|
|
||||||
|
|
||||||
## Sized plan (if go)
|
|
||||||
|
|
||||||
Each line is one session unless noted. Option A keeps gst_mse and fixes it, so the expensive parsing stays in
|
|
||||||
GStreamer.
|
|
||||||
|
|
||||||
1. **gst_mse fixes** (2 sessions): bugs 1–3 as a patch on gst-plugins-bad 1.28.9 `gst-libs/gst/mse` (C, LGPL).
|
|
||||||
Build our own `libgstmse-1.0.so` and `libgstmse.so` (the plugin), loaded from Nacre's lib dir ahead of the
|
|
||||||
system copy. Offer the patches upstream (an MR to GStreamer). A C unit test per bug, like the Python probes in
|
|
||||||
the spike.
|
|
||||||
2. **MSE DOM to spec** (2 sessions): ready-state and event ordering, duration change, `removeSourceBuffer`,
|
|
||||||
`activeSourceBuffers`, `changeType`, sequence mode, `abort`, `HTMLMediaElement.buffered`/`seekable` from the
|
|
||||||
MediaSource, object URL lifetime (Blob URL store entry, #40749), no `Trusted` leak, a `dom_media_source_enabled`
|
|
||||||
pref, and the WPT `media-source` subset as smoke.
|
|
||||||
3. **Player integration** (1 session): seeking through msesrc, playback rate, error paths. The script thread must
|
|
||||||
not block in `GStreamerPlayer::setup` (async attach). `isTypeSupported` codec table: Opus in WebM, AV1 with
|
|
||||||
dav1d.
|
|
||||||
4. **YouTube + Reddit pass** (1 session): heavy-web YouTube steps green (play, seek, quality menu, captions, PiP,
|
|
||||||
ad blocking), plus Reddit's HLS video (hls.js over MSE) and site-doctor's video sites.
|
|
||||||
5. **Packaging** (1–2 sessions): AppImage bundles GStreamer ≥ 1.26.11 with the mse plugin, our patched libgstmse and
|
|
||||||
dav1d. The Windows installer bundles the MSVC runtime subset; check playback in the VM (software rendering).
|
|
||||||
|
|
||||||
Total **7–8 sessions**. Option B (own MSE core in Rust: fMP4/WebM byte-stream parsers, coded frame processing and
|
|
||||||
track buffers feeding one `appsrc` per track, like WebKit's own GStreamer MSE) is the fallback if bug 3 can't be
|
|
||||||
fixed inside msesrc. It would add 5–6 sessions.
|
|
||||||
|
|
||||||
## Risks
|
|
||||||
|
|
||||||
- Patched gst_mse must ship as our own copy on every platform until upstream releases the fixes (version skew
|
|
||||||
with the system GStreamer on Linux; bundling avoids it).
|
|
||||||
- `script` rebuilds take about 10 minutes per DOM edit; a Servo upgrade means re-applying the vendored patches (as D-012).
|
|
||||||
- YouTube's SABR streaming and A/B tests change often; the flakiness seen in the spike may have more causes than
|
|
||||||
bug 3.
|
|
||||||
- No EME: DRM content stays unavailable.
|
|
||||||
- Windows GStreamer bundle size and software-GL video in the VM are unmeasured.
|
|
||||||
|
|
||||||
## Recommendation
|
|
||||||
|
|
||||||
**Go, option A.** The DOM plus backend are small (the prototype took one session), the hard part (coded frame
|
|
||||||
processing) already exists in gst_mse, and the three blockers are concrete and local. Start with plan 1 (gst_mse
|
|
||||||
fixes), because it decides whether option B is needed. Plans 2–3 can then run while YouTube is re-checked.
|
|
||||||
1536
spikes/webkit-egui/Cargo.lock
generated
1536
spikes/webkit-egui/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,25 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "webkit-egui"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
publish = false
|
|
||||||
description = "Spike: Nacre's egui chrome hosted in a GTK 4 window next to WebKitGTK 6.0 web views (D-033)"
|
|
||||||
|
|
||||||
# Own workspace and own target/ (never the main crate's target/).
|
|
||||||
[workspace]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
gtk = { package = "gtk4", version = "=0.11.5", features = ["v4_20"] }
|
|
||||||
webkit = { package = "webkit6", version = "=0.6.1", features = ["v2_52"] }
|
|
||||||
egui = { version = "=0.37.0", default-features = false, features = ["default_fonts"] }
|
|
||||||
egui_glow = { version = "=0.37.0", default-features = false }
|
|
||||||
glow = "=0.17.0"
|
|
||||||
libloading = "0.8"
|
|
||||||
serde_json = "1"
|
|
||||||
# wl-input test helper (virtual pointer, test input method)
|
|
||||||
wayland-client = "=0.31.15"
|
|
||||||
wayland-protocols-wlr = { version = "=0.3.12", features = ["client"] }
|
|
||||||
wayland-protocols-misc = { version = "=0.3.12", features = ["client"] }
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
debug = 1
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Hidden test harness used for the D-033 spike run (docs/engine/webkit-spike.md). Outputs and the throwaway home go to $SPIKE_RUN (default /tmp/webkit-spike).
|
|
||||||
# Hidden nested session: Xvfb :77 -> niri (winit backend on X11) -> Wayland socket in a throwaway runtime dir.
|
|
||||||
# usage: nested.sh start | stop ; env for clients: source $S/env
|
|
||||||
S=${SPIKE_RUN:-/tmp/webkit-spike}; HERE=$(cd "$(dirname "$0")" && pwd)
|
|
||||||
R=$S; mkdir -p $R
|
|
||||||
case $1 in
|
|
||||||
start)
|
|
||||||
RT=/run/user/$(id -u)/nsp; rm -rf $RT $R/home; mkdir -p $RT $R/home/.config $R/home/.cache $R/home/.local/share; chmod 700 $RT
|
|
||||||
Xvfb :77 -screen 0 1600x900x24 -nolisten tcp >$R/xvfb.log 2>&1 & echo $! >$R/xvfb.pid
|
|
||||||
sleep 1
|
|
||||||
env -i PATH=$PATH HOME=$R/home XDG_RUNTIME_DIR=$RT XDG_CONFIG_HOME=$R/home/.config XDG_CACHE_HOME=$R/home/.cache \
|
|
||||||
XDG_DATA_HOME=$R/home/.local/share DISPLAY=:77 LIBGL_ALWAYS_SOFTWARE=1 RUST_LOG=warn RUST_BACKTRACE=1 \
|
|
||||||
niri -c $HERE/niri.kdl >$R/niri.log 2>&1 & echo $! >$R/niri.pid
|
|
||||||
for i in $(seq 50); do ls $RT/wayland-* >/dev/null 2>&1 && break; sleep 0.2; done
|
|
||||||
W=$(ls $RT | grep -m1 '^wayland-[0-9]*$')
|
|
||||||
cat >$R/env <<E2
|
|
||||||
export HOME=$R/home XDG_RUNTIME_DIR=$RT XDG_CONFIG_HOME=$R/home/.config XDG_CACHE_HOME=$R/home/.cache XDG_DATA_HOME=$R/home/.local/share WAYLAND_DISPLAY=$W GDK_BACKEND=wayland
|
|
||||||
unset DISPLAY DBUS_SESSION_BUS_ADDRESS SWAYSOCK
|
|
||||||
export NIRI_SOCKET=\$(ls -d \$XDG_RUNTIME_DIR/niri*.sock)
|
|
||||||
E2
|
|
||||||
echo "wayland=$W"; cat $R/niri.log | tail -5;;
|
|
||||||
stop) kill $(cat $R/niri.pid) $(cat $R/xvfb.pid) 2>/dev/null;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
input {
|
|
||||||
keyboard {
|
|
||||||
xkb {
|
|
||||||
layout "us"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prefer-no-csd
|
|
||||||
hotkey-overlay {
|
|
||||||
skip-at-startup
|
|
||||||
}
|
|
||||||
screenshot-path null
|
|
||||||
animations {
|
|
||||||
off
|
|
||||||
}
|
|
||||||
layout {
|
|
||||||
gaps 0
|
|
||||||
border {
|
|
||||||
off
|
|
||||||
}
|
|
||||||
focus-ring {
|
|
||||||
off
|
|
||||||
}
|
|
||||||
default-column-width {
|
|
||||||
proportion 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# full spike sequence in the nested session: seq.sh <outdir> [env...]
|
|
||||||
S=${SPIKE_RUN:-/tmp/webkit-spike}; HERE=$(cd "$(dirname "$0")" && pwd)
|
|
||||||
O=$1; shift
|
|
||||||
SOFT="LIBGL_ALWAYS_SOFTWARE=1 WEBKIT_DMABUF_RENDERER_FORCE_SHM=1 GTK_A11Y=none GDK_DEBUG=no-portals GSK_RENDERER=gl NO_AT_BRIDGE=1"
|
|
||||||
$HERE/spike.sh $O $SOFT "$@"
|
|
||||||
python3 /home/astar76/Projects/Nacre/tools/engine-test/sample.py --out $O/ram.csv --name '^webkit-egui$' --mark $O/mark --until-gone >$O/sample.log 2>&1 &
|
|
||||||
source $S/env; export WL_INPUT_FLIP_Y=1
|
|
||||||
W=$HERE/../target/release/wl-input
|
|
||||||
c() { echo "$*" >> $O/cmd; }
|
|
||||||
c mark load; sleep 30; c shot loaded
|
|
||||||
c 'js v0 (()=>{const v=document.querySelector("video");return JSON.stringify(v&&{t:v.currentTime,rs:v.readyState,p:v.paused})})()'
|
|
||||||
c mark play; $W winit click 440 360; sleep 5; c stats s0; c sleep 15; c stats play; sleep 16
|
|
||||||
c 'js v1 (()=>{const v=document.querySelector("video");const q=v.getVideoPlaybackQuality();return JSON.stringify({t:v.currentTime,p:v.paused,frames:q.totalVideoFrames,dropped:q.droppedVideoFrames})})()'
|
|
||||||
[ "$ONLYSTATS" = 1 ] && { sleep 2; c quit; exit; }
|
|
||||||
c menu 1; sleep 1; c shot flyout; c pick pick_open 1100 60 1100 120 640 400 600 22; sleep 1
|
|
||||||
$W winit click 1036 117; sleep 1; c state zoom; c pick pick_closed 1100 60 1100 120 640 400 600 22; sleep 1
|
|
||||||
$W winit click 400 300 right; sleep 1.5; c state ctx; c shot ctxmenu; sleep 1.5
|
|
||||||
$W winit click 1200 700; sleep 1; c state ctx_closed
|
|
||||||
c 'js top0 window.scrollY'; $W winit scroll 640 400 5; sleep 1.5; c 'js top1 window.scrollY'; sleep 1
|
|
||||||
# URL field: click it, IME preedit+commit, then typing via virtual keyboard
|
|
||||||
$W winit click 600 22; sleep 0.5; c state urlfocus; sleep 0.5
|
|
||||||
$W winit click 600 22; sleep 0.3; wtype -M ctrl a -m ctrl; wtype -k BackSpace; sleep 0.3
|
|
||||||
$W ime 日本 1.0 >$O/ime_url.log 2>&1 & sleep 0.6; c shot ime_preedit_url; sleep 1.2; c state ime_url
|
|
||||||
wtype ' example.com'; sleep 0.5; c state typed_url; wtype -k Return; sleep 4; c state went; c shot went
|
|
||||||
# page input
|
|
||||||
c 'go https://duckduckgo.com/'; sleep 8; c shot ddg
|
|
||||||
c 'js inp (()=>{const i=document.querySelector("input[name=q]");const r=i.getBoundingClientRect();return JSON.stringify([r.x+r.width/2,r.y+r.height/2])})()'; sleep 1
|
|
||||||
read X Y < <(python3 -c "import json;a=json.load(open('$O/inp.json'));a=json.loads(a) if isinstance(a,str) else a;print(int(a[0]),int(a[1])+46)")
|
|
||||||
$W winit click $X $Y; sleep 0.5; wtype 'abc '; $W ime 日本語 1.0 >$O/ime_page.log 2>&1 & sleep 0.6; c shot ime_preedit_page; sleep 1.2
|
|
||||||
c 'js pageval document.activeElement.tagName+"|"+document.activeElement.value'; sleep 1
|
|
||||||
# popup + tabs
|
|
||||||
c menu 1; sleep 0.5; $W winit click 1094 186; sleep 5; c state popup; c shot popup
|
|
||||||
$W winit click 40 22; sleep 1; c state tab0; c shot tab0
|
|
||||||
c mark idle2; c sleep 10; c quit
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
S=${SPIKE_RUN:-/tmp/webkit-spike}; HERE=$(cd "$(dirname "$0")" && pwd)
|
|
||||||
O=$1; shift
|
|
||||||
SOFT="LIBGL_ALWAYS_SOFTWARE=1 WEBKIT_DMABUF_RENDERER_FORCE_SHM=1 GTK_A11Y=none GDK_DEBUG=no-portals GSK_RENDERER=gl NO_AT_BRIDGE=1"
|
|
||||||
$HERE/spike.sh $O $SOFT SPIKE_URL=https://example.com/ "$@"
|
|
||||||
source $S/env; export WL_INPUT_FLIP_Y=1
|
|
||||||
W=$HERE/../target/release/wl-input
|
|
||||||
c() { echo "$*" >> $O/cmd; }
|
|
||||||
xy() { python3 -c "import json,sys;a=json.load(open('$O/$1.json'));a=json.loads(a) if isinstance(a,str) else a;print(int(a[0]),int(a[1])+46)"; }
|
|
||||||
rect='(()=>{const i=document.querySelector(SEL);const r=i.getBoundingClientRect();return JSON.stringify([r.x+r.width/2,r.y+r.height/2])})()'
|
|
||||||
sleep 8
|
|
||||||
c "js link ${rect/SEL/\"a\"}"; sleep 1; read X Y < <(xy link)
|
|
||||||
$W winit click $X $Y right; sleep 1; c state ctx; c shot ctx_link; sleep 1
|
|
||||||
read CX CY < <(python3 -c "import json;s=json.load(open('$O/ctx.json'));print(int(s['ctx_menu']['x'])+60,int(s['ctx_menu']['y'])+14)")
|
|
||||||
$W winit click $CX $CY; sleep 3; c state ctx_opened; sleep 0.5
|
|
||||||
# IME into the URL field
|
|
||||||
$W winit click 600 22; sleep 0.3; wtype -M ctrl a -m ctrl -k BackSpace; sleep 0.3
|
|
||||||
$W winit ime 日本 1.5 >$O/ime_url.log 2>&1 & sleep 0.7; c shot ime_preedit_url; c state ime_pre_url; sleep 1.5; c state ime_url; sleep 0.5
|
|
||||||
wtype -M ctrl a -m ctrl 'en.wikipedia.org/wiki/Web_browser'; wtype -k Return; sleep 6; c state wiki
|
|
||||||
c 'js top0 window.scrollY'; sleep 0.5; $W winit scroll 640 400 5; sleep 1.5; c 'js top1 window.scrollY'; sleep 0.5
|
|
||||||
# IME into a page input
|
|
||||||
c 'go https://duckduckgo.com/'; sleep 7
|
|
||||||
c "js inp ${rect/SEL/\"textarea,input[name=q]\"}"; sleep 1; read X Y < <(xy inp)
|
|
||||||
$W winit click $X $Y; sleep 0.5; wtype 'abc '; $W winit ime 日本語 1.5 >$O/ime_page.log 2>&1 & sleep 0.7; c shot ime_preedit_page
|
|
||||||
c 'js pagepre document.activeElement.value'; sleep 1.5
|
|
||||||
c 'js pageval document.activeElement.tagName+"|"+document.activeElement.value'; sleep 1; c shot ime_page; c quit
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue