Commit Graph
160 Commits
Author SHA1 Message Date
Ashley Zebrowski a843c313da Bug 1800882 - Implement HTMLVideoElement.requestVideoFrameCallback. r=webidl,media-playback-reviewers,emilio,ErichDonGubler,padenot
See https://wicg.github.io/video-rvfc/ for standard details.

Differential Revision: https://phabricator.services.mozilla.com/D216159
2024-08-01 20:12:22 +00:00
Sandor Molnar 42c4952868 Backed out 3 changesets (bug 1800882) for causing webcodecs failures . CLOSED TREE
Backed out changeset fd02fd0205ab (bug 1800882)
Backed out changeset fa46622c4ec7 (bug 1800882)
Backed out changeset 3ac74b4d6534 (bug 1800882)
2024-07-31 20:45:09 +03:00
Ashley Zebrowski 05a02c5a88 Bug 1800882 - Implement HTMLVideoElement.requestVideoFrameCallback. r=webidl,media-playback-reviewers,emilio,ErichDonGubler,padenot
See https://wicg.github.io/video-rvfc/ for standard details.

Differential Revision: https://phabricator.services.mozilla.com/D216159
2024-07-31 16:53:55 +00:00
Butkovits Atila e422067dc8 Backed out 3 changesets (bug 1800882) for causing webgpu failures. CLOSED TREE
Backed out changeset 8acda0361e97 (bug 1800882)
Backed out changeset 1e76fd470d00 (bug 1800882)
Backed out changeset 548a1763e689 (bug 1800882)
2024-07-26 01:14:08 +03:00
Ashley Zebrowski c781cc475c Bug 1800882 - Implement HTMLVideoElement.requestVideoFrameCallback. r=webidl,media-playback-reviewers,emilio,ErichDonGubler,padenot
See https://wicg.github.io/video-rvfc/ for standard details.

Differential Revision: https://phabricator.services.mozilla.com/D216159
2024-07-25 17:08:38 +00:00
Tamas Szentpeteri c944152723 Backed out changeset e2de2a86795f (bug 1800882) 2024-07-25 00:05:30 +03:00
Ashley Zebrowski 189b0b8e40 Bug 1800882 - Implement HTMLVideoElement.requestVideoFrameCallback. r=webidl,media-playback-reviewers,emilio,ErichDonGubler,padenot
See https://wicg.github.io/video-rvfc/ for standard details.

Differential Revision: https://phabricator.services.mozilla.com/D216159
2024-07-24 18:30:35 +00:00
Karl Tomlinson ccc6e99c22 Bug 1840313 return full TaskQueue class from CreateBackgroundTaskQueue() r=xpcom-reviewers,nika
This makes TaskQueue methods such as BeginShutdown() and IsEmpty() available
to clients.

Only the interface class nsISerialEventTarget was previously returned over
concerns [1] that returning a TaskQueue might imply that clients would need to
explicitly shut down the TaskQueue, but this was not correct.  TaskQueues do
not require explicit shutdown [2].

Limited lifetime queues have been an option for clients since
BackgroundEventTarget's ownership of these queues until shutdown was
removed [3].

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1584568#c5
[2] https://searchfox.org/mozilla-central/rev/05d1afda588e54be73e31ef4e022dde91f1ed97a/xpcom/threads/TaskQueue.h#49
[3] https://hg.mozilla.org/integration/autoland/rev/77022ce2c24b#l3.37

Differential Revision: https://phabricator.services.mozilla.com/D181966
2023-06-26 21:52:50 +00:00
Marco Bonardo 53aa8a18e6 Bug 1666303 - Remove NS_SetCurrentThreadName Android workaround. r=xpcom-reviewers,nika
The workaround is no longer necessary because NSPR has been fixed.
This allows to use PR_GetThreadName that otherwise returns an empty string.

Differential Revision: https://phabricator.services.mozilla.com/D181861
2023-06-23 16:08:21 +00:00
Nika Layzell 085ce48510 Bug 1825360 - Remove the NS_DISPATCH_SYNC flag, r=necko-reviewers,geckoview-reviewers,media-playback-reviewers,karlt,jesup,m_kato,emilio
This flag is not supported by most event targets and can have unexpected
side effects (namely spinning a nested event loop). All consumers have
been replaced with a new function which is more explicit about this side
effect.

Differential Revision: https://phabricator.services.mozilla.com/D173985
2023-03-30 16:53:51 +00:00
Nika Layzell 3652956b7b Bug 1809753 - Part 4: Remove unnecessary GetMainThreadEventTarget, r=mccr8
This method always returned GetMainThreadSerialEventTarget(). This patch
switches all callers over to use that method instead.

We can't easily switch all calls to be calls to NS_GetMainThread(), as there is
no version of that method returning a bare nsIThread* instance.

I didn't introduce one, as we may want to add a lock around mMainThread in the
future, which would require removing nsThreadManager::GetMainThreadWeak. As
this method only returns nsISerialEventTarget, it method could remain
implemented, however, by returning a statically allocated fake event target
which forwards dispatches (and QIs to nsIThread) to the real main thread.

Differential Revision: https://phabricator.services.mozilla.com/D166608
2023-01-16 23:14:12 +00:00
Nika Layzell ccbdb42273 Bug 1809753 - Part 3: Replace all callers of GetCurrentEventTarget with GetCurrentSerialEventTarget, r=mccr8,necko-reviewers,valentin
This only changes the behaviour when called with a TaskQueue or other type
using SerialEventTargetGuard on the stack. They are being switched over as the
existing GetCurrentEventTarget method is being removed, as it is somewhat
confusing, and poorly documented.

Callers which need to get the current thread even when on a threadpool or
behind a TaskQueue were switched to GetCurrentEventTarget in the previous part.

Differential Revision: https://phabricator.services.mozilla.com/D166607
2023-01-16 23:14:11 +00:00
Nika Layzell 309d61988a Bug 1809753 - Part 2: Switch some calls to GetCurrentEventTarget() to NS_GetCurrentThread, r=mccr8
These callers are depending on the existing behaviour which always returns a
thread, and does not respect custom TaskQueues. In the next part, all remaining
callers will be switched to GetCurrentSerialEventTarget.

Differential Revision: https://phabricator.services.mozilla.com/D166606
2023-01-16 23:14:11 +00:00
Nika Layzell 801c40814f Bug 1809753 - Part 1: Remove quantum-dom nsIThread::EventTarget methods, r=mccr8
We aren't likely to try to make these changes any time soon, so cleaning out
these unnecessary methods which just return `this` will simplify things.

I was unable to find any calls to the `.eventTarget` getter in JS, which makes
sense, as the nsIThread type is only really used in JS as a wrapper around the
main thread in older code. Because of that, it has been removed as well.

Differential Revision: https://phabricator.services.mozilla.com/D166605
2023-01-16 23:14:10 +00:00
Nika Layzell dea6384800 Bug 1809752 - Part 2: Assert if GetCurrentSerialEventTarget is called on a thread pool with no active TaskQueue, r=mccr8
This will help catch issues such as the one from bug 1806751, as we will assert
earlier in the process. This also aligns better with the existing documentation
of the method (which has been updated), which suggests that the method would
assert if called on a thread pool.

Differential Revision: https://phabricator.services.mozilla.com/D166604
2023-01-16 23:14:10 +00:00
Sandor Molnar f236c54e45 Backed out 6 changesets (bug 1809752, bug 1809753) for causing perma failures in browser/components/firefoxview/tests/browser/browser_feature_callout_position.js
Backed out changeset ea05784d74c4 (bug 1809753)
Backed out changeset 7c9b20eebcc8 (bug 1809753)
Backed out changeset d0267ac2256d (bug 1809753)
Backed out changeset aa9f2971bd6f (bug 1809753)
Backed out changeset f0d9fcfaa6f8 (bug 1809752)
Backed out changeset 6d58c799cffe (bug 1809752)
2023-01-17 03:19:24 +02:00
Nika Layzell d61ced88a2 Bug 1809753 - Part 4: Remove unnecessary GetMainThreadEventTarget, r=mccr8
This method always returned GetMainThreadSerialEventTarget(). This patch
switches all callers over to use that method instead.

We can't easily switch all calls to be calls to NS_GetMainThread(), as there is
no version of that method returning a bare nsIThread* instance.

I didn't introduce one, as we may want to add a lock around mMainThread in the
future, which would require removing nsThreadManager::GetMainThreadWeak. As
this method only returns nsISerialEventTarget, it method could remain
implemented, however, by returning a statically allocated fake event target
which forwards dispatches (and QIs to nsIThread) to the real main thread.

Differential Revision: https://phabricator.services.mozilla.com/D166608
2023-01-16 23:14:12 +00:00
Nika Layzell 21081c63fa Bug 1809753 - Part 3: Replace all callers of GetCurrentEventTarget with GetCurrentSerialEventTarget, r=mccr8,necko-reviewers,valentin
This only changes the behaviour when called with a TaskQueue or other type
using SerialEventTargetGuard on the stack. They are being switched over as the
existing GetCurrentEventTarget method is being removed, as it is somewhat
confusing, and poorly documented.

Callers which need to get the current thread even when on a threadpool or
behind a TaskQueue were switched to GetCurrentEventTarget in the previous part.

Differential Revision: https://phabricator.services.mozilla.com/D166607
2023-01-16 23:14:11 +00:00
Nika Layzell 54fc2ba71e Bug 1809753 - Part 2: Switch some calls to GetCurrentEventTarget() to NS_GetCurrentThread, r=mccr8
These callers are depending on the existing behaviour which always returns a
thread, and does not respect custom TaskQueues. In the next part, all remaining
callers will be switched to GetCurrentSerialEventTarget.

Differential Revision: https://phabricator.services.mozilla.com/D166606
2023-01-16 23:14:11 +00:00
Nika Layzell 754d395675 Bug 1809753 - Part 1: Remove quantum-dom nsIThread::EventTarget methods, r=mccr8
We aren't likely to try to make these changes any time soon, so cleaning out
these unnecessary methods which just return `this` will simplify things.

I was unable to find any calls to the `.eventTarget` getter in JS, which makes
sense, as the nsIThread type is only really used in JS as a wrapper around the
main thread in older code. Because of that, it has been removed as well.

Differential Revision: https://phabricator.services.mozilla.com/D166605
2023-01-16 23:14:10 +00:00
Nika Layzell 4061d5b0a9 Bug 1809752 - Part 2: Assert if GetCurrentSerialEventTarget is called on a thread pool with no active TaskQueue, r=mccr8
This will help catch issues such as the one from bug 1806751, as we will assert
earlier in the process. This also aligns better with the existing documentation
of the method (which has been updated), which suggests that the method would
assert if called on a thread pool.

Differential Revision: https://phabricator.services.mozilla.com/D166604
2023-01-16 23:14:10 +00:00
Nika Layzell 19ad083277 Bug 1809749 - Use the correct thread for timed out idle runnables from off-main-thread, r=smaug,mccr8
This code was previously incorrectly targeting the timer at the dispatching
thread. This is fortunately not an issue, as idle runnables with timeouts are
always dispatched from the main thread, however it could be an issue for future
idle runnables with timeouts dispatched from off-main-thread.

Differential Revision: https://phabricator.services.mozilla.com/D166610
2023-01-12 15:24:13 +00:00
Sandor Molnar b6679eb354 Backed out changeset 577c7f0d1780 (bug 1809749) for causing assertion failures in xpcom/threads/nsThreadUtils.cpp CLOSED TREE 2023-01-12 03:52:06 +02:00
Nika Layzell 338355a302 Bug 1809749 - Use the correct thread for timed out idle runnables from off-main-thread, r=smaug,mccr8
This code was previously incorrectly targeting the timer at the dispatching
thread. This is fortunately not an issue, as idle runnables with timeouts are
always dispatched from the main thread, however it could be an issue for future
idle runnables with timeouts dispatched from off-main-thread.

Differential Revision: https://phabricator.services.mozilla.com/D166610
2023-01-12 01:06:18 +00:00
Nika Layzell 119713a821 Bug 1799222 - Part 1: Prevent accidental dispatches to threadpool and timer threads, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,jesup,m_kato,padenot,kmag
Differential Revision: https://phabricator.services.mozilla.com/D161349
2022-12-16 17:09:16 +00:00
Cristian Tuns de12c42c7f Backed out changeset 42315c023471 (bug 1799222) for causing multiple failures CLOSED TREE 2022-12-06 16:35:58 -05:00
Nika Layzell e8f474cee1 Bug 1799222 - Prevent accidental dispatches to threadpool and timer threads, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,jesup,m_kato,padenot,kmag
Differential Revision: https://phabricator.services.mozilla.com/D161349
2022-12-06 20:44:15 +00:00
Olli Pettay 9382df276d Bug 1800347, make it possible to set the priority of the Runnables used by MozPromise, r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D161954
2022-11-16 09:23:28 +00:00
Nika Layzell f4c7085466 Bug 1738103 - Part 1: Remove the unused TailDispatchingTarget type, r=xpcom-reviewers,KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D129837
2022-03-23 22:22:02 +00:00
Gabriele Svelto a57add78e9 Bug 1756505 - Remove the ThreadIdNameMapping annotation and all the associated machinery r=Gankra
This has several implications:
* A race-condition that could manifest itself both on macOS and Linux is
  removed. The race could happen if we took the lock to the thread name
  mapping while another suspended thread was in the memory allocator. Taking
  the lock required an allocation thus the thread acting within the exception
  handler would get stuck.
* We save a few KiBs of memory per process since we don't have to keep the
  thread name mapping around.
* Thread startup will be slightly faster since the first thing each new thread
  did was to fill its own mapping.

Differential Revision: https://phabricator.services.mozilla.com/D139319
2022-03-15 09:23:38 +00:00
Nika Layzell 06626bac7e Bug 1739727 - Part 2: Improve rust async support in moz_task, r=emilio
This patch contains changes to moz_task to improve it's support for
async execution on multiple threads. Unlike the previous executor
implementation, this new implementation reduces the amount of unsafe
code substantially by depending on the async-task crate
(https://crates.io/crates/async-task) for the core task implementation.
This adds a few additional features:

 * Both local (no Send bound) and non-local (with Send bound) execution support,
 * Support for spawning on arbitrary nsIEventTargets or the background task pool,
 * Returned Task objects from runnables which may be .await-ed on or detach()-ed,
 * Support for spawning with the NS_DISPATCH_EVENT_MAY_BLOCK flag set,
 * Automatic use of NS_DISPATCH_AT_END when required,
 * Support for specifying the runnable priority for runnables.

There are also some correctness improvements, and exposed a better API
for dispatching normal runnable functions to background threads.

After these changes the TaskRunnable API should no longer be necessary.
It is re-implemented on top of the executor and kept in-place to avoid
rewriting all consumers.

Differential Revision: https://phabricator.services.mozilla.com/D130705
2021-12-07 20:01:41 +00:00
Jens Stutte 26f8284daa Bug 1735129: Add thread-safe name getter to nsThread. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D128356
2021-10-21 11:51:08 +00:00
Olli Pettay ee4d895567 Bug 1734811 - consider to use higher priority for the imglib tasks r=tnikkel
Depends on D127935

Differential Revision: https://phabricator.services.mozilla.com/D127936
2021-10-08 19:29:37 +00:00
Mike Hommey 18ca062db2 Bug 1733308 - Fix non-unified builds errors in xpcom/threads. r=xpcom-reviewers,mccr8
xpcom/threads/CPUUsageWatcher.cpp:43:23: error: unused variable 'kCPUCheckInterval' [-Werror,-Wunused-const-variable]
xpcom/threads/CPUUsageWatcher.cpp:109:23: error: unused variable 'kCPUCheckInterval' [-Werror,-Wunused-const-variable]
xpcom/threads/InputEventStatistics.cpp:18:5: error: use of undeclared identifier 'ClearOnShutdown'
xpcom/threads/InputTaskManager.cpp:62:9: error: use of undeclared identifier 'InputEventStatistics'
xpcom/threads/InputTaskManager.cpp:89:3: error: use of undeclared identifier 'InputEventStatistics'
xpcom/threads/InputTaskManager.cpp:105:7: error: use of undeclared identifier 'nsRefreshDriver'
xpcom/threads/InputTaskManager.cpp:124:9: error: use of undeclared identifier 'InputEventStatistics'
xpcom/threads/MainThreadIdlePeriod.cpp:29:23: error: unused variable 'kMaxTimerThreadBoundClamp' [-Werror,-Wunused-const-variable]
xpcom/threads/VsyncTaskManager.h:15:67: error: implicit instantiation of undefined template 'mozilla::StaticRefPtr<mozilla::VsyncTaskManager>'
xpcom/threads/VsyncTaskManager.h:16:52: error: no viable overloaded '='
xpcom/threads/nsMemoryPressure.cpp:61:12: error: use of undeclared identifier 'nsIObserverService'
xpcom/threads/nsMemoryPressure.cpp:61:37: error: use of undeclared identifier 'services'
xpcom/threads/nsThreadManager.cpp:422:28: error: member access into incomplete type 'mozilla::ThreadEventTarget'
xpcom/threads/nsThreadManager.cpp:661:5: error: use of undeclared identifier 'CrashReporter'
xpcom/threads/nsThreadManager.cpp:662:59: error: expected ')'
xpcom/threads/nsThreadManager.cpp:662:9: error: use of undeclared identifier 'CrashReporter'
xpcom/threads/nsThreadManager.cpp:669:7: error: use of undeclared identifier 'CrashReporter'
xpcom/threads/nsThreadManager.cpp:670:11: error: use of undeclared identifier 'CrashReporter'
xpcom/threads/nsThreadManager.cpp:670:61: error: expected ')'
xpcom/threads/nsThreadManager.cpp:672:7: error: use of undeclared identifier 'CrashReporter'
xpcom/threads/nsThreadManager.cpp:673:11: error: use of undeclared identifier 'CrashReporter'
xpcom/threads/nsThreadUtils.cpp:636:13: error: member access into incomplete type 'mozilla::Task'

Differential Revision: https://phabricator.services.mozilla.com/D127041
2021-10-01 01:49:18 +00:00
Jeff Muizelaar 8367d41c8b Bug 1718154 - Remove unneeded MOZILLA_INTERNAL_API from nsThreadUtils.cpp. r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D118771
2021-06-25 03:06:35 +00:00
Dorel Luca fc1039e2a9 Backed out 2 changesets (bug 1707924) for multiple failures with crash [@ BackgroundEventTarget::CreateBackgroundTaskQueue(char const*)]. CLOSED TREE
Backed out changeset 7fda47840322 (bug 1707924)
Backed out changeset c6213e0b8024 (bug 1707924)
2021-04-30 06:20:24 +03:00
kriswright ab6b2f3637 Bug 1707924 - Disallow creation of new TaskQueues after we have begun threads shutdown r=xpcom-reviewers,nika
I discovered today an order of events that causes a hang:
- A background TaskQueue is created after we [begin threads shut down](https://searchfox.org/mozilla-central/rev/759872688df15a5d6ab305ffe39d90450590bfec/xpcom/build/XPCOMInit.cpp#625)
- The task queue enters shut down, and attempts to [cancel delayed runnables] (https://searchfox.org/mozilla-central/rev/37edd2782e67e716dd07a85016da07b4d6275e5d/xpcom/threads/TaskQueue.cpp#163)
- The task queue [dispatches a runnable](https://searchfox.org/mozilla-central/rev/37edd2782e67e716dd07a85016da07b4d6275e5d/xpcom/threads/TaskQueue.cpp#140) which clears its delayed runnables
- Because delayed runnables are canceled before we stop servicing new threads, most TaskQueue clear this step. But if you create one at this part of shutdown, you dispatch it to a threadpool that cannot create new threads, so if there are no active threads this dispatch will not be serviced.

We could just change how to dispatch delayed runnable cancel tasks, but I think the best solution is to outright forbid the creation of new background TaskQueues after we have begun shutdown. Since this problem is specific to the way background task queue shut down, I don't want to change the behavior of any unrelated task queue who dispatch delayed runnables and shut down in their own time.

Differential Revision: https://phabricator.services.mozilla.com/D113449
2021-04-30 00:58:47 +00:00
Andreas Pehrson b445a0aea4 Bug 1695580 - Break out DelayedRunnable into its own files. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D109778
2021-04-06 20:15:09 +00:00
Brindusan Cristian 13b2a5f0b2 Backed out 8 changesets (bug 1695580) for causing build bustages on DataMutex.h. CLOSED TREE
Backed out changeset ec0b0fcc8d88 (bug 1695580)
Backed out changeset 982a46056fcb (bug 1695580)
Backed out changeset e38e8b90f119 (bug 1695580)
Backed out changeset 6fdd154aa151 (bug 1695580)
Backed out changeset d04f7a7ec375 (bug 1695580)
Backed out changeset 2103cd9e58b7 (bug 1695580)
Backed out changeset de9a7dd7fc79 (bug 1695580)
Backed out changeset ae16f09be41b (bug 1695580)
2021-04-06 17:41:19 +03:00
Andreas Pehrson 9a7c9068c4 Bug 1695580 - Break out DelayedRunnable into its own files. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D109778
2021-04-06 12:16:10 +00:00
Karl Tomlinson cbc6045335 Bug 1119956 implement IdleRunnableWrapper::OnDiscard() r=sg
This causes no behavior changes in the current code because existing runnables
passed to NS_DispatchToThreadQueue() are either run on the main thread where
OnDiscard() is not called or they have only a no-op OnDiscard().

Differential Revision: https://phabricator.services.mozilla.com/D98120
2020-12-06 21:51:01 +00:00
Bas Schouten 8bbad0ec9b Bug 1680544 - Part 2: Specialize LogTaskBase<Task>::Run::Run. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D98645
2020-12-04 19:14:12 +00:00
Karl Tomlinson 6a3caeebda Bug 1119956 don't pretend to implement nsICancelableRunnable::Cancel() r=gsvelto,necko-reviewers,dragana
Differential Revision: https://phabricator.services.mozilla.com/D98119
2020-12-02 06:32:39 +00:00
Karl Tomlinson 54446d9be0 Bug 1119956 introduce DiscardableRunnable for tasks that might not run but might not implement cancellation r=asuth,sg
Classes that inherit from DiscardableRunnable are only promising that it is OK
for Run() to be skipped, rather than promising that Cancel() is effective.

Differential Revision: https://phabricator.services.mozilla.com/D98117
2020-12-02 09:36:25 +00:00
Simon Giesecke b27ec28576 Bug 1673424 - Fix includes around StructuredCloneData.h.
Differential Revision: https://phabricator.services.mozilla.com/D94763

Depends on D94762
2020-11-23 16:07:01 +00:00
Honza Bambas 661ab0a0b1 Bug 1657974 - MOZ_LOG schedule and run of FrameRequestCallback, r=froydnj
Depends on D86740

Differential Revision: https://phabricator.services.mozilla.com/D86741
2020-08-13 14:41:16 +00:00
Honza Bambas c7e4bb5178 Bug 1657960 - MOZ_LOG schedule and run of mStyleFlushObservers and mLayoutFlushObservers, r=froydnj
Depends on D86737

Differential Revision: https://phabricator.services.mozilla.com/D86738
2020-08-13 14:41:15 +00:00
Honza Bambas c78e8399a0 Bug 1651068 - Include Task from TaskController in MOZ_LOG=events, r=bas
Differential Revision: https://phabricator.services.mozilla.com/D83065
2020-07-14 16:17:18 +00:00
Jean-Yves Avenard 934acd24fc Bug 1649671 - Add DelayedDispatch support to AbstractThread (and TaskQueue). r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D81811
2020-07-02 00:08:54 +00:00
Honza Bambas d04898063e Bug 1648781 - MOZ_LOG of timer events dispatch and run, MOZ_LOG of idle-dispatch timeout, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D81467
2020-06-30 10:57:28 +00:00