Bug 1869004 - On Android submit 'use-counters' ping also around startup r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D195933
This commit is contained in:
Chris H-C 2023-12-12 17:22:20 +00:00
parent f88ce30376
commit 1ee82075f6
2 changed files with 17 additions and 0 deletions

View File

@ -846,6 +846,19 @@ nsresult nsContentUtils::Init() {
if (XRE_IsParentProcess()) {
AsyncPrecreateStringBundles();
#if defined(MOZ_WIDGET_ANDROID)
// On Android, at-shutdown ping submission isn't reliable
// (( because, on Android, we usually get killed, not shut down )).
// To have a chance at submitting the ping, aim for idle after startup.
nsresult rv = NS_DispatchToCurrentThreadQueue(
NS_NewRunnableFunction(
"AndroidUseCounterPingSubmitter",
[]() { glean_pings::UseCounters.Submit("idle_startup"_ns); }),
EventQueuePriority::Idle);
// This is mostly best-effort, so if it goes awry, just log.
Unused << NS_WARN_IF(NS_FAILED(rv));
#endif // defined(MOZ_WIDGET_ANDROID)
RunOnShutdown(
[&] { glean_pings::UseCounters.Submit("app_shutdown_confirmed"_ns); },
ShutdownPhase::AppShutdownConfirmed);

View File

@ -33,6 +33,10 @@ use-counters:
app_shutdown_confirmed: |
Submitted when we reach `ShutdownPhase::AppShutdownConfirmed`.
(Any later and the network might have been torn down.)
idle_startup: |
(Android only)
Submitted when the thread init'ing DOM's contentutils has an idle moment.
Acts as a safety net for platforms (like Android) that don't get to gracefully shut down.
include_client_id: true
send_if_empty: false
bugs: