Closed Bug 1747431 Opened 3 years ago Closed 3 years ago

Nightly OffscreenCanvas API breaks multiple visualization libraries

Categories

(Core :: Graphics: CanvasWebGL, defect, P3)

Firefox 97
x86_64
Windows 10
defect

Tracking

()

RESOLVED INVALID
Tracking Status
firefox-esr91 --- unaffected
firefox95 --- unaffected
firefox96 --- unaffected
firefox97 --- disabled

People

(Reporter: bpeiris, Unassigned)

References

(Regression)

Details

(Keywords: regression)

Edit: This bug was initially filed to report issues with the three.js library, but as commented below, we've found that it breaks several other libraries and sites.

Older versions of three.js (versions r109 to r111) attempt to feature-detect and use the OffscreenCanvas API. However this breaks in Nightly since it seems the API implementation is partial or incompatible.

The error occurs while three.js is initializing, which means it breaks three.js-based apps entirely. This will cause issues with our Mozilla Hubs Cloud product as well, since some users choose to use older custom client code, which use older versions of three.js.

The error message is Uncaught TypeError: OffscreenCanvas.getContext: '2d' (value of argument 1) is not a valid value for enumeration OffscreenRenderingContextId.

The error can be reproduced in Nightly with this example page:
https://rawcdn.githack.com/mrdoob/three.js/r111/examples/webgl_materials_envmaps_hdr.html

Cannot be reproduced in Firefox Stable or Chrome.

Can confirm. It's been reported as https://github.com/webcompat/web-bugs/issues/97181 for pinafore.social, though bug was rejected because the site needs a Mastodon account in order to check.

Two-liner test case:

var x = new OffscreenCanvas(32, 32);
var y = x.getContext("2d");

I believe it was broken in hg changeset https://hg.mozilla.org/mozilla-central/rev/25ca519aa6fc61f63feb42446740a9f68170c8c2.

Flags: needinfo?(nbeleuzu)
Flags: needinfo?(nbeleuzu) → needinfo?(aosmond)
Regressed by: 1746110
Has Regression Range: --- → yes

Probably depends on bug 1746750, since bug 1736177 was only about webgl implementation. Please revert if not.

Depends on: 1746750

Set release status flags based on info from the regressing bug 1746110

Offscreen canvas is currently held to Nightly. These three.js revisions are over two years old. Don't think this warrants a backout of our OC work, or even holds up our eventual rollout. (Sites that use the older revs of three.js can upgrade.)

Severity: -- → S4
Flags: needinfo?(aosmond)
Priority: -- → P3

(In reply to Jim Mathies [:jimm] from comment #4)

Don't think this warrants a backout of our OC work, or even holds up our eventual rollout.

Apologies for disagreeing here, but as I said in comment 1,

var x = new OffscreenCanvas(32, 32);
var y = x.getContext("2d");

is a completely standalone test case (no three.js involved) and it's been regressed on 97. This renders any site that uses OffscreenCanvas with a 2d context unusable, because getContext is not supposed to throw an exception with a fully documented and valid enum value; it should, at the very least, return null instead. See https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext#parameters .

In my own case, I've had to gfx.offscreencanvas.enable set to false in order to be able to read my Mastodon timeline again via https://pinafore.social.

We've got a report in https://github.com/webcompat/web-bugs/issues/97457 and the same issue is present in a current version of cytoscape.
The library is being used by a lot of sites according to https://js.cytoscape.org/#introduction/who-uses-cytoscape.js

(In reply to Jim Mathies [:jimm] from comment #4)

Offscreen canvas is currently held to Nightly.

Does this mean that this regression will not be released to Stable?

This also affects mapgenie.io, which is using mapbox.

Example on mapbox website https://docs.mapbox.com/mapbox-gl-js/example/add-terrain/, where 3d terrain is not rendered
(getContext('2d') is being used in https://github.com/mapbox/mapbox-gl-js/blob/main/src/source/raster_dem_tile_worker_source.js#L29)

Summary: Nightly OffscreenCanvas API breaks older versions of three.js → Nightly OffscreenCanvas API breaks multiple visualisation libraries
Summary: Nightly OffscreenCanvas API breaks multiple visualisation libraries → Nightly OffscreenCanvas API breaks multiple visualization libraries

mapbox-gl-js attempts to detect the support, but it does not consider the case where .getContext('2d') throws.

:jimm, can you please re-evaluate this based on comment 5 and comment 6? It looks like the scope larger than initially seen and this is causing webcompat issues. Thanks!

Flags: needinfo?(jmathies)

This also breaks image previews in Matrix/Element chats.

OffscreenCanvas was preffed off for 97.

Flags: needinfo?(jmathies)

We changed plans to ship via a simplified origin trial and we are implementing the necessary remaining pieces for Canvas2D in 2022. I think we can close this.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.