Closed Bug 2090806 Opened 19 days ago Closed 2 days ago

Crash in [@ kotlin.UninitializedPropertyAccessException: at mozilla.telemetry.glean.private.TimingDistributionMetricType.getInner(TimingDistributionMetricType.kt:8)]

Categories

(Data Platform and Tools :: Glean: SDK, defect, P1)

defect

Tracking

(firefox161+ affected, firefox162+ fixed, firefox163+ fixed)

RESOLVED FIXED
Tracking Status
firefox161 + affected
firefox162 + fixed
firefox163 + fixed

People

(Reporter: clouseau-bot, Assigned: janerik)

References

(Blocks 2 open bugs)

Details

(4 keywords)

Crash Data

Attachments

(4 external files)

Crash report: https://crash-stats.mozilla.org/report/index/c308ac89-4241-4784-bd4e-080360261108

Top 10 frames:

0  mozilla.telemetry.glean.private.TimingDistributionMetricType  getInner  mozilla/telemetry/glean/private/TimingDistributionMetricType.kt
1  mozilla.telemetry.glean.private.TimingDistributionMetricType  start  mozilla/telemetry/glean/private/TimingDistributionMetricType.kt
2  org.mozilla.fenix.components.metrics.AdjustMetricsService  buildAdjustConfig  mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt
3  org.mozilla.fenix.components.metrics.AdjustMetricsService  ensureInitialized  mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt
4  org.mozilla.fenix.components.metrics.AdjustMetricsService$start$1  invokeSuspend  mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt
5  kotlin.coroutines.jvm.internal.BaseContinuationImpl  resumeWith
6  kotlinx.coroutines.DispatchedTask  run
7  kotlinx.coroutines.internal.LimitedDispatcher$Worker  run
8  kotlinx.coroutines.scheduling.TaskImpl  run
9  kotlinx.coroutines.scheduling.CoroutineScheduler$Worker  run

There are 16 crashes (from 7 installations) in nightly 161 starting with buildid 20261105050539.

This signature is new: its first report anywhere is in build 20261031095059 (2026-10-31), 5 days before the build above.

Clouseau analysis (automated). The mechanism below fits the evidence but is not proven end-to-end:

Fenix probably crashes at startup when AdjustMetricsService starts the Glean timer adjustAttributionTime and the Glean Kotlin TimingDistributionMetricType reads its still-uninitialized lateinit inner.

  1. AdjustMetricsService.start launches a coroutine on Dispatchers.IO that calls ensureInitialized and then buildAdjustConfig when no Adjust attribution is stored yet.
  2. buildAdjustConfig calls setAttributionChangedListener, which calls AdjustAttribution.adjustAttributionTime.start().
  3. Changeset cb62c451a11f moved the Glean Android library from 70.3.0 to 71.0.0, which probably changed when TimingDistributionMetricType.inner is assigned (for example, only once Glean is initialized).
  4. On this IO-thread path, start() reaches getInner() before inner is set, and Kotlin throws UninitializedPropertyAccessException.

Frames #0–#4 match this chain, and the fenix code in it was last changed on 2026-10-13, so the variable is the Glean library. Step 3 is inferred from domain and timing (Glean 71.0.0 landed 2026-10-29 and the signature first appeared in build 20261031), not read from Glean source, which is not in mozilla-central. The update may only have exposed an older ordering issue, where Adjust telemetry is touched before Glean initialization.

The signature first appeared in build 20261031, and per-day counts are zero before 10-31. The Glean 71.0.0 bump (cb62c451a11f) landed on 2026-10-29, just before that. No Nimbus rollout went live in that period, and the bit-flip and Raptor Lake shares are 0%. The 2026-11-05 pushlog window comes after first appearance and contains nothing in Glean or Adjust.

Starting point — NOT a suspected cause: cb62c451a11f (gh) (bug 2085018) by :janerik.

This changeset did not land in this build's pushlog window, so there is no evidence here that the crash is a recent regression from it; it is named only as the closest thing found on the crash path. If you know where this actually comes from, that correction is the most useful thing you could leave on this bug.

Impact

The parent process crashes, so the whole browser closes.

Possible fixes

  • In Glean Kotlin, make TimingDistributionMetricType.start safe to call before inner is assigned (lazy init or queueing, as other metric types do pre-init).
  • In fenix, defer AdjustMetricsService.start's ensureInitialized until after Glean.initialize has run.
  • Defensively catch the exception around adjustAttributionTime.start() in setAttributionChangedListener until a Glean fix ships.

How to confirm

Diff the Glean Kotlin TimingDistributionMetricType between v70.3.0 and v71.0.0 for the introduction of lateinit var inner, then reproduce by starting Fenix with marketing telemetry enabled and no stored Adjust attribution, with AdjustMetricsService.start racing ahead of Glean.initialize.

Code references:

What the automated skeptic pass checked

In its own words (a pass means the check succeeded, which is not always support for the conclusion):

  • unverifiable mechanism — The Glean Kotlin bindings (TimingDistributionMetricType.kt) are not in mozilla-central (searchfox finds no definition), so I could not confirm that v71.0.0 introduced or changed the lateinit inner. The link rests on domain (the exception is thrown inside the Glean library this changeset swaps) and timing (landed 2026-10-29, signature first seen in build 20261031).
  • unverifiable alt_adjust_sdk — The Adjust SDK 5.8.1 bump landed the same day, but the exception is raised in Glean's getInner, not in Adjust code, so it is less likely. AdjustMetricsService.kt was last changed on 2026-10-13 (3881151eace9), well before first sighting.
  • fail window — This and every other 2026-11-05 pushlog candidate (including the Nimbus 'feature-flip' changes and the application-services vendor bump f528980adbd1) is after the signature's first sighting in build 20261031, and none touches Glean Kotlin, Adjust or AdjustMetricsService. They are noise for this crash.

:janerik, can you have a look please?

Filed automatically by Clouseau with an LLM, from a submitted crash report: not an independent Mozilla discovery

Filed automatically by Clouseau, which analyses nightly crashes with an LLM. Nothing above was written or checked by a human. Please close it as INVALID if it is wrong — that is useful feedback, not a nuisance.

This is not an independent Mozilla discovery: the crash is known here only because somebody submitted the crash report linked at the top. If this duplicates an existing report, please resolve THIS bug as the duplicate and leave the credit with the earlier reporter.

Flags: needinfo?(jrediger)

dropping it into triage.

Flags: needinfo?(jrediger)
Assignee: nobody → jrediger
Priority: -- → P3
Priority: P3 → P1

badboy merged PR [mozilla/glean]: Bug 2090806 - Kotlin: Don't do intialization of a timing distribution metric on the dispatcher (#3778) in 919fb8a.

The patch landed upstream. It will land in the next release, which I'll try to get out quickly. Leaving this open for tracking until then.

Flags: needinfo?(jrediger)

Clouseau, can you please stop reposting things that are already tackled? Thank you.

Flags: needinfo?(jrediger)
Severity: -- → S2

Jan-Erik, this is a top crash on release, here is Claude suggestion for a safe fix on the release channel we could include in next week dot release:

Cause: a regression in Glean 71.0.0, confirmed from the Glean source. In v70.3.0, inner was by lazy, so it was created on first use and could not fail. In v71.0.0 it became a lateinit var, set by a task queued on Glean's Dispatchers.Delayed. That task only runs after Glean.initialize drains the pre-init queue. AdjustMetricsService.start() starts a coroutine on Dispatchers.IO that calls ensureInitialized → buildAdjustConfig → setAttributionChangedListener → AdjustAttribution.adjustAttributionTime.start(). That call can run before the queued task does, so start() throws.
This only happens while no Adjust attribution is stored, because alreadyKnown(settings) returns false. For those users it repeats on every launch.
Upstream fix: Jan-Erik's PR #3778 (commit 919fb8a) restores lazy creation in getInner(). It is not in any Glean release: it is listed under "Unreleased" in the changelog and is in neither v71.1.0 nor v71.2.0. It is planned for v72.0.0 (bug 2094550), which waits on bug 2093447 and needs cross-team coordination.
Release (161.0.1) and beta (162) both use Glean 71.0.0. Main uses 71.2.0, which also lacks the fix, so 163 is affected too.

Recommended option: a small Fenix-only workaround, uplifted to release and beta

In setAttributionChangedListener (AdjustMetricsService.kt), stop using the Glean timer and measure the time in Fenix instead. accumulateSingleSample() goes through Dispatchers.Delayed in the same queue order as the constructor's task, so it is safe before Glean is initialized:

 private fun setAttributionChangedListener(config: AdjustConfig, settings: Settings) {
     val startTime = SystemClock.elapsedRealtime()
 
     config.setOnAttributionChangedListener {
         AdjustAttribution.adjustAttributionTime.accumulateSingleSample(
             SystemClock.elapsedRealtime() - startTime,
         )
         ...

What do you think?

Flags: needinfo?(jrediger)

That would work. We can leave a TODO on it to switch it back once bug 2094550 landed.
(I didn't realize this hit release already, my bad).

Are you doing that patch and I can r+ it or the other way around?

Flags: needinfo?(jrediger) → needinfo?(pascalc)

Please do the patch, I am not a developer :D Thanks!

Flags: needinfo?(pascalc) → needinfo?(jrediger)

(In reply to Pascal Chevrel (relman team) -> :pascalc from comment #8)

Please do the patch, I am not a developer :D Thanks!

You can be! (I'll do it)

Flags: needinfo?(jrediger)
Attachment #9691274 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Crashes on Android in Release and Beta.
  • Code covered by automated testing?: no
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: -
  • Risk associated with taking this patch: low
  • Explanation of risk level: Changing to a Glean API we know is not impacted by the bug (it's used in other places in this way).
  • String changes made/needed?: -
  • Is Android affected?: yes

firefox-release Uplift Approval Request

  • User impact if declined/Reason for urgency: Crashes on Android in Release and Beta.
  • Code covered by automated testing?: no
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: -
  • Risk associated with taking this patch: low
  • Explanation of risk level: Changing to a Glean API we know is not impacted by the bug (it's used in other places in this way).
  • String changes made/needed?: -
  • Is Android affected?: yes
Attachment #9691277 - Flags: approval-mozilla-release?
Pushed by jrediger@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/0a2ce2c92701 https://hg.mozilla.org/integration/autoland/rev/f5d5512a73e0 Work around a potential crash when using the Glean API r=android-reviewers,pollymce
Crash Signature: [@ kotlin.UninitializedPropertyAccessException: at mozilla.telemetry.glean.private.TimingDistributionMetricType.getInner(TimingDistributionMetricType.kt:8)] → [@ kotlin.UninitializedPropertyAccessException: at mozilla.telemetry.glean.private.TimingDistributionMetricType.getInner(TimingDistributionMetricType.kt:8)] [@ fij: at mozilla.telemetry.glean.private.TimingDistributionMetricType.getInner(TimingDistributi…
Status: NEW → RESOLVED
Closed: 2 days ago
Resolution: --- → FIXED
Attachment #9691274 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: