This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch geckoview-99.0.1-11.0-1 in repository tor-browser.
commit 8a3142c41fbfe3d00bf26fd2157fa05cd7beabbd Author: Chris H-C chutten@mozilla.com AuthorDate: Mon Mar 21 21:19:26 2022 +0000
Bug 1758795 - Run cleanup registration on main thread r=TravisLong a=dmeehan
If we don't, we assert if the first GIFFT-enabled timing distribution's instrumentation thread on a given process is not the main thread.
Differential Revision: https://phabricator.services.mozilla.com/D141632 --- .../glean_parser_ext/templates/gifft.jinja2 | 31 +++++++++++++--------- .../glean/tests/pytest/gifft_output_Event | 1 + .../glean/tests/pytest/gifft_output_Histogram | 11 +++++--- .../glean/tests/pytest/gifft_output_Scalar | 21 +++++++++------ 4 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/toolkit/components/glean/build_scripts/glean_parser_ext/templates/gifft.jinja2 b/toolkit/components/glean/build_scripts/glean_parser_ext/templates/gifft.jinja2 index 0da20645c7c3b..5fdccfe1a0e90 100644 --- a/toolkit/components/glean/build_scripts/glean_parser_ext/templates/gifft.jinja2 +++ b/toolkit/components/glean/build_scripts/glean_parser_ext/templates/gifft.jinja2 @@ -15,6 +15,7 @@ Jinja2 template is not. Pleas file bugs! #} #include "nsClassHashtable.h" #include "nsTHashMap.h" {% endif %} +#include "nsThreadUtils.h"
#ifndef mozilla_glean_{{ probe_type }}GifftMap_h #define mozilla_glean_{{ probe_type }}GifftMap_h @@ -31,10 +32,12 @@ static inline TimerToStampMutex::AutoLock GetTimerIdToStartsLock() { auto lock = sTimerIdToStarts.Lock(); if (!*lock) { *lock = MakeUnique<nsTHashMap<TimerId, TimeStamp>>(); - RunOnShutdown([&] { - auto lock = sTimerIdToStarts.Lock(); - *lock = nullptr; // deletes, see UniquePtr.h - }); + NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, [&] { + RunOnShutdown([&] { + auto lock = sTimerIdToStarts.Lock(); + *lock = nullptr; // deletes, see UniquePtr.h + }); + })); } return lock; } @@ -49,10 +52,12 @@ static inline SubmetricToMirrorMutex::AutoLock GetLabeledMirrorLock() { auto lock = sLabeledMirrors.Lock(); if (!*lock) { *lock = MakeUnique<SubmetricToLabeledMirrorMapType>(); - RunOnShutdown([&] { - auto lock = sLabeledMirrors.Lock(); - *lock = nullptr; // deletes, see UniquePtr.h - }); + NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, [&] { + RunOnShutdown([&] { + auto lock = sLabeledMirrors.Lock(); + *lock = nullptr; // deletes, see UniquePtr.h + }); + })); } return lock; } @@ -87,10 +92,12 @@ static inline TimesToStartsMutex::AutoLock GetTimesToStartsLock() { auto lock = sTimespanStarts.Lock(); if (!*lock) { *lock = MakeUnique<nsTHashMap<ScalarIDHashKey, TimeStamp>>(); - RunOnShutdown([&] { - auto lock = sTimespanStarts.Lock(); - *lock = nullptr; // deletes, see UniquePtr.h - }); + NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, [&] { + RunOnShutdown([&] { + auto lock = sTimespanStarts.Lock(); + *lock = nullptr; // deletes, see UniquePtr.h + }); + })); } return lock; } diff --git a/toolkit/components/glean/tests/pytest/gifft_output_Event b/toolkit/components/glean/tests/pytest/gifft_output_Event index 30fea481d6a33..1c7ef470ebbcb 100644 --- a/toolkit/components/glean/tests/pytest/gifft_output_Event +++ b/toolkit/components/glean/tests/pytest/gifft_output_Event @@ -8,6 +8,7 @@ #include "mozilla/Maybe.h" #include "mozilla/Telemetry.h" #include "mozilla/DataMutex.h" +#include "nsThreadUtils.h"
#ifndef mozilla_glean_EventGifftMap_h #define mozilla_glean_EventGifftMap_h diff --git a/toolkit/components/glean/tests/pytest/gifft_output_Histogram b/toolkit/components/glean/tests/pytest/gifft_output_Histogram index 77bcb8ad4d2e3..642a3aa80dbbd 100644 --- a/toolkit/components/glean/tests/pytest/gifft_output_Histogram +++ b/toolkit/components/glean/tests/pytest/gifft_output_Histogram @@ -8,6 +8,7 @@ #include "mozilla/Maybe.h" #include "mozilla/Telemetry.h" #include "mozilla/DataMutex.h" +#include "nsThreadUtils.h"
#ifndef mozilla_glean_HistogramGifftMap_h #define mozilla_glean_HistogramGifftMap_h @@ -23,10 +24,12 @@ static inline TimerToStampMutex::AutoLock GetTimerIdToStartsLock() { auto lock = sTimerIdToStarts.Lock(); if (!*lock) { *lock = MakeUnique<nsTHashMap<TimerId, TimeStamp>>(); - RunOnShutdown([&] { - auto lock = sTimerIdToStarts.Lock(); - *lock = nullptr; // deletes, see UniquePtr.h - }); + NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, [&] { + RunOnShutdown([&] { + auto lock = sTimerIdToStarts.Lock(); + *lock = nullptr; // deletes, see UniquePtr.h + }); + })); } return lock; } diff --git a/toolkit/components/glean/tests/pytest/gifft_output_Scalar b/toolkit/components/glean/tests/pytest/gifft_output_Scalar index b568028afcd7d..83f13b3699ca7 100644 --- a/toolkit/components/glean/tests/pytest/gifft_output_Scalar +++ b/toolkit/components/glean/tests/pytest/gifft_output_Scalar @@ -11,6 +11,7 @@ #include "mozilla/Tuple.h" #include "nsClassHashtable.h" #include "nsTHashMap.h" +#include "nsThreadUtils.h"
#ifndef mozilla_glean_ScalarGifftMap_h #define mozilla_glean_ScalarGifftMap_h @@ -29,10 +30,12 @@ static inline SubmetricToMirrorMutex::AutoLock GetLabeledMirrorLock() { auto lock = sLabeledMirrors.Lock(); if (!*lock) { *lock = MakeUnique<SubmetricToLabeledMirrorMapType>(); - RunOnShutdown([&] { - auto lock = sLabeledMirrors.Lock(); - *lock = nullptr; // deletes, see UniquePtr.h - }); + NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, [&] { + RunOnShutdown([&] { + auto lock = sLabeledMirrors.Lock(); + *lock = nullptr; // deletes, see UniquePtr.h + }); + })); } return lock; } @@ -67,10 +70,12 @@ static inline TimesToStartsMutex::AutoLock GetTimesToStartsLock() { auto lock = sTimespanStarts.Lock(); if (!*lock) { *lock = MakeUnique<nsTHashMap<ScalarIDHashKey, TimeStamp>>(); - RunOnShutdown([&] { - auto lock = sTimespanStarts.Lock(); - *lock = nullptr; // deletes, see UniquePtr.h - }); + NS_DispatchToMainThread(NS_NewRunnableFunction(__func__, [&] { + RunOnShutdown([&] { + auto lock = sTimespanStarts.Lock(); + *lock = nullptr; // deletes, see UniquePtr.h + }); + })); } return lock; }