Bug 1849704. Don't create a new ImageBitmapShutdownObserver if we are in XPCOMShutdown or later. r=gfx-reviewers,aosmond

XPCOMShutdownThreads is the phase just after XPCOMShutdown and XPCOMShutdown is when we destory the ImageBitmapShutdownObserver, so we need to not create a new ImageBitmapShutdownObserver if we are in XPCOMShutdown or later.

Differential Revision: https://phabricator.services.mozilla.com/D186852
This commit is contained in:
Timothy Nikkel 2023-08-25 19:10:10 +00:00
parent 9854503d07
commit 29dee56fcb
3 changed files with 38 additions and 1 deletions

View File

@ -647,7 +647,7 @@ ImageBitmap::ImageBitmap(nsIGlobalObject* aGlobal, layers::Image* aData,
StaticMutexAutoLock lock(sShutdownMutex);
if (!sShutdownObserver &&
!AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) {
!AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdown)) {
sShutdownObserver = new ImageBitmapShutdownObserver();
}
if (sShutdownObserver) {

View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TransferToImageBitmap</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id='myWorker' type='text/worker'>
self.onmessage = function(e) {
var canvas = new OffscreenCanvas(128, 128);
var gl = canvas.getContext("webgl2");
gl.clearColor(1.0, 1.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
var image = canvas.transferToImageBitmap();
self.postMessage({ bitmap: image },
[ image ]);
};
</script>
<script>
var blob = new Blob([document.getElementById('myWorker').textContent]);
var worker = new Worker(URL.createObjectURL(blob));
worker.onmessage = function (msg) {
try { worker.postMessage('Start worker'); } catch (e) { }
};
try { worker.postMessage('Start worker'); } catch (e) { }
</script>
</body>
</html>

View File

@ -65,3 +65,4 @@ load 1757755.html
pref(gfx.offscreencanvas.enabled,true) load 1769878.html
pref(gfx.offscreencanvas.enabled,true) load 1771007-1.html
pref(dom.webgpu.enabled,true) load 1816140.html
load 1849704-1.html