while ((analyser.getByteFrequencyData(dataArray), dataArray.every(v => v == 0))) {
await new Promise(r => requestAnimationFrame(r));
}
const count = await SpecialStream.countUnderlyingStreams();
parent.postMessage({ type: "ready", value: count }, "*");
} else if (event.data === "destroy") {
// Clean up all resources
if (stream) {
// Stopping the MediaStreamTrack breaks connection to
// CrossGraphTransmitter, which can cause issues if the
// transmitter attempts to read from that connection during
// ::ProcessInput before the CrossGraph pair is fully torn
// down.
stream.getTracks().forEach(track => track.stop());
stream = null;
}
if (analyser) {
analyser.disconnect();
analyser = null;
}
if (sourceNode) {
sourceNode.disconnect();
sourceNode = null;
}
if (ctx) {
await ctx.close();
ctx = null;
}
dataArray = null;
// Force garbage collection
await new Promise(r => SpecialPowers.exactGC(r));
// Helper to wait for iframe messages
const waitForMessage = (type) => {
return new Promise(resolve => {
const handler = (event) => {
if (event.data.type === type) {
window.removeEventListener("message", handler);
resolve(event.data.value);
}
};
window.addEventListener("message", handler);
});
};
// Wait for iframe to initialize and get initial stream count
const initialCount = await waitForMessage("init");
dump(`Initial stream count: ${initialCount}\n`);
// Start audio and wait for it to be ready iframe.contentWindow.postMessage("startAudio", "*");
const readyCount = await waitForMessage("ready");
dump(`Stream count when audio ready: ${readyCount}\n`);
// Destroy all resources in the iframe while MediaStream is active iframe.contentWindow.postMessage("destroy", "*");
const finalCount = await waitForMessage("destroyed");
dump(`Final stream count: ${finalCount}\n`);
// Check if streams were cleaned up
if (finalCount === initialCount) {
document.documentElement.removeAttribute("class");
} else {
dump("Streams were not cleaned up properly.\n");
}
});
</script>
</head>
<body></body>
</html>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.