Avoid dropping glitch info on IPC playout glitches [chromium/src : main]

0 views
Skip to first unread message

Fredrik Hernqvist (Gerrit)

unread,
Jan 8, 2026, 10:19:06 AM (11 days ago) Jan 8
to Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
Attention needed from Olga Sharonova

Fredrik Hernqvist voted and added 1 comment

Votes added by Fredrik Hernqvist

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Fredrik Hernqvist . resolved

PTAL! :)

Open in Gerrit

Related details

Attention is currently required from:
  • Olga Sharonova
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
Gerrit-Change-Number: 7415120
Gerrit-PatchSet: 10
Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
Gerrit-Comment-Date: Thu, 08 Jan 2026 15:18:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Sharonova (Gerrit)

unread,
Jan 13, 2026, 8:11:17 AM (6 days ago) Jan 13
to Fredrik Hernqvist, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
Attention needed from Fredrik Hernqvist

Olga Sharonova added 5 comments

File media/audio/audio_output_device_thread_callback.h
Line 77, Patchset 12 (Latest): uint64_t prev_cumulative_glitch_count = 0;
Olga Sharonova . unresolved

prev_cumulative_glitch_count_

Line 76, Patchset 12 (Latest): int64_t prev_cumulative_glitch_duration_us = 0;
Olga Sharonova . unresolved

prev_cumulative_glitch_duration_us_

File media/audio/audio_output_device_thread_callback.cc
Line 76, Patchset 12 (Latest): .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
prev_cumulative_glitch_duration_us),
Olga Sharonova . unresolved

How do we ensure it's monotonic?

Line 78, Patchset 12 (Latest): .count = static_cast<uint32_t>(cur_cumulative_glitch_count -
Olga Sharonova . unresolved

saturated_cast?

File media/base/audio_parameters.h
Line 53, Patchset 12 (Latest): int64_t cumulative_glitch_duration_us; // base::TimeDelta in microseconds.
uint64_t cumulative_glitch_count;
Olga Sharonova . unresolved

Document more?

Open in Gerrit

Related details

Attention is currently required from:
  • Fredrik Hernqvist
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 12
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Comment-Date: Tue, 13 Jan 2026 13:11:00 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Fredrik Hernqvist (Gerrit)

    unread,
    Jan 14, 2026, 2:59:15 AM (6 days ago) Jan 14
    to Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
    Attention needed from Olga Sharonova

    Fredrik Hernqvist added 6 comments

    Patchset-level comments
    File-level comment, Patchset 15 (Latest):
    Fredrik Hernqvist . resolved

    Thanks! Comments addressed.

    File media/audio/audio_output_device_thread_callback.h
    Line 77, Patchset 12: uint64_t prev_cumulative_glitch_count = 0;
    Olga Sharonova . resolved

    prev_cumulative_glitch_count_

    Fredrik Hernqvist

    Done

    Line 76, Patchset 12: int64_t prev_cumulative_glitch_duration_us = 0;
    Olga Sharonova . resolved

    prev_cumulative_glitch_duration_us_

    Fredrik Hernqvist

    Done

    File media/audio/audio_output_device_thread_callback.cc
    Line 76, Patchset 12: .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
    prev_cumulative_glitch_duration_us),
    Olga Sharonova . unresolved

    How do we ensure it's monotonic?

    Fredrik Hernqvist

    Added DCHECKs. I am reluctant to use CHECKS here, because they will crash if the counters overflow when incrementing (we have had such a bug before), and that is much worse for the user experience than getting wrong numbers in the glitch stats.

    Line 78, Patchset 12: .count = static_cast<uint32_t>(cur_cumulative_glitch_count -
    Olga Sharonova . resolved

    saturated_cast?

    Fredrik Hernqvist

    Good idea, done.

    File media/base/audio_parameters.h
    Line 53, Patchset 12: int64_t cumulative_glitch_duration_us; // base::TimeDelta in microseconds.
    uint64_t cumulative_glitch_count;
    Olga Sharonova . unresolved

    Document more?

    Fredrik Hernqvist

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Olga Sharonova
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 15
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Comment-Date: Wed, 14 Jan 2026 07:59:01 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    Jan 16, 2026, 10:53:33 AM (3 days ago) Jan 16
    to Fredrik Hernqvist, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
    Attention needed from Fredrik Hernqvist

    Olga Sharonova added 1 comment

    File media/audio/audio_output_device_thread_callback.cc
    Line 76, Patchset 12: .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
    prev_cumulative_glitch_duration_us),
    Olga Sharonova . unresolved

    How do we ensure it's monotonic?

    Fredrik Hernqvist

    Added DCHECKs. I am reluctant to use CHECKS here, because they will crash if the counters overflow when incrementing (we have had such a bug before), and that is much worse for the user experience than getting wrong numbers in the glitch stats.

    Olga Sharonova

    How do we actually know it will be monotonic and logic like start/stop or default device change won't mess it up?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Fredrik Hernqvist
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 16
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Comment-Date: Fri, 16 Jan 2026 15:53:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
    Comment-In-Reply-To: Fredrik Hernqvist <fhern...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Fredrik Hernqvist (Gerrit)

    unread,
    5:26 AM (14 hours ago) 5:26 AM
    to Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
    Attention needed from Olga Sharonova

    Fredrik Hernqvist added 1 comment

    File media/audio/audio_output_device_thread_callback.cc
    Line 76, Patchset 12: .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
    prev_cumulative_glitch_duration_us),
    Olga Sharonova . unresolved

    How do we ensure it's monotonic?

    Fredrik Hernqvist

    Added DCHECKs. I am reluctant to use CHECKS here, because they will crash if the counters overflow when incrementing (we have had such a bug before), and that is much worse for the user experience than getting wrong numbers in the glitch stats.

    Olga Sharonova

    How do we actually know it will be monotonic and logic like start/stop or default device change won't mess it up?

    Fredrik Hernqvist
    • This shared memory will only be used by a single AudioOutputDeviceThreadCallback, and a single SyncReader.
    • Both the values in shared memory and the prev_* values are initialized to 0 upon creation.
    • SyncReader is the only one that change the values in shared memory, and it only increases them, thus the values in shared memory are monotonically increasing
    • AudioOutputDeviceThreadCallback reads the monotonically increasing values from the shared memory and stores them in the prev_* variables.
    • Thus both the variables in shared memory and the prev_* variables are monotonically increasing, and the shared memory variables are always at least as large as the prev_* variables.
    • This monotonic logic is constrained to AudioOutputDeviceThreadCallback and SyncReader, so this concern does not exist in the rest of the stack. This means that start/stop or default device change cannot affect it.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Olga Sharonova
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 16
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Comment-Date: Mon, 19 Jan 2026 10:26:13 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    6:30 AM (13 hours ago) 6:30 AM
    to Fredrik Hernqvist, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
    Attention needed from Fredrik Hernqvist

    Olga Sharonova added 3 comments

    File media/audio/audio_output_device_thread_callback.cc
    Line 70, Patchset 16 (Latest): int64_t cur_cumulative_glitch_duration_us =
    Olga Sharonova . unresolved

    On a second thought, should we convert the values to TimeDelta when reading them from memory, and use TimeDelta throughout? (This is a general recommendation when dealing with time.)

    Line 76, Patchset 12: .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
    prev_cumulative_glitch_duration_us),
    Olga Sharonova . unresolved

    How do we ensure it's monotonic?

    Fredrik Hernqvist

    Added DCHECKs. I am reluctant to use CHECKS here, because they will crash if the counters overflow when incrementing (we have had such a bug before), and that is much worse for the user experience than getting wrong numbers in the glitch stats.

    Olga Sharonova

    How do we actually know it will be monotonic and logic like start/stop or default device change won't mess it up?

    Fredrik Hernqvist
    • This shared memory will only be used by a single AudioOutputDeviceThreadCallback, and a single SyncReader.
    • Both the values in shared memory and the prev_* values are initialized to 0 upon creation.
    • SyncReader is the only one that change the values in shared memory, and it only increases them, thus the values in shared memory are monotonically increasing
    • AudioOutputDeviceThreadCallback reads the monotonically increasing values from the shared memory and stores them in the prev_* variables.
    • Thus both the variables in shared memory and the prev_* variables are monotonically increasing, and the shared memory variables are always at least as large as the prev_* variables.
    • This monotonic logic is constrained to AudioOutputDeviceThreadCallback and SyncReader, so this concern does not exist in the rest of the stack. This means that start/stop or default device change cannot affect it.
    Olga Sharonova

    Thanks. That actually highlights another aspect: we have non-trivial reads and writes of atomics split between two very distant code locations, which makes it hard to maintain the logic. Should we organize some helpers for that and put them together?

    File media/base/audio_parameters.h
    Line 53, Patchset 12: int64_t cumulative_glitch_duration_us; // base::TimeDelta in microseconds.
    uint64_t cumulative_glitch_count;
    Olga Sharonova . resolved

    Document more?

    Fredrik Hernqvist

    Done

    Olga Sharonova

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Fredrik Hernqvist
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 16
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Comment-Date: Mon, 19 Jan 2026 11:29:50 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Fredrik Hernqvist (Gerrit)

    unread,
    10:09 AM (9 hours ago) 10:09 AM
    to Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
    Attention needed from Olga Sharonova

    Fredrik Hernqvist added 2 comments

    File media/audio/audio_output_device_thread_callback.cc
    Line 70, Patchset 16: int64_t cur_cumulative_glitch_duration_us =
    Olga Sharonova . resolved

    On a second thought, should we convert the values to TimeDelta when reading them from memory, and use TimeDelta throughout? (This is a general recommendation when dealing with time.)

    Fredrik Hernqvist

    Done

    Line 76, Patchset 12: .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
    prev_cumulative_glitch_duration_us),
    Olga Sharonova . unresolved

    How do we ensure it's monotonic?

    Fredrik Hernqvist

    Added DCHECKs. I am reluctant to use CHECKS here, because they will crash if the counters overflow when incrementing (we have had such a bug before), and that is much worse for the user experience than getting wrong numbers in the glitch stats.

    Olga Sharonova

    How do we actually know it will be monotonic and logic like start/stop or default device change won't mess it up?

    Fredrik Hernqvist
    • This shared memory will only be used by a single AudioOutputDeviceThreadCallback, and a single SyncReader.
    • Both the values in shared memory and the prev_* values are initialized to 0 upon creation.
    • SyncReader is the only one that change the values in shared memory, and it only increases them, thus the values in shared memory are monotonically increasing
    • AudioOutputDeviceThreadCallback reads the monotonically increasing values from the shared memory and stores them in the prev_* variables.
    • Thus both the variables in shared memory and the prev_* variables are monotonically increasing, and the shared memory variables are always at least as large as the prev_* variables.
    • This monotonic logic is constrained to AudioOutputDeviceThreadCallback and SyncReader, so this concern does not exist in the rest of the stack. This means that start/stop or default device change cannot affect it.
    Olga Sharonova

    Thanks. That actually highlights another aspect: we have non-trivial reads and writes of atomics split between two very distant code locations, which makes it hard to maintain the logic. Should we organize some helpers for that and put them together?

    Fredrik Hernqvist

    Good idea, I put the logic in a helper class. How about this?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Olga Sharonova
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 18
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Comment-Date: Mon, 19 Jan 2026 15:09:17 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    10:23 AM (9 hours ago) 10:23 AM
    to Fredrik Hernqvist, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org, marinacio...@chromium.org, olka+...@chromium.org
    Attention needed from Fredrik Hernqvist

    Olga Sharonova added 3 comments

    File media/audio/audio_output_device_thread_callback.cc
    Line 76, Patchset 12: .duration = base::Microseconds(cur_cumulative_glitch_duration_us -
    prev_cumulative_glitch_duration_us),
    Olga Sharonova . resolved

    How do we ensure it's monotonic?

    Fredrik Hernqvist

    Added DCHECKs. I am reluctant to use CHECKS here, because they will crash if the counters overflow when incrementing (we have had such a bug before), and that is much worse for the user experience than getting wrong numbers in the glitch stats.

    Olga Sharonova

    How do we actually know it will be monotonic and logic like start/stop or default device change won't mess it up?

    Fredrik Hernqvist
    • This shared memory will only be used by a single AudioOutputDeviceThreadCallback, and a single SyncReader.
    • Both the values in shared memory and the prev_* values are initialized to 0 upon creation.
    • SyncReader is the only one that change the values in shared memory, and it only increases them, thus the values in shared memory are monotonically increasing
    • AudioOutputDeviceThreadCallback reads the monotonically increasing values from the shared memory and stores them in the prev_* variables.
    • Thus both the variables in shared memory and the prev_* variables are monotonically increasing, and the shared memory variables are always at least as large as the prev_* variables.
    • This monotonic logic is constrained to AudioOutputDeviceThreadCallback and SyncReader, so this concern does not exist in the rest of the stack. This means that start/stop or default device change cannot affect it.
    Olga Sharonova

    Thanks. That actually highlights another aspect: we have non-trivial reads and writes of atomics split between two very distant code locations, which makes it hard to maintain the logic. Should we organize some helpers for that and put them together?

    Fredrik Hernqvist

    Good idea, I put the logic in a helper class. How about this?

    Olga Sharonova

    Nice!

    File media/base/audio_parameters.h
    Line 75, Patchset 18 (Latest): AudioGlitchInfo LoadGlitchInfoFromBuffer(AudioOutputBufferParameters& params);
    Olga Sharonova . unresolved

    GetGlitchIncrementSinceLastCall, or something like that?

    Also: do we always use both methods with the same params throughout the helper lifetime?

    Line 69, Patchset 18 (Latest):// living in shared memory.
    Olga Sharonova . unresolved

    It's reading them in a very specific way (diff from the previous call). -could you document that?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Fredrik Hernqvist
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib8f140fd047a8a37431335a7407c5177dfafad02
    Gerrit-Change-Number: 7415120
    Gerrit-PatchSet: 18
    Gerrit-Owner: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Fredrik Hernqvist <fhern...@google.com>
    Gerrit-Comment-Date: Mon, 19 Jan 2026 15:23:39 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages