mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
Bug 1758029: Gracefully bail out of canvas SVG-filter invalidation codepath, if the canvas has been unlinked due to cycle collection. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D140419
This commit is contained in:
parent
bfa9c70d05
commit
9f74bc949f
@ -864,7 +864,10 @@ class SVGFilterObserverListForCanvasContext final
|
||||
|
||||
void SVGFilterObserverListForCanvasContext::OnRenderingChange() {
|
||||
if (!mContext) {
|
||||
MOZ_CRASH("GFX: This should never be called without a context");
|
||||
NS_WARNING(
|
||||
"GFX: This should never be called without a context, except during "
|
||||
"cycle collection (when DetachFromContext has been called)");
|
||||
return;
|
||||
}
|
||||
// Refresh the cached FilterDescription in mContext->CurrentState().filter.
|
||||
// If this filter is not at the top of the state stack, we'll refresh the
|
||||
|
40
layout/svg/crashtests/1758029-1.html
Normal file
40
layout/svg/crashtests/1758029-1.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
body { background: gray; }
|
||||
canvas { border: 2px solid black;}
|
||||
</style>
|
||||
|
||||
<img id="img"
|
||||
onload="go()"
|
||||
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAKElEQVR42u3NQQ0AAAgEoNP+nTWFDzcoQE1udQQCgUAgEAgEAsGTYAGjxAE/G/Q2tQAAAABJRU5ErkJggg==">
|
||||
<canvas id="canvas"></canvas>
|
||||
<script>
|
||||
const ctx = canvas.getContext("2d", { desynchronized: true });
|
||||
const SVG_FILTER = `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<filter id="posterize">
|
||||
<feComponentTransfer>
|
||||
<feFuncR type="discrete" tableValues="0,1" />
|
||||
<feFuncG type="discrete" tableValues="0,1" />
|
||||
<feFuncB type="discrete" tableValues="0,1" />
|
||||
<feFuncA type="discrete" tableValues="0,1" />
|
||||
</feComponentTransfer>
|
||||
</filter>
|
||||
</svg>`;
|
||||
|
||||
const FILTER1 = `url('data:image/svg+xml;utf8,${SVG_FILTER.replace(/\n/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim()}#posterize') grayscale(50%) brightness(50%)`;
|
||||
function go() {
|
||||
canvas.width = img.naturalWidth;
|
||||
canvas.height = img.naturalHeight;
|
||||
|
||||
ctx.imageSmoothingEnabled = true;
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
ctx.filter = FILTER1;
|
||||
ctx.drawImage(img, 0, 0);
|
||||
setTimeout(() => { document.documentElement.removeAttribute("class")}, 0);
|
||||
}
|
||||
</script>
|
@ -238,3 +238,4 @@ load 1609663.html
|
||||
skip-if(Android) load 1671950.html # No print-preview support on android
|
||||
load 1678947.html
|
||||
load 1693032.html
|
||||
load 1758029-1.html
|
||||
|
Loading…
Reference in New Issue
Block a user