Commit Graph

203 Commits

Author SHA1 Message Date
Lee Salzman
a8f9704405 Bug 1904048 - Add prototype for ImageBitmap's BindingJSObjectMallocBytes. r=aosmond
It looks like there was never a prototype for ImageBitmap's BindingJSObjectMallocBytes function.
Even though it was defined and expected to associate ImageBitmap's internally allocated surface
memory for the GC to track, the bindings generator never actually tried to call it because the
lack of the prototype caused the default non-specialized version of this function to be called
instead. With the protoype in place, this actually gets called and the GC is able to properly
clean out ImageBitmap's in a more timely fashion.

Differential Revision: https://phabricator.services.mozilla.com/D216250
2024-07-13 02:12:55 +00:00
Eden Chuang
7d1673e962 Bug 1894231 - P8 Remove ImageBit::SendShutdownToWorkerThread::mWorkerPrivate. r=dom-worker-reviewers,asuth
Instead of holding SendShutdownToWorkerThread::mWorkerPrivate, hold WorkerPrivate::mControlEventTarget for SendShutdownToWorkerThread dispatching.

Depends on D213943

Differential Revision: https://phabricator.services.mozilla.com/D213944
2024-06-24 22:20:53 +00:00
Eden Chuang
feb314e721 Bug 1894231 - P3 Remove WorkerPrivate* in WorkerMainThreadRunnable. r=dom-worker-reviewers,extension-reviewers,smaug,rpl
Remove mWorkerPrivate from WorkerMainThreadRunnable. Instead, using a ThreadSafeWorkerRef to keep Worker alive until the created syncLoop is destroyed.

In general, WorkerMainThreadRunnable::mWorkerPrivate is only used for dispatching the MainThreadStopSyncLoopRunnable back to the Worker thread. Because of the syncLoop, the Worker is supposed to be kept alive until the created syncLoop is destroyed.

RefPtr<ThreadSafeWorkerRef> WorkerMainThreadRunnable::mWorkerRef is introduced to ensure a valid WorkerPrivate during WorkerMainThreadRunnable's execution.

WorkerMainThreadRunnable::mWorkerRef is allocated just before creating a syncLoop in WorkerMainThreadRunnable::Dispatch. And released after the created syncLoop::Run() finishes.

Depends on D212556

Differential Revision: https://phabricator.services.mozilla.com/D212557
2024-06-24 22:20:51 +00:00
Lee Salzman
e4a8b84667 Bug 1897745 - Check for null surface in ScaleDataSourceSurface. r=aosmond
Every use of ScaleDataSourceSurface checks for a null result and just spits out
a warning. So here it seems reasonable to check the input is valid, and if not,
just spit out that null result. This should give us more consistent behavior
between debug and opt builds.

Differential Revision: https://phabricator.services.mozilla.com/D212501
2024-06-04 02:41:30 +00:00
Eden Chuang
a718e4758f Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth
WorkerRunnable no longer keeps a raw pointer(mWorkerPrivate) for the associated WorkerPrivate in this patch.
Removing the WorkerRunnable::mWorkerPrivate needs to fix the following problems.

1. Thread assertions in WorkerRunnable::Dispatch()

To fix this problem, the associated WorkerPrivate is as a parameter and passed to WorkerRunnable::Dispatch() for the dispatching thread assertions. This associated WorkerPrivate is also propagated to PreDispatch() and PostDispatch() for the children classes of WorkerRunnable()

2. Get the associated WorkerPrivate in WorkerRunnable::Run() for environment setup(GlobabObject, JSContext setting for the runnable)

- For WorkerThreadRunnable

Since WorkerThreadRunnable is supposed to run on the worker thread, it does not need to keep a raw pointer to WorkerPrivate as its class member. GetCurrentThreadWorkerPrivate() should always get the correct WorkerPrivate for WorkerThreadRunnable.

- For WorkerParentThreadRunnable

WorkerParentRef is introduced to keep a RefPtr<WorkerPrivate> for WorkerParentThreadRunnable instead of using a raw pointer.
Checking the associated WorkerPrivate existence by WorkerParentRef at the beginning of WorkerParentThreadRunnable::Run(). If the Worker has already shut down, WorkerParentThreadRunnable cannot do anything with the associated WorkerPrivate, so WorkerParentThreadRunnable::Run() will return NS_OK directly but with a warning.

The associated WorkerPrivate is also passed into WorkerRun(), PreRun(), and PostRun(), so the majority of implementations of child classes of WorkerRunnable do not need to be changed.

If there are any cases in which the child classes of WorkerThreadRunnable/WorkerParentThreadRunnable want to keep the associated WorkerPrivate, they should use WorkerRefs instead of raw pointers.

Depends on D205679

Differential Revision: https://phabricator.services.mozilla.com/D207039
2024-04-19 09:41:58 +00:00
Eden Chuang
f9b64790d7 Bug 1769913 - P1 Make WorkerRunnable to be a base class for runnables on Worker thread and Worker's parent thread. r=dom-worker-reviewers,asuth
This is the first step in splitting the parent thread runnable out of WorkerRunnable.

To reuse the runnable dispatching codes in Worker, we still need a base class for runnable on the worker thread and the parent thread.

In this patch, we rename the original WorkerRunnable to WorkerThreadRunnable and make WorkerRunnable to be WorkerThreadRunnable's parent class.

In the second patch, we will create WorkerParentThreadRunnable and its sub-classes, split from WorkerThreadRunnable for runnable on the Worker's parent thread.

And in the third patch, we will re-structure the content of WorkerParentThreadRunnable to remove unnecessary members.

Differential Revision: https://phabricator.services.mozilla.com/D205178
2024-04-19 09:41:57 +00:00
Emilio Cobos Álvarez
5b62de6483 Bug 1883435 - Don't include GleanMetrics.h from Document.h. r=chutten,necko-reviewers,valentin
In bug 1883435 comment 2 chutten mentions that including
nsGlobalWindowInner.h from GleanMetrics.h causes a stylo build failure.

This is because nsGlobalWindowInner.h itself brings a bunch of DOM
bindings template soup that bindgen isn't great at dealing with.

That can be fixed in various ways. However, there is a simpler fix,
which is not including GleanMetrics at all.

It's trivial to do, and given it's a massive autogenerated file, and
Document.h is a very common header, it's worth doing this if only for
build times.

Fix a bunch of unused includes while at it.

Differential Revision: https://phabricator.services.mozilla.com/D203625
2024-03-05 17:54:14 +00:00
Lee Salzman
c679101cea Bug 1879651 - Ensure CreateImageBitmapInternal copies DataSourceSurface before modifying it. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D202554
2024-02-23 16:09:21 +00:00
Kagami Sascha Rosylight
62ba6fa295 Bug 1876536 - Part 2: Remove self refcounts within constructor in ImageBitmap r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D199978
2024-02-01 11:03:59 +00:00
Stanca Serban
08b5a4c8d7 Backed out 4 changesets (bug 1842871, bug 1876536) for Constructor related sm bustages. CLOSED TREE
Backed out changeset 2a8075f926e8 (bug 1842871)
Backed out changeset 133df2717c5b (bug 1876536)
Backed out changeset 8ec499a5a57b (bug 1876536)
Backed out changeset 1568bfa2cc45 (bug 1876536)
2024-02-01 11:41:49 +02:00
Kagami Sascha Rosylight
196e5171d4 Bug 1876536 - Part 2: Remove self refcounts within constructor in ImageBitmap r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D199978
2024-02-01 09:01:17 +00:00
Jens Stutte
aa54dcc26f Bug 1875800 - Add name support to WorkerRunnable. r=dom-worker-reviewers,asuth,smaug
Differential Revision: https://phabricator.services.mozilla.com/D199228
2024-01-24 16:00:26 +00:00
Cristian Tuns
5de093dcd2 Backed out changeset f3efca74da0f (bug 1875800) for causing build bustages in WorkerPrivate.cpp CLOSED TREE 2024-01-23 11:20:38 -05:00
Jens Stutte
926a1907f0 Bug 1875800 - Add name support to WorkerRunnable. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D199228
2024-01-23 11:23:41 +00:00
Eden Chuang
a8f31306c0 Bug 1799173 - Override Predispatch/PostDispatch of CreateImageBitmapFromBlobRunnable to mute the noise of WorkerRunnable dispatching assertion. r=dom-worker-reviewers,asuth
CreateImageBigmapFromBlob is a behavior across the owning thread and the main thread. It starts from the owning thread, completes the IO on the main thread, and returns to the owning thread in the end.

However, when CreateImageBitmapFromBlob is in a nested worker, it uses CreateImageBitmapFromBlobRunnable to return to the owning thread. And It hits the assertion of WorkerRunnable::PreDispatch(), which supposes the runnable should be dispatched from its parent thread.

According to the design of CreateImageBigmapFromBlob, it should not be restricted by the assertion of WorkerRunnable::PreDispatch(), and it should always be dispatched back to the owning thread. Therefore, This patch overrides PreDispatch() and PostDispatch() of CreateImageBitmapFromBlobRunnable so that it can work correctly.

Differential Revision: https://phabricator.services.mozilla.com/D193553
2023-11-21 13:04:42 +00:00
Emilio Cobos Álvarez
d02e297b2d Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Peter Van der Beken
e664ec3758 Bug 1690111 - Use new TypedArray APIs for processing data. r=farre,media-playback-reviewers,padenot,chunmin,sfink
Depends on D152497

Differential Revision: https://phabricator.services.mozilla.com/D152498
2023-09-20 09:42:02 +00:00
Andrew Osmond
78e5ad3804 Bug 1852420 - Ensure surface and crop rect used in ImageBitmap are valid. r=gfx-reviewers,lsalzman
When ImageBitmap::PrepareForDrawTarget is called, we must ensure
that the surface returned is acceptable to the given DrawTarget. If
it is not, then we need to recreate the surface from mData. We must
also ensure similar when we are creating a new ImageBitmap from
another ImageBitmap, as we don't know in what context it may be
used.

Similarly, we need to ensure we produce DataSourceSurface compatible
surfaces when we need to both crop and premultiply.

Additionally, we now no longer clear mPictureRect or mAlphaType
when we set mSurface with the cached, cropped data. Since we may
need to clear the cached surface, we need to know the original crop
rect and alpha.

Differential Revision: https://phabricator.services.mozilla.com/D188056
2023-09-13 12:05:25 +00:00
Cosmin Sabou
c3effd7450 Backed out 13 changesets (bug 1690111) for causing fetch related crashes.
Backed out changeset 5f2c25d194ad (bug 1690111)
Backed out changeset 76c408bcd053 (bug 1690111)
Backed out changeset 6d0649fdafff (bug 1690111)
Backed out changeset c1330b5e8c43 (bug 1690111)
Backed out changeset 5fa36d8fd2a5 (bug 1690111)
Backed out changeset daf7d747853a (bug 1690111)
Backed out changeset f70e09a7f5c6 (bug 1690111)
Backed out changeset 40c6d6eed7f8 (bug 1690111)
Backed out changeset 692f2a759573 (bug 1690111)
Backed out changeset 7140866dd9f6 (bug 1690111)
Backed out changeset 2865fe682139 (bug 1690111)
Backed out changeset 9dcd2416f8a5 (bug 1690111)
Backed out changeset 9c411bf84079 (bug 1690111)
2023-09-11 17:55:24 +03:00
Peter Van der Beken
312137a408 Bug 1690111 - Use new TypedArray APIs for processing data. r=farre,media-playback-reviewers,padenot,chunmin,sfink
Depends on D152497

Differential Revision: https://phabricator.services.mozilla.com/D152498
2023-09-11 12:52:20 +00:00
Timothy Nikkel
cadda1a9e1 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
2023-08-25 19:10:10 +00:00
Andrew Osmond
d392139494 Bug 1645555 - Ensure we return surfaces with the proper size with canvas and ImageBitmap. r=gfx-reviewers,lsalzman
In general the canvas size and the surface size should match. However if
we are in the process of updating an OffscreenCanvas's size, it is
possible we may return a surface with a different size if an ImageBitmap
is created, or we draw using, the placeholder HTMLCanvasElement. In that
case we should ensure the surface we yield is the same size as the
current intrinsic size of the HTMLCanvasElement.

Differential Revision: https://phabricator.services.mozilla.com/D186376
2023-08-16 21:01:34 +00:00
Timothy Nikkel
5370f6b212 Bug 1845372. Don't create a (useless) shutdown observer for ImageBitmaps if we've already passed the main shutdown notification phase. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D184905
2023-08-01 01:31:31 +00:00
Timothy Nikkel
c5a1a7de1d Bug 1839286. Use one shutdown observer for all ImageBitmaps. r=gfx-reviewers,lsalzman
Use on shutdown observer and manager a hashtable of all imagebitmaps. Observers are managed using an array, which is slow for large numbers of observers.

Differential Revision: https://phabricator.services.mozilla.com/D181432
2023-07-19 06:15:22 +00:00
Andrew Osmond
db122dc77c Bug 1781527 - Part 3. Implement support for surfaces requiring scaling/crop rects with canvas. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D182208
2023-07-10 00:26:47 +00:00
Andrew Osmond
37e046356a Bug 1781527 - Part 2. Implement means to use VideoFrame with ImageBitmap and CanvasRenderingContext2D. r=chunmin,webidl,gfx-reviewers,smaug,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D150679
2023-07-10 00:26:47 +00:00
Cristian Tuns
282c7e78f0 Backed out 4 changesets (bug 1781527) for causing Assertion failures in ImageBitmap.cpp CLOSED TREE
Backed out changeset d3ca9e70625b (bug 1781527)
Backed out changeset f6c56b5e6450 (bug 1781527)
Backed out changeset 34d140bc5b99 (bug 1781527)
Backed out changeset f7a2f2b89ba8 (bug 1781527)
2023-07-09 18:53:20 -04:00
Andrew Osmond
cb8dd55424 Bug 1781527 - Part 3. Implement support for surfaces requiring scaling/crop rects with canvas. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D182208
2023-07-09 21:03:46 +00:00
Andrew Osmond
d82cdd3fd1 Bug 1781527 - Part 2. Implement means to use VideoFrame with ImageBitmap and CanvasRenderingContext2D. r=chunmin,webidl,gfx-reviewers,smaug,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D150679
2023-07-09 21:03:46 +00:00
Noemi Erli
8d7b099c74 Backed out changeset ec7fc33e6ad4 (bug 1839286) for causing multiple failures 2023-06-20 13:10:09 +03:00
Timothy Nikkel
6cb94d2a3a Bug 1839286. Use one shutdown observer for all ImageBitmaps. r=gfx-reviewers,lsalzman
Use on shutdown observer and manager a hashtable of all imagebitmaps. Observers are managed using an array, which is slow for large numbers of observers.

Differential Revision: https://phabricator.services.mozilla.com/D181432
2023-06-20 08:35:18 +00:00
Angus Sawyer
8ea6dd2230 Bug 1785635 Add flag to enforce from-image orientation for createImageBitmap r=emilio
New flag added to nsLayoutUtils to ensure any exif specified orientation
is applied to surfaces obtained from HTMLImage elements irrespective of the
presence of the element in the DOM. For use in createImageBitmap where from-image is
the required behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D168356
2023-01-31 16:04:17 +00:00
Chun-Min Chang
5bd99e209b Bug 1776796 - Rename MarkAsContentSource r=media-playback-reviewers,alwu
`HTMLMediaElement::MarkAsContentSource` [1] was added in Bug 1299718 to
monitor the visibility / invisibility of various usage of video element.
However, that telemetry had been removed in Bug 1356046.
`MarkAsContentSource` is only used for logging currently. It's better to
reword its name and related comments to bring the code in line with the
current status.

[1] https://searchfox.org/mozilla-central/rev/5b2d2863bd315f232a3f769f76e0eb16cdca7cb0/dom/html/HTMLMediaElement.h#799

Differential Revision: https://phabricator.services.mozilla.com/D150434
2022-07-27 00:20:45 +00:00
Andrew Osmond
a17dd28491 Bug 1777411 - Improve error messages when cloning ImageBitmap. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D150697
2022-06-30 13:36:34 +00:00
Timothy Nikkel
8dc6be8c00 Bug 1768593. Allow createImageBitmap to work on img elements whose src is an svg with no specified size of resizeWidth/Height is specified. r=lsalzman
Just need to pass the resizeWidth/Height down into SurfaceFromElement for html image elements so we can ask for a frame of the right size from the image.

We have to annotate the new test that I add as failing, just like all of the existing tests, because we don't yet support the resizeQuality option, so we fail that part of the test and pass all of the rest of it. The part that we are fixing here passes.

Differential Revision: https://phabricator.services.mozilla.com/D147739
2022-06-02 03:31:43 +00:00
Angus Sawyer
4c68b4a042 Bug 1756803 scaling/premultiply alpha of ImageData r=aosmond
Two issues:

The result of scaling & premultiply is order critical, the previous order for ImageData was scale > premultiply, the other image sources were premultiplied by default so didn't expose this issue. Reorder in the ImageData and common code paths (the original order followed the w3c spec order of operations - maybe the spec needs amending).

The ImageData path did not set the premultiplied flag of the resulting ImageBitmap correctly so the image would be premultiplied again in PrepareForDrawTarget.

Differential Revision: https://phabricator.services.mozilla.com/D139700
2022-03-18 16:47:26 +00:00
Randell Jesup
855202c183 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 18:47:08 +00:00
Noemi Erli
16f5f5f2b9 Backed out changeset 12a59e5a50bf (bug 1207753) for causing build bustage CLOSED TREE 2022-03-16 18:32:51 +02:00
Randell Jesup
a98b1f8218 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 16:16:14 +00:00
Butkovits Atila
01197944a0 Backed out changeset a68ee4b09f92 (bug 1207753) for causing Hazard bustages. CLOSED TREE 2022-03-16 14:38:14 +02:00
Randell Jesup
fe15f2115d Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 12:01:14 +00:00
Andrew Osmond
53d15de5c7 Bug 1755792 - Handle surface unavailable cases in ImageBitmap. r=gfx-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D139369
2022-02-22 14:36:30 +00:00
Angus Sawyer
8c124e4008 Bug 1733559 - createImageBitmap() resizeWidth and resizeHeight support, r=aosmond,emilio
Also fixed negative cropping width/height for blob images.
Removes two unused class variables.

Differential Revision: https://phabricator.services.mozilla.com/D127250
2022-01-20 15:38:01 +00:00
Angus Sawyer
c1ec1dd8c0 Bug 1748868 - support createImageBitmap colorSpaceConversion option, r=aosmond,emilio
Differential Revision: https://phabricator.services.mozilla.com/D135888
2022-01-15 15:14:32 +00:00
Andrew Osmond
26a21a9723 Bug 1746093 - Allow OffscreenCanvas as an input for CanvasImageSource and ImageBitmapSource. r=lsalzman,emilio
As per the spec, we should allow one to create ImageBitmaps, and call
CanvasRenderingContext2D's drawImage and createPattern using an
OffscreenCanvas.

Differential Revision: https://phabricator.services.mozilla.com/D133808
2021-12-15 21:36:21 +00:00
aardgoose
13c1674214 Bug 1687658 - Recursive createImageBitmap ignores source cropping r=aosmond
Note: if the original imageBitmap has been use for display, the source surface will have been cropped and
the original cropping IntRect has been lost, in this case use cropped mSurface instead of mdata.

If some of the new clip rect falls outside the source we have to crop the source if it hasn't been cropped.

Q: Should I attempt to get tests for this added to WPT?

Differential Revision: https://phabricator.services.mozilla.com/D124607
2021-12-08 03:47:56 +00:00
Lee Salzman
5c54ad5bb8 Bug 1743851 - Ensure cropped ImageBitmap preserves surface format. r=gfx-reviewers,bradwerth
When an ImageBitmap needed to be cropped to prepare itself for a DT, it would
accidentally convert to the DT's format, which could cause issues if the DT
was opaque while the source surface was an alpha format.

Differential Revision: https://phabricator.services.mozilla.com/D132912
2021-12-06 18:05:07 +00:00
Lee Salzman
a4a8855aa9 Bug 1739454 - Don't overwrite the ImageBitmap's surface in PrepareForDrawTarget. r=emilio
ImageBitmap::PrepareForDrawTarget overwrites its surface's contents when premultiplying the
data. This code pattern seems to stem all the way back to bug 1239752. It doesn't seem like
we have much control over where this surface comes from, and we have no strong guarantees
that this surface isn't shared by multiple consumers. As such, overwriting the data could
result in another consumer getting premultiplied data in the surface that it didn't expect.
We should just always be cloning the surface first before premultiplying unless we can
otherwise prove the surface isn't shared.

* * *
Bug 1739454 - Remove reftest-wait in reftest. r?emilio

Differential Revision: https://phabricator.services.mozilla.com/D131583
2021-11-19 18:46:46 +00:00
Alexandru Michis
730827aad0 Backed out 3 changesets (bug 1739454) for causing crashtest failures in 1739454-1.html
CLOSED TREE

Backed out changeset 3accfa522abb (bug 1739454)
Backed out changeset 18fdb7a13e63 (bug 1739454)
Backed out changeset 1de7d723923a (bug 1739454)
2021-11-19 19:33:53 +02:00
Lee Salzman
fdda4b08e5 Bug 1739454 - Don't overwrite the ImageBitmap's surface in PrepareForDrawTarget. r=emilio
ImageBitmap::PrepareForDrawTarget overwrites its surface's contents when premultiplying the
data. This code pattern seems to stem all the way back to bug 1239752. It doesn't seem like
we have much control over where this surface comes from, and we have no strong guarantees
that this surface isn't shared by multiple consumers. As such, overwriting the data could
result in another consumer getting premultiplied data in the surface that it didn't expect.
We should just always be cloning the surface first before premultiplying unless we can
otherwise prove the surface isn't shared.

Differential Revision: https://phabricator.services.mozilla.com/D131583
2021-11-19 16:22:09 +00:00