Commit Graph

128 Commits

Author SHA1 Message Date
Jamie Nicol
9526c88d05 Bug 1898238 - Don't call TexTypeForWebgl when initializing offscreen canvas. r=aosmond,jgilbert
This is only used if the OffscreenCanvas has a webgl context, in which
case it forwards the tex type to WebGLContext::PresentFrontBuffer(). A
later patch in this series will make TexTypeForWebgl() return a
different value depending on whether the webgl context is in-process
or remote, which is something that cannot be known when the
OffscreenCanvas is initialized. This patch therefore removes the field
from OffscreenCanvas and makes WebGLContext::PresentFrontBuffer() call
TexTypeForWebgl() itself.

Differential Revision: https://phabricator.services.mozilla.com/D211289
2024-07-22 20:23:37 +00:00
Iulian Moraru
724263a29c Backed out 5 changesets (bug 1898238) for causing non unified build bustages on RenderEGLImageTextureHost.cpp. CLOSED TREE
Backed out changeset ae8e94c8f819 (bug 1898238)
Backed out changeset 549abd685d11 (bug 1898238)
Backed out changeset 6359e558d765 (bug 1898238)
Backed out changeset 332c668a15bc (bug 1898238)
Backed out changeset 19fa8d4af66f (bug 1898238)
2024-07-22 20:27:45 +03:00
Jamie Nicol
ae417c018f Bug 1898238 - Don't call TexTypeForWebgl when initializing offscreen canvas. r=aosmond,jgilbert
This is only used if the OffscreenCanvas has a webgl context, in which
case it forwards the tex type to WebGLContext::PresentFrontBuffer(). A
later patch in this series will make TexTypeForWebgl() return a
different value depending on whether the webgl context is in-process
or remote, which is something that cannot be known when the
OffscreenCanvas is initialized. This patch therefore removes the field
from OffscreenCanvas and makes WebGLContext::PresentFrontBuffer() call
TexTypeForWebgl() itself.

Differential Revision: https://phabricator.services.mozilla.com/D211289
2024-07-22 16:02:33 +00:00
Andrew Osmond
4a490fa10f Bug 1888634 - Disallow captureStream with canvas transferred to DOM worker. r=gfx-reviewers,lsalzman
This behaviour has yet to be defined by the spec and/or WPT, see:

https://github.com/w3c/mediacapture-fromelement/issues/65
https://github.com/w3c/mediacapture-extensions/pull/26
https://github.com/web-platform-tests/wpt/issues/21102

Differential Revision: https://phabricator.services.mozilla.com/D207582
2024-04-17 12:57:56 +00:00
Andrew Osmond
bc84f1c089 Bug 1877429 - Prevent offscreen canvas2d updates from racing with compositing. r=gfx-reviewers,lsalzman
When OffscreenCanvas::CommitFrameToCompositor uses the non-remote
texture canvas path with Skia, it uses ImageBridgeChild for compositing.
When ImageContainer::SetCurrentImages is called, there was an
intermediate state where the relevant textures were not yet marked as
read only for the compositor's consumption, because the event to do so
was dispatched asynchronously to the ImageBridgeChild thread. If the
owning thread of the canvas (main or DOM worker) ran immediately after
CommitFrameToCompositor, then we could run into texture reuse since
nothing marked the texture yet as being used for compositing. This had
the end result of sometimes displaying back buffer textures currently
being used for drawing on the display pipeline.

This patch makes it so that we mark OffscreenCanvas textures as read
only for the compositor before dispatching, and releasing the lock
either when we swap the images in the ImageContainer (winning the race
with ImageBridgeChild), or after the compositor has finished with it
(losing the race, if any, with ImageBridgeChild).

Additionally, to handle better the case where we run out of buffers, we
need to implement ImageBridgeChild::SyncWithCompositor, to be analogous
to how WebRenderBridgeChild::SyncWithCompositor works. We achieve this
by calling from ImageBridgeChild back into the appropriate
WebRenderBridgeChild based on the window ID associated with the canvas,

It also adds a new pref, gfx.offscreencanvas.shared-provider, which
allows one to switch between PersistentBufferProviderShared and Basic.
The latter of which is used if we fallback from using shared buffers if
it takes too long to get the shared buffers back from the compositor.

Differential Revision: https://phabricator.services.mozilla.com/D200991
2024-02-07 20:25:52 +00:00
Kaiido
d330f045c6 Bug 1872237 - Update detached OffscreenCanvas error messages. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D197370
2024-01-11 12:29:01 +00:00
Andrew Osmond
b7b5b39189 Bug 1870957 - Part 4. Refactor canvas shutdown to be synchronized with CanvasManagerChild. r=lsalzman
Because we cannot control the ordering of shutdown notification from
WorkerRef, we need to choose one centralized point to begin shutdown of
the main thread or the owning DOM worker. Since there are other objects
owned by CanvasManagerChild, we also switch to a ThreadSafeWorkerRef.

Differential Revision: https://phabricator.services.mozilla.com/D195120
2023-12-20 13:01:19 +00:00
Noemi Erli
0340d8233c Backed out 12 changesets (bug 1795296, bug 1855742) as requested by aosmond a=backout
Backed out changeset 05b607c3bbe6 (bug 1795296)
Backed out changeset 7704291111b4 (bug 1855742)
Backed out changeset db60743295fb (bug 1855742)
Backed out changeset 8ed51e7d1c98 (bug 1855742)
Backed out changeset 40cba2c51b1c (bug 1855742)
Backed out changeset d4bfe15c07ec (bug 1855742)
Backed out changeset 2061271c53e8 (bug 1855742)
Backed out changeset 5b2a89a61f7f (bug 1855742)
Backed out changeset 2028c7018977 (bug 1855742)
Backed out changeset 13e806495fb8 (bug 1855742)
Backed out changeset 4bfa0d4913a2 (bug 1855742)
Backed out changeset 711b3f47e380 (bug 1855742)
2023-12-19 17:25:55 +02:00
Andrew Osmond
63d0eb1dc2 Bug 1855742 - Part 5. Refactor canvas shutdown to be synchronized with CanvasManagerChild. r=lsalzman
Because we cannot control the ordering of shutdown notification from
WorkerRef, we need to choose one centralized point to begin shutdown of
the main thread or the owning DOM worker. Since there are other objects
owned by CanvasManagerChild, we also switch to a ThreadSafeWorkerRef.

Differential Revision: https://phabricator.services.mozilla.com/D195120
2023-12-19 05:10:33 +00:00
Kagami Sascha Rosylight
c1e45850a8 Bug 1862244 - Add GlobalTeardownHelper r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D193295
2023-11-23 17:17:39 +00:00
Andrew Osmond
41f2c4a566 Bug 1850871 - Resize canvas in ImageBitmapRenderingContext::TransferFromImageBitmap. r=gfx-reviewers,lsalzman
This patch makes it so that when a new ImageBitmap is provided to an
ImageBitmapRenderingContext, we resize its owning canvas rather than
crop or scale the given ImageBitmap to fit inside the canvas dimensions.

See discussion in https://github.com/whatwg/html/issues/7833.

Differential Revision: https://phabricator.services.mozilla.com/D188126
2023-10-16 11:23:43 +00:00
Andrew Osmond
e440533327 Bug 1848875 - Throw InvalidStateError when cloning OffscreenCanvas with context. r=gfx-reviewers,lsalzman
This patch makes us follow the standard and pass WPT tests regarding the
cloning of OffscreenCanvas with a context. It also makes us throw a less
generic message when attempting to clone an OffscreenCanvas that has
already been cloned/transferred to a worker.

Differential Revision: https://phabricator.services.mozilla.com/D186265
2023-08-16 12:06:34 +00:00
Andrew Osmond
2d890a764c Bug 1837070 - Ensure we flush OffscreenCanvas when the display list is recreated. r=lsalzman
When we recreate the display list, e.g. after tabbing away, we need to
ensure we flush the OffscreenCanvas because our resource handles will be
invalidated. This requires the OffscreenCanvasDisplayHelper to know
which OffscreenCanvas it belongs to, and a worker reference if necessary
to do the dispatching for the flush. Otherwise we would require the
canvas to be updated manually by the web application to repaint.

Differential Revision: https://phabricator.services.mozilla.com/D184324
2023-07-23 20:42:41 +00:00
Andrew Osmond
aa9c7099b5 Bug 1833876. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D179483
2023-07-18 16:29:47 +00:00
Tim Huang
711f354ff0 Bug 1816189 - Part 3: Moving ShouldResistFingerprinting() to nsICanvasRenderingContextInternal from ClientWebCLContext and add a RFPTarget as an input argument. r=tjr,lsalzman
This patch moves ShouldResistFingerprinting() and add a RFPTarget as
input argument. We will use this function to check if canvas
fingerprinting protection is enabled.

We also modify the caller to pass the right RFPTarget for Canvas image
data extraction prompt. Note that, we need to set the default argument
for the function to known because it's used for WebGL fingerprinting
protection too. However, We don't cut over this part in this patch and
will do it in a future bug.

Differential Revision: https://phabricator.services.mozilla.com/D175608
2023-05-08 14:04:34 +00:00
Jim Blandy
8d28dad728 Bug 1816140: Check that OffscreenCanvas width and height fit in int32_t. r=gfx-reviewers,webidl,aosmond,nical,smaug
Differential Revision: https://phabricator.services.mozilla.com/D169508
2023-02-14 00:18:37 +00:00
Kaiido
b80360af65 Bug 1799058 - Reset context on SetWidth and SetHeight. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D161925
2022-11-22 07:53:29 +00:00
Emilio Cobos Álvarez
03f11818fd Bug 1796819 - Remove OffscreenCanvas origin trial / domain allowlist. r=aosmond
We've shipped this, a single pref should be enough.

Differential Revision: https://phabricator.services.mozilla.com/D159947
2022-10-21 19:00:57 +00:00
Kelsey Gilbert
49a2625ba0 Bug 1794956 - TransferToImageBitmap should reset bitmap but not state. r=gfx-reviewers,lsalzman
s/Reset/ResetBitmap/ and implement for WebGL and WebGPU.

Differential Revision: https://phabricator.services.mozilla.com/D159346
2022-10-16 22:52:40 +00:00
Iulian Moraru
bd5791d52c Backed out 2 changesets (bug 1794956) for causing wpt failures on offscreencanvas.transfer.to.imagebitmap.html. CLOSED TREE
Backed out changeset 7b3067b086e6 (bug 1794956)
Backed out changeset 3abcf6ccf88a (bug 1794956)
2022-10-15 19:09:01 +03:00
Kelsey Gilbert
b3044b4370 Bug 1794956 - TransferToImageBitmap should reset bitmap but not state. r=gfx-reviewers,lsalzman
s/Reset/ResetBitmap/ and implement for WebGL and WebGPU.

Differential Revision: https://phabricator.services.mozilla.com/D159346
2022-10-15 09:01:46 +00:00
Jens Stutte
32e9225b8a Bug 1776878 - Extract the WorkerRef initialization from the EventCallback constructor. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D150491
2022-07-06 17:43:24 +00:00
Olli Pettay
0653a08f06 Bug 1769878, ensure objects owned by the worker thread are cleared when the worker is shutting down, r=asuth,aosmond
Depends on D147858

Differential Revision: https://phabricator.services.mozilla.com/D149693
2022-06-22 14:06:31 +00:00
Jens Stutte
d544252e5e Bug 1769878 - Remove redundant RefPtr<nsIGlobalObject> from EncodeComplete callback. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147858
2022-06-22 14:06:30 +00:00
Andrew Osmond
bd22f89c38 Bug 1753302 - Part 1. Integrate WebGPU with OffscreenCanvas plumbing. r=gfx-reviewers,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D141491
2022-04-04 16:42:02 +00:00
Andrew Osmond
b95b412f0d Bug 1756864 - Fix several WPT failures surrounding neutered/no context OffscreenCanvas. r=gfx-reviewers,lsalzman
Mostly changing whether we throw, not throw, or throw a specific
exception.

Differential Revision: https://phabricator.services.mozilla.com/D139516
2022-02-28 16:12:47 +00:00
Andrew Osmond
1190d92588 Bug 1756687 - Fix OffscreenCanvas::ConvertToBlob and WPT tests. r=gfx-reviewers,bradwerth
We should throw when the OffscreenCanvas is empty, and we should ignore
the quality parameter for image encoders that do not support it.

Differential Revision: https://phabricator.services.mozilla.com/D139425
2022-02-22 22:52:40 +00:00
Andrew Osmond
67e3b5ea0c Bug 1746750 - Part 3. Implement partial OffscreenCanvasRenderingContext2D. r=lsalzman,webidl,smaug
This patch adds a partial OffscreenCanvasRenderingContext2D
implementation. It is missing anything text and UI related, including
CanvasFilters, CanvasUserInterface, CanvasText, CanvasTextDrawingStyles,
and CanvasHitRegions.

Differential Revision: https://phabricator.services.mozilla.com/D135354
2022-02-03 20:00:25 +00:00
Iulian Moraru
6d4e168ab0 Backed out 4 changesets (bug 1746750) as per request. CLOSED TREE
Backed out changeset bf79a6b72d87 (bug 1746750)
Backed out changeset 87dde3962558 (bug 1746750)
Backed out changeset 08e0ff1804f6 (bug 1746750)
Backed out changeset 4a3da2db3bc0 (bug 1746750)
2022-02-03 03:24:42 +02:00
Andrew Osmond
ddb298ce9c Bug 1746750 - Part 3. Implement partial OffscreenCanvasRenderingContext2D. r=lsalzman,webidl,smaug
This patch adds a partial OffscreenCanvasRenderingContext2D
implementation. It is missing anything text and UI related, including
CanvasFilters, CanvasUserInterface, CanvasText, CanvasTextDrawingStyles,
and CanvasHitRegions.

Differential Revision: https://phabricator.services.mozilla.com/D135354
2022-02-02 23:25:51 +00:00
Iulian Moraru
e2e1e48917 Backed out 4 changesets (bug 1746750) for causing mochitest webgl failures on test_2_conformance2__offscreencanvas__offscreencanvas-sync.html. CLOSED TREE
Backed out changeset 011f75653bfb (bug 1746750)
Backed out changeset 9c2aca08a507 (bug 1746750)
Backed out changeset cccf6afc3ce9 (bug 1746750)
Backed out changeset 36fedb339908 (bug 1746750)
2022-02-02 23:28:30 +02:00
Andrew Osmond
984a54c8cc Bug 1746750 - Part 3. Implement partial OffscreenCanvasRenderingContext2D. r=lsalzman,webidl,smaug
This patch adds a partial OffscreenCanvasRenderingContext2D
implementation. It is missing anything text and UI related, including
CanvasFilters, CanvasUserInterface, CanvasText, CanvasTextDrawingStyles,
and CanvasHitRegions.

Differential Revision: https://phabricator.services.mozilla.com/D135354
2022-02-02 16:41:26 +00:00
Andrew Osmond
9cb33c7532 Bug 1751205 - Part 2. Ensure we y-flip surfaces with OffscreenCanvas if needed. r=gfx-reviewers,jgilbert
On the path that we need to read the pixels from the canvas for display
purposes, instead of using a platform buffer handle, we need to take
into account the need to y-flip for WebGL. This patch ensures that we do
so.

Differential Revision: https://phabricator.services.mozilla.com/D136504
2022-02-01 13:20:50 +00:00
Norisz Fay
187a2bb9ef Backed out 2 changesets (bug 1751205) for causing multiple wpt failures on offscreencanvas.resize.html CLOSED TREE
Backed out changeset 70e5f13d08cc (bug 1751205)
Backed out changeset e97271d90795 (bug 1751205)
2022-01-28 09:14:15 +02:00
Andrew Osmond
f3161d747f Bug 1751205 - Part 2. Ensure we y-flip surfaces with OffscreenCanvas if needed. r=gfx-reviewers,jgilbert
On the path that we need to read the pixels from the canvas for display
purposes, instead of using a platform buffer handle, we need to take
into account the need to y-flip for WebGL. This patch ensures that we do
so.

Differential Revision: https://phabricator.services.mozilla.com/D136504
2022-01-28 05:16:02 +00:00
Andrew Osmond
87329bae6c Bug 1749323 - Allow controlling access to OffscreenCanvas via a domain allowlist pref. r=gfx-reviewers,webidl,lsalzman,smaug
This patch adds several new prefs to control what happens with
OffscreenCanvas. gfx.offscreencanvas.enabled works as it did before.

- gfx.offscreencanvas.domain-enabled: Enables OffscreenCanvas for
domains on the allowlist.

- gfx.offscreencanvas.domain-allowlist: Comma separated allowlist
which controls which domains can access the OffscreenCanvas constructor
and HTMLCanvasElement.transferControlToOffscreen.

- dom.workers.requestAnimation: Controls whether or not
request/cancelAnimationFrame are accessible from dedicated workers.
Ideally this would have used the same decision process as
OffscreenCanvas but there were unrelated build/runtime issues around
using a Func directive with DedicatedWorkerGlobalScope.

Differential Revision: https://phabricator.services.mozilla.com/D135928
2022-01-24 16:12:02 +00:00
Andrew Osmond
fb14462521 Bug 1747476 - Fix resizing errors with OffscreenCanvas. r=gfx-reviewers,kvark,mstange
When we attempt to resize an OffscreenCanvas, or an HTMLCanvasElement
with transferControlToOffscreen caled on it, we need to ensure we throw
the right error, and a message that is clear to the user. We also need
to propogate size changes to the placeholder
HTMLCanvasElement/OffscreenCanvas, when the OffscreenCanvas object on
the worker thread has its size changed.

Differential Revision: https://phabricator.services.mozilla.com/D134637
2021-12-28 16:47:02 +00:00
Andrew Osmond
bc47bc2bda Bug 1747520 - Ensure that OffscreenCanvas invalidation is in a consistent state. r=gfx-reviewers,kvark
This patch ensures that our invalidation is more consistent and less
frequent. It no longer queues an invalidation for each draw call. It now
combines the parameter update (e.g. width, height, opacity) with an
invalidation to ensure the contents of the canvas are consistent with
the advertised properties. It also ensures that if an explicit commit
occurs, any pending commits are cancelled.

Differential Revision: https://phabricator.services.mozilla.com/D134655
2021-12-24 17:04:39 +00:00
Andrew Osmond
7dc8d79a28 Bug 1746059 - Fix broken ImageBitmapRenderingContext::TransferFromImageBitmap for OffscreenCanvas. r=lsalzman,emilio
This patch ensures that when we call TransferFromImageBitmap, it
actually gets the correct result and resets the context to all black,
instead of just crashing. We now also clear the ImageContainer properly
instead of adding a null image if none is provided.

Differential Revision: https://phabricator.services.mozilla.com/D133806
2021-12-15 21:36:20 +00:00
Andrew Osmond
51d7cf43a9 Bug 1736177 - Part 11. Plumb in OffscreenCanvasDisplayHelper. r=jgilbert
This patch integrates OffscreenCanvasDisplayHelper with
HTMLCanvasElement, OffscreenCanvas and nsDisplayCanvas to allow
asynchronous display of an OffscreenCanvas.

Differential Revision: https://phabricator.services.mozilla.com/D130787
2021-12-10 02:57:55 +00:00
Andrew Osmond
008be814e5 Bug 1736177 - Part 5. Implement OffscreenCanvas::ConvertToBlob. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D130781
2021-12-10 02:57:53 +00:00
Andrew Osmond
149cf96cef Bug 1736177 - Part 3. Update OffscreenCanvas WebIDL to be more current. r=dom-worker-reviewers,jgilbert,smaug
Differential Revision: https://phabricator.services.mozilla.com/D130779
2021-12-10 02:57:52 +00:00
Andrew Osmond
e2806fd95c Bug 1736177 - Part 2. Add variants of CanvasRenderingContextHelper::ToBlob. r=jgilbert
This patch contains no functional changes but sets us up for refactoring
in a later part in this series.

Differential Revision: https://phabricator.services.mozilla.com/D130778
2021-12-10 02:57:52 +00:00
Andrew Osmond
86d592cb56 Bug 1736177 - Part 1. Rename CanvasRenderingContextHelper::GetContext to GetOrCreateContext. r=jgilbert
This patch contains no functional changes but sets us up for refactoring
in a later part in this series. It also helps silence a bunch of
compiler warnings.

Differential Revision: https://phabricator.services.mozilla.com/D130777
2021-12-10 02:57:51 +00:00
Csoregi Natalia
77f4c3192d Backed out 17 changesets (bug 1738971, bug 1736177) for bp-hybrid failures and others. CLOSED TREE
Backed out changeset 828633114de2 (bug 1736177)
Backed out changeset 5be8557c4721 (bug 1736177)
Backed out changeset 49f8b4205a46 (bug 1736177)
Backed out changeset 2610d4464ad5 (bug 1736177)
Backed out changeset 6d6c78c31c28 (bug 1736177)
Backed out changeset d55f1ee88bb9 (bug 1736177)
Backed out changeset bf588f8ffcf1 (bug 1736177)
Backed out changeset 86f6f6d86c6c (bug 1736177)
Backed out changeset f400c75c5829 (bug 1736177)
Backed out changeset 4a34124d5f4e (bug 1736177)
Backed out changeset 70aff7fcd001 (bug 1736177)
Backed out changeset db2347ee8147 (bug 1736177)
Backed out changeset 3dde5ddb65e5 (bug 1738971)
Backed out changeset 894ba6b7b68f (bug 1738971)
Backed out changeset dc4503052cf1 (bug 1738971)
Backed out changeset d9aef3e9797e (bug 1738971)
Backed out changeset 562a1e8e5ac3 (bug 1738971)
2021-12-10 01:13:23 +02:00
Andrew Osmond
c2d0f104c6 Bug 1736177 - Part 11. Plumb in OffscreenCanvasDisplayHelper. r=jgilbert
This patch integrates OffscreenCanvasDisplayHelper with
HTMLCanvasElement, OffscreenCanvas and nsDisplayCanvas to allow
asynchronous display of an OffscreenCanvas.

Differential Revision: https://phabricator.services.mozilla.com/D130787
2021-12-09 19:25:28 +00:00
Andrew Osmond
cf622976ac Bug 1736177 - Part 5. Implement OffscreenCanvas::ConvertToBlob. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D130781
2021-12-09 19:25:26 +00:00
Andrew Osmond
7a75acda7d Bug 1736177 - Part 3. Update OffscreenCanvas WebIDL to be more current. r=dom-worker-reviewers,jgilbert,smaug
Differential Revision: https://phabricator.services.mozilla.com/D130779
2021-12-09 19:25:24 +00:00
Andrew Osmond
6616367e26 Bug 1736177 - Part 2. Add variants of CanvasRenderingContextHelper::ToBlob. r=jgilbert
This patch contains no functional changes but sets us up for refactoring
in a later part in this series.

Differential Revision: https://phabricator.services.mozilla.com/D130778
2021-12-09 19:25:24 +00:00
Andrew Osmond
32ec981831 Bug 1736177 - Part 1. Rename CanvasRenderingContextHelper::GetContext to GetOrCreateContext. r=jgilbert
This patch contains no functional changes but sets us up for refactoring
in a later part in this series. It also helps silence a bunch of
compiler warnings.

Differential Revision: https://phabricator.services.mozilla.com/D130777
2021-12-09 19:25:24 +00:00