Bug 1756696. Make sure image decoding has finished in netwerk/test/browser/browser_opaque_response_blocking_telemetry.js. r=aosmond

Because these images are loaded as embeds/objects we can't get a hold of them to apply most usual methods of waiting for decode (img.decode, using a special powers image notifications observer). This should hopefully be enough to avoid hitting this in automation.

Backout the patch for bug 1722422 (the one that changed it from an assert to a leak) because I think it's easier to classify/recognize the assert than the leak in the logs.

Differential Revision: https://phabricator.services.mozilla.com/D139464
This commit is contained in:
Timothy Nikkel 2022-02-23 13:23:41 +00:00
Родитель 7bc7d1ad66
Коммит d98b94ac1c
2 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -29,7 +29,6 @@
#include "mozilla/StaticPrefs_image.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Tuple.h"
#include "mozilla/Unused.h"
#include "nsExpirationTracker.h"
#include "nsHashKeys.h"
#include "nsIMemoryReporter.h"
@ -1880,13 +1879,9 @@ void SurfaceCache::ReleaseImageOnMainThread(
return;
}
// Don't try to dispatch the release after shutdown.
// Don't try to dispatch the release after shutdown, we'll just leak the
// runnable.
if (gXPCOMThreadsShutDown) {
// Note, this intentionally leaks! If we can't dispatch to the main thread
// because we are late in shutdown then it's better to leak then to release
// on this thread.
image::Image* intentionalLeak = aImage.take();
Unused << intentionalLeak;
return;
}

Просмотреть файл

@ -153,6 +153,33 @@ add_task(async function() {
browser,
[testcase.url, testcase.loadType, testcase.iframe],
async (url, loadType, iframe) => {
async function ensureDecodeFinished() {
// Calling drawWindow (via snapshotWindowWithOptions) sync decodes
// images by default, as long as this asks for the same image
// surface with the same options it should force the decode that
// was kicked off by being in the document to finish.
SpecialPowers.snapshotWindowWithOptions(
content.window,
undefined /* use the default rect */,
undefined /* use the default bgcolor */,
// Use flags to make this snapshot as close as possible to
// drawing to the screen.
{
DRAWWINDOW_DRAW_VIEW: true,
DRAWWINDOW_USE_WIDGET_LAYERS: true,
DRAWWINDOW_DRAW_CARET: true,
}
);
// And then wait two frames to make sure the results of that
// decode are flushed to the screen.
await new Promise(r =>
content.requestAnimationFrame(() =>
content.requestAnimationFrame(r)
)
);
}
try {
if (loadType == "media") {
const audio = content.document.createElement("audio");
@ -188,6 +215,7 @@ add_task(async function() {
});
content.document.body.appendChild(object);
await onloadPromise;
await ensureDecodeFinished();
content.document.body.removeChild(object);
return;
}
@ -199,6 +227,7 @@ add_task(async function() {
});
content.document.body.appendChild(embed);
await onloadPromise;
await ensureDecodeFinished();
content.document.body.removeChild(embed);
return;
}