188 Commits
Author SHA1 Message Date
Daniel Holbert c8723c0549 Bug 2044510: Pass already_AddRefed types by-value instead of by rvalue reference, in xpcom/. r=xpcom-reviewers,emilio
See https://bugzilla.mozilla.org/show_bug.cgi?id=2044510#c0 for more details.

Differential Revision: https://phabricator.services.mozilla.com/D304349
2026-06-05 21:06:31 +00:00
Daniel Holbert ac764635e4 Bug 2043772: Use MakeRefPtr to do allocation for various RefPtr variables in xpcom/threads/. r=xpcom-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D303524
2026-05-30 14:29:48 +00:00
Lars Eggert f98d2c9a95 Bug 2026686 - Extend nsAutoLowPriorityIO to Linux r=jrmuizel
Uses IOPRIO_CLASS_BE at priority 7 (lowest best-effort) via syscall,
throttling disk access without risking starvation. This matches the
semantics of macOS IOPOL_THROTTLE and Windows THREAD_MODE_BACKGROUND_BEGIN.

Not enabled on Android because the platform seccomp filter blocks
ioprio_get/ioprio_set on at least arm32 (Bug 2035650).

Differential Revision: https://phabricator.services.mozilla.com/D296708
2026-04-29 09:15:37 +00:00
Serban Stanca 410a52656d Revert "Bug 2026686 - Use nsAutoLowPriorityIO for startup cache writes r=mccr8,xpcom-reviewers" as requested by @ryanvm for causing Bug 2035650.
This reverts commit 44a37e6043.

This reverts commit a1469c214a.
2026-04-29 00:17:45 +00:00
Lars Eggert a1469c214a Bug 2026686 - Extend nsAutoLowPriorityIO to Linux/Android r=jrmuizel
Uses IOPRIO_CLASS_BE at priority 7 (lowest best-effort) via syscall,
throttling disk access without risking starvation. This matches the
semantics of macOS IOPOL_THROTTLE and Windows THREAD_MODE_BACKGROUND_BEGIN.

Differential Revision: https://phabricator.services.mozilla.com/D296708
2026-04-28 10:32:22 +00:00
Nika Layzell 5f0f9dd22a Bug 2020817 - Part 4: Annotate & clean up nsACString callers of BeginReading/Data, r=xpcom-reviewers,media-playback-reviewers,webrtc-reviewers,cookie-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,permissions-reviewers,toolkit-telemetry-reviewers-rotation,layout-reviewers,dom-worker-reviewers,gfx-reviewers,webgpu-reviewers,necko-reviewers,dom-core,smaug,handyman,emilio,pehrsons,kershaw,timhuang,edenchuang,padenot,bradwerth
This is a large number of largely mechanical changes. When possible, the code
was called to directly call `.get()` instead, performing the assertions
manually. In many places PromiseFlatCString() calls were added to dynamically
copy the strings into null terminated buffers if the string was not null
terminated.

Differential Revision: https://phabricator.services.mozilla.com/D286158
2026-03-25 08:23:04 +00:00
Sylvestre Ledru 6149f49299 Bug 2023419 - Remove Emacs/Vim modelines from xpcom/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287878
2026-03-16 17:22:07 +00:00
Valentin Gosu ce76031637 Bug 2009372 - Allow PrioritizableRunnable::Run to run on socket thread r=necko-reviewers,kershaw,xpcom-reviewers,nika
The PrioritizableRunnable asserted that it runs on the main thread.
In order to prioritize events on the socket thread we also allow these
runnables to be dispatched to the socket thread.

Differential Revision: https://phabricator.services.mozilla.com/D280953
2026-02-16 17:12:12 +00:00
Serban Stanca 6b07694ccf Revert "Bug 2009372 - Prioritize H3 TRR runnables too r=necko-reviewers,jesup" for causing leak failures.
This reverts commit 71907b4279.

This reverts commit 3b82fab078.

This reverts commit 5356061695.

This reverts commit b4bdee9bef.

This reverts commit 07a14723bc.

This reverts commit a95437aebb.

This reverts commit 53664bf0f3.

This reverts commit 0fd8e2d182.

This reverts commit 843517a0ab.

This reverts commit d1a9579526.
2026-02-13 04:48:49 +00:00
Valentin Gosu 53664bf0f3 Bug 2009372 - Allow PrioritizableRunnable::Run to run on socket thread r=necko-reviewers,kershaw,xpcom-reviewers,nika
The PrioritizableRunnable asserted that it runs on the main thread.
In order to prioritize events on the socket thread we also allow these
runnables to be dispatched to the socket thread.

Differential Revision: https://phabricator.services.mozilla.com/D280953
2026-02-13 02:18:08 +00:00
Jens Stutte 69091519a2 Bug 2011161 - Enforce TaskQueue names to be literal with StaticString. r=xpcom-reviewers,dom-storage-reviewers,nika,asuth
By now, nobody really uses TaskQueue::mName. Bug 1999508 wants to introduce logging and in order to avoid copying strings just for that, we enforce names to be literals.

In a few cases this reduces the level of detail provided in the name (WebRTC, IndexedDB), but given it never showed up (except maybe while debugging) we can probably live without it.

Differential Revision: https://phabricator.services.mozilla.com/D279500
2026-01-26 15:15:47 +00:00
Sandor Molnar 64ab8b77b5 Revert "Bug 2011161 - Enforce TaskQueue names to be literal with StaticString. r=xpcom-reviewers,dom-storage-reviewers,nika,asuth" for causing build bustages @ TestFileSystemDataManagerVersions.cpp
This reverts commit 1030b77bd4.
2026-01-26 12:34:32 +00:00
Jens Stutte 1030b77bd4 Bug 2011161 - Enforce TaskQueue names to be literal with StaticString. r=xpcom-reviewers,dom-storage-reviewers,nika,asuth
By now, nobody really uses TaskQueue::mName. Bug 1999508 wants to introduce logging and in order to avoid copying strings just for that, we enforce names to be literals.

In a few cases this reduces the level of detail provided in the name (WebRTC, IndexedDB), but given it never showed up (except maybe while debugging) we can probably live without it.

Differential Revision: https://phabricator.services.mozilla.com/D279500
2026-01-26 11:30:22 +00:00
Matthew Gaudet 29ea9091ad Bug 1990842 - Enforce copying restrictions in Gecko r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D268607
2025-10-28 20:05:42 +00:00
serge-sans-paille c961fa4a0b Bug 1993127 - Remove unused inclusion of Attributes.h from xpcom/* r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D269714
2025-10-24 09:33:39 +00:00
Matthew Gaudet 13b332cedd Bug 1991164 - Support LogMicroTaskQueueEntry::Run for JS Micro Tasks r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D268618
2025-10-17 23:34:11 +00:00
Jeff Muizelaar a0583cf322 Bug 1982895 - Add profiler markers for runnables run by IdleWrapperRunnable::TimedOut r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D261012
2025-09-04 13:37:47 +00:00
Nika Layzell 7d39c30b5b Bug 1979013 - Part 2: Require nsITimer API callers to provide a nsACString, r=xpcom-reviewers,media-playback-reviewers,webrtc-reviewers,profiler-reviewers,dom-storage-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,mstange,emz,bwc,janv,emilio,padenot
This avoids the small overhead and potential for bugs from the previous
approach of assuming all `const char*` arguments passed to `nsITimer`
initializers are string literals, by instead requiring the argument to be a
`const nsACString&`. This involves changing all callsites to pass a `""_ns`
string literal down instead of a bare string literal.

It appears that while there were currently no buggy callers which
would've provided a dynamic string, there was at least one piece of code
(nsRepeatService::Start) which did pass down a raw char* which may be
dynamically allocated (all callers pass down `nsLiteralCString` so we're
actually OK here right now, but this was a footgun).

Differential Revision: https://phabricator.services.mozilla.com/D261032
2025-08-29 16:18:25 +00:00
iulian moraru f5d6849317 Revert "Bug 1979013: apply code formatting via Lando" for causing windows build bustages on MFTEncoder.cpp.
This reverts commit 8c929cc018.

Revert "Bug 1979013 - Part 2: Require nsITimer API callers to provide a nsACString, r=xpcom-reviewers,media-playback-reviewers,webrtc-reviewers,profiler-reviewers,dom-storage-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,mstange,emz,bwc,janv,emilio,padenot"

This reverts commit e01c0a6a32.

Revert "Bug 1979013 - Part 1: Eagerly fetch name for timer callbacks, r=xpcom-reviewers,mccr8"

This reverts commit 9f8e73c163.
2025-08-27 23:00:09 +00:00
Nika Layzell e01c0a6a32 Bug 1979013 - Part 2: Require nsITimer API callers to provide a nsACString, r=xpcom-reviewers,media-playback-reviewers,webrtc-reviewers,profiler-reviewers,dom-storage-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,mstange,emz,bwc,janv,emilio,padenot
This avoids the small overhead and potential for bugs from the previous
approach of assuming all `const char*` arguments passed to `nsITimer`
initializers are string literals, by instead requiring the argument to be a
`const nsACString&`. This involves changing all callsites to pass a `""_ns`
string literal down instead of a bare string literal.

It appears that while there were currently no buggy callers which
would've provided a dynamic string, there was at least one piece of code
(nsRepeatService::Start) which did pass down a raw char* which may be
dynamically allocated (all callers pass down `nsLiteralCString` so we're
actually OK here right now, but this was a footgun).

Differential Revision: https://phabricator.services.mozilla.com/D261032
2025-08-27 22:04:15 +00:00
Nika Layzell b66d532c27 Bug 1824189 - Add a NS_DISPATCH_FALLIBLE flag to specify that events should not be leaked on error, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,webrtc-reviewers,bwc,padenot,emilio,jstutte,dom-worker-reviewers,asuth,kershaw,ohall
Differential Revision: https://phabricator.services.mozilla.com/D258327
2025-08-26 16:47:30 +00:00
Atila Butkovits a906e9e172 Revert "Bug 1824189 - Add a NS_DISPATCH_FALLIBLE flag to specify that events should not be leaked on error, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,webrtc-reviewers,bwc,padenot,emilio,jstutte,dom-worker-reviewers,asuth,kershaw,ohall" for causing leaks complaining about MediaTransportHandlerSTS.
This reverts commit 381d5dd6f0.
2025-08-26 00:43:59 +00:00
Nika Layzell 381d5dd6f0 Bug 1824189 - Add a NS_DISPATCH_FALLIBLE flag to specify that events should not be leaked on error, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,webrtc-reviewers,bwc,padenot,emilio,jstutte,dom-worker-reviewers,asuth,kershaw,ohall
Differential Revision: https://phabricator.services.mozilla.com/D258327
2025-08-25 23:20:08 +00:00
Nika Layzell 902c1ab992 Bug 1966936 - Switch various IPC IDs to 64-bits, r=ipc-reviewers,mccr8,jld
This changes a few IDs which have historically been 32-bit integers to
instead be 64-bit integers, reducing the chance of the value
overflowing.

Differential Revision: https://phabricator.services.mozilla.com/D250502
2025-05-29 19:41:03 +00:00
iulian moraru f47b2be876 Revert "Bug 1966936 - Switch various IPC IDs to 64-bits, r=ipc-reviewers,mccr8,jld" for causing build bustages on IPCFuzzController.cpp.
This reverts commit 1c84660d1e.
2025-05-28 17:45:49 +00:00
Nika Layzell 1c84660d1e Bug 1966936 - Switch various IPC IDs to 64-bits, r=ipc-reviewers,mccr8,jld
This changes a few IDs which have historically been 32-bit integers to
instead be 64-bit integers, reducing the chance of the value
overflowing.

Differential Revision: https://phabricator.services.mozilla.com/D250502
2025-05-28 15:24:05 +00:00
Norisz Fay 69c6408bb5 Revert "Bug 1966936 - Switch various IPC IDs to 64-bits, r=ipc-reviewers,mccr8,jld" for causing multiple build bustages
This reverts commit 9d6f16ddda.
2025-05-26 22:56:41 +00:00
Nika Layzell 9d6f16ddda Bug 1966936 - Switch various IPC IDs to 64-bits, r=ipc-reviewers,mccr8,jld
This changes a few IDs which have historically been 32-bit integers to
instead be 64-bit integers, reducing the chance of the value
overflowing.

Differential Revision: https://phabricator.services.mozilla.com/D250502
2025-05-26 21:44:11 +00:00
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