253 Commits
Author SHA1 Message Date
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
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
Nika Layzell f8cc60a090 Bug 1979013 - Part 1: Eagerly fetch name for timer callbacks, r=xpcom-reviewers,mccr8,necko-reviewers,valentin
This avoids risks which can be caused by reading the name for things
such as the profiler. By fetching the name from the callback when the
nsITimer is initialized, we avoid potential race conditions, and also
avoid the potential for re-entrancy when reading the name from a timer.

As part of this change, timer names are now always stored as a
`nsCString` (as they may be dynamic due to JS or custom nsINamed
implementations). The `const char*` arguments passed to function and closure
based constructors are assumed to be string literals, and passed to
`AssignLiteral`.

Differential Revision: https://phabricator.services.mozilla.com/D261031
2025-08-29 16:18:21 +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 9f8e73c163 Bug 1979013 - Part 1: Eagerly fetch name for timer callbacks, r=xpcom-reviewers,mccr8
This avoids risks which can be caused by reading the name for things
such as the profiler. By fetching the name from the callback when the
nsITimer is initialized, we avoid potential race conditions, and also
avoid the potential for re-entrancy when reading the name from a timer.

As part of this change, timer names are now always stored as a
`nsCString` (as they may be dynamic due to JS or custom nsINamed
implementations). The `const char*` arguments passed to function and closure
based constructors are assumed to be string literals, and passed to
`AssignLiteral`.

Differential Revision: https://phabricator.services.mozilla.com/D261031
2025-08-27 22:04:11 +00:00
Jens Stutte 81f9147285 Bug 1964037 - Increase the sequence # in SetDelay for one shot timers. r=xpcom-reviewers,nika
While the recommendation to not use SetDelay at all with one-shot timers
remains, there are too many rare usages to be easily audited.
But we can at least increase the sequence number, which ensures for
one-shot timers:

- in case the timer event was not yet executed we will reschedule the timer,
  even if the event was already in flight.
- in case the payload was already executed, we will still bail with error.

For repeating timers nothing changes.

Differential Revision: https://phabricator.services.mozilla.com/D256191
2025-07-09 10:18:53 +00:00
Jens Stutte 3949ce093c Bug 1961386 - part 3: Substitute timer local mGeneration with TimerThread global sequence. r=xpcom-reviewers,nika,jlink
This will help us later to craft stable and unique sort conditions for TimerThread::mTimers, enabling binary search on the array.

Differential Revision: https://phabricator.services.mozilla.com/D249899
2025-07-04 20:10:14 +00:00
Serban Stanca 8507096e4b Revert "Bug 1961386 - part 6: Use binary search in Add/RemoveTimerInternal. r=xpcom-reviewers,nika,jlink" for causing devtools failures in browser_rules_mark_overridden_layers.js.
This reverts commit d0da8faf38.

This reverts commit 290c897a56.

This reverts commit feb3956985.

This reverts commit eb07412c3e.

This reverts commit 31a063c7e3.

This reverts commit c53ea72851.
2025-07-02 18:48:24 +00:00
Jens Stutte eb07412c3e Bug 1961386 - part 3: Substitute timer local mGeneration with TimerThread global sequence. r=xpcom-reviewers,nika,jlink
This will help us later to craft stable and unique sort conditions for TimerThread::mTimers, enabling binary search on the array.

Differential Revision: https://phabricator.services.mozilla.com/D249899
2025-07-02 15:08:03 +00:00
Sylvestre Ledru a3ea006705 Bug 1519636 - Reformat recent changes to the Google coding style r=emilio,necko-reviewers,geckoview-reviewers,application-update-reviewers,media-playback-reviewers,devtools-reviewers,anti-tracking-reviewers,profiler-reviewers,win-reviewers,migration-reviewers,padenot,mconley,nchevobbe,kershaw,gstoll,mstange,bytesized,m_kato
This new version of clang 17 also slightly changed the formatting.

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D215914
2024-07-17 11:15:31 +00:00
Jan Varga 272327b326 Bug 1855134 - Move existing MOZ_TRY macros to a dedicated header file; r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D189226
2023-09-28 20:46:07 +00:00
Jamie Nicol bb7866c27e Bug 1843534 - Avoid unnecessary timestamp in nsTimerImpl::Fire if logging is disabled. r=xpcom-reviewers,nika
On certain devices we have seen that taking frequent timestamps can be
expensive, therefore it makes sense to reduce the number of timestamps
taken in hot paths. nsTimerImpl::Fire() currently takes a timestamp
which only gets used in logging. This patch therefore makes it so the
timestamp is only taken when logging is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D185010
2023-08-09 10:28:38 +00:00
Florian Quèze dc510c9008 Bug 1828013 - Add a scriptable API to list all current nsITimer instances, r=smaug.
Differential Revision: https://phabricator.services.mozilla.com/D175430
2023-04-20 09:43:41 +00:00
Gerald Squelart 132204b11f Bug 1787974 - nsTimerImpl directly keeps track of whether it's in a TimerThread::Entry r=smaug
nsTimerImplHolder can now be removed.

Differential Revision: https://phabricator.services.mozilla.com/D164286
2023-01-20 17:11:08 +00:00
Fabrice Desré e29be44cb7 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 16:39:41 +00:00
Andreea Pavel fc724b92fc Backed out changeset b9d2965591b9 (bug 1761040) for landing with wrong author CLOSED TREE DONTBUILD 2022-08-03 18:55:00 +03:00
Andreea Pavel eda47f3911 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 15:27:43 +00:00
Andreea Pavel c2e97d2e06 Backed out changeset a907159a482f (bug 1761040) for causing build bustages on a CLOSED TREE 2022-08-02 04:59:08 +03:00
Fabrice Desré d2d02e8493 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-02 00:49:41 +00:00
Nika Layzell 583cee7bac Bug 1778211 - Reject xpidl CDATA containing 'virtual', r=xpcom-reviewers,necko-reviewers,mccr8,dragana
We'll probably want to do something more accurate in the future with a
custom clang static analysis pass which validates that XPIDL interfaces
have the expected vtable and struct layout, however doing so would be
more involved than the string matching done in this patch.

In addition to checking for extra virtual methods, we'll likely also
want to check for data members on interfaces, and reject them unless the
class is marked as `[builtinclass]` in addition to some other attribute
which we'll need to add to prevent them from being implemented in Rust
(as c++ data members will not be reflected by the rust macro).

There were 2 instances of a comment which contained the word 'virtual'
within a CDATA block. These comments were moved out of the CDATA block
to avoid triggering the error.

Differential Revision: https://phabricator.services.mozilla.com/D151068
2022-07-06 14:53:06 +00:00
Andrew McCreight 9ebb07c91b Bug 1514936, part 2 - Drop the outer arguments from static components. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146457
2022-05-17 20:24:19 +00:00
Gerald Squelart cc9f3020d5 Bug 1766357 - Remove unused and empty TimerThread::InitLocks - r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D144660
2022-04-27 01:14:37 +00:00
Jens Stutte 4cf82d8690 Bug 1765822: Do not assert but just bail out on missing event target in nsTimerImpl::InitCommon. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D144540
2022-04-25 10:46:25 +00:00
Randell Jesup 687bab8ee0 Bug 1207753 - xpcom Timer thread-safety annotations r=nika
Differential Revision: https://phabricator.services.mozilla.com/D130572
2022-03-19 03:43:57 +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
Randell Jesup 30620287d0 Bug 1746523: xpcom Timer cleanup, assertions and comments r=bwc,xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D134089
2022-02-01 20:25:16 +00:00
Randell Jesup 3ff3ef3560 Bug 1739421: Use kungFuDeathGrip when firing a timer r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D130375
2021-11-08 23:00:30 +00:00
Andreas Pehrson bb31f32cb5 Bug 1529581 - Introduce initHighResolutionWithNamedFuncCallback for nsITimer. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D129654
2021-11-03 15:23:27 +00:00
Iulian Moraru 2d1a832c1f Backed out 10 changesets (bug 1529581) for causing bp-hybrid build bustages on TestPacer. CLOSED TREE
Backed out changeset e7b7072ac90c (bug 1529581)
Backed out changeset 3c5d719c54db (bug 1529581)
Backed out changeset 39e2b3143ecd (bug 1529581)
Backed out changeset bd2122ea3cc3 (bug 1529581)
Backed out changeset 033cc341ad2e (bug 1529581)
Backed out changeset 8a8ee5055c0d (bug 1529581)
Backed out changeset 8c204db3e91d (bug 1529581)
Backed out changeset 142d94304c86 (bug 1529581)
Backed out changeset ac180bf89fd0 (bug 1529581)
Backed out changeset d0640f52161d (bug 1529581)
2021-11-02 17:53:17 +02:00
Andreas Pehrson 6177453043 Bug 1529581 - Introduce initHighResolutionWithNamedFuncCallback for nsITimer. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D129654
2021-11-02 14:35:58 +00:00
Andreas Pehrson 251fddc48b Bug 1729964 - Fix data race on static logging-only nsTimerImpl members. r=xpcom-reviewers,KrisWright
Tsan with MOZ_LOG=nsTimerImpl:5 reveals this race.

Differential Revision: https://phabricator.services.mozilla.com/D126920
2021-10-06 14:33:41 +00:00
Byron Campen [:bwc] 11f4e4f4fb Bug 1726177: For repeating precise, keep the cadence when we finish firing late. r=xpcom-reviewers,nika,jesup
Covers the case where we finish late because the callback took a long time,
and the case where we fired really late (eg; because of sleep).

Differential Revision: https://phabricator.services.mozilla.com/D123814
2021-09-03 21:59:00 +00:00
Iulian Moraru 5dbc655d2d Backed out 2 changesets (bug 1726177) for causing gtest failures on TestTimers.cpp. CLOSED TREE
Backed out changeset 82ec582992fd (bug 1726177)
Backed out changeset 50952e0327ee (bug 1726177)
2021-09-02 03:09:10 +03:00
Byron Campen [:bwc] 81cdabc8a1 Bug 1726177: For repeating precise, keep the cadence when we finish firing late. r=xpcom-reviewers,nika
Covers the case where we finish late because the callback took a long time,
and the case where we fired really late (eg; because of sleep).

Differential Revision: https://phabricator.services.mozilla.com/D123814
2021-09-01 21:46:48 +00:00
Florian Quèze 50f6b1fd86 Bug 1728228 - Add profiler markers in the Timer thread to understand its activity, r=gerald,smaug,KrisWright.
Differential Revision: https://phabricator.services.mozilla.com/D123989
2021-08-31 13:41:46 +00:00
kriswright 2caece151a Bug 1683404 - Wrap the timer thread behind a mutex. r=nika
This particular race is a tricky one - there's no perfect solution to protecting the timer thread from being called in `cancel` while being dereferenced. This ensures that we won't run into that problem by locking all of our TimerThread calls behind a mutex inside a wrapper class. Then we hold onto the wrapper class until after we shutdown `nsThreadManager`, in which case no background thread pools should be active anymore to call `nsTimerImpl::Cancel`.

For reference, the worst-case scenario happens when another thread dereferences `gThread` [between these two calls](https://searchfox.org/mozilla-central/rev/98a9257ca2847fad9a19631ac76199474516b31e/xpcom/threads/nsTimerImpl.cpp#402-403), in which case we will get stuck on a dereferenced mutex. By putting the check and the actual call into `gThread` behind a mutex maybe we can prevent this issue.

Differential Revision: https://phabricator.services.mozilla.com/D115453
2021-06-17 15:36:00 +00:00
Florian Quèze 76d92a054e Bug 1715257 - Remove Task Tracer code from the profiler, r=gerald,necko-reviewers.
Differential Revision: https://phabricator.services.mozilla.com/D117996
2021-06-17 09:33:00 +00:00
Iulian Moraru 4b5e996bef Backed out changeset 617a466d0cce (bug 1715257) for causing build bustages. CLOSED TREE 2021-06-17 10:58:16 +03:00
Florian Quèze 2b195470a1 Bug 1715257 - Remove Task Tracer code from the profiler, r=gerald,necko-reviewers.
Differential Revision: https://phabricator.services.mozilla.com/D117996
2021-06-17 06:12:10 +00:00
Nika Layzell 696bb3aec3 Bug 1711090 - Part 4: Remove non-string func timer names, r=KrisWright
They are not used anywhere in the codebase and come with
non-insignificant complexity which we can drop.

Differential Revision: https://phabricator.services.mozilla.com/D115267
2021-05-18 20:45:17 +00:00
Nika Layzell db011b4242 Bug 1711090 - Part 2: Allow creating a nsITimer with a std::function callback, r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D115089
2021-05-18 20:45:16 +00:00
Nika Layzell 38b5936044 Bug 1711090 - Part 1: Simplify nsTimerImpl's Callback implementation, r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D115088
2021-05-18 20:45:16 +00:00
Alexandru Michis 1a7078f60c Backed out 4 changesets (bug 1711090) for causing bustages in nsTimerImpl.cpp
CLOSED TREE

Backed out changeset 5c6f0950714d (bug 1711090)
Backed out changeset 0b6a886eea8a (bug 1711090)
Backed out changeset fc9c788ff41d (bug 1711090)
Backed out changeset ecc51d9ad027 (bug 1711090)
2021-05-18 20:25:56 +03:00
Nika Layzell a9196a4172 Bug 1711090 - Part 4: Remove non-string func timer names, r=KrisWright
They are not used anywhere in the codebase and come with
non-insignificant complexity which we can drop.

Differential Revision: https://phabricator.services.mozilla.com/D115267
2021-05-18 16:24:49 +00:00
Nika Layzell dc243c85c4 Bug 1711090 - Part 2: Allow creating a nsITimer with a std::function callback, r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D115089
2021-05-18 16:24:48 +00:00