Closed Bug 1629839 Opened 5 years ago Closed 4 years ago

Crash in [@ cubeb_coreaudio::backend::buffer_manager::BufferManager::push_silent_data]

Categories

(Core :: Audio/Video: cubeb, defect, P1)

76 Branch
x86_64
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla77
Tracking Status
firefox-esr68 --- unaffected
firefox75 --- unaffected
firefox76 --- fixed
firefox77 --- fixed

People

(Reporter: achronop, Assigned: padenot)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: crash, regression)

Crash Data

Attachments

(4 files)

This bug is for crash report bp-3d1796a9-b704-4049-abed-1ff470200413.

Top 10 frames of crashing thread:

0 XUL RustMozCrash mozglue/static/rust/wrappers.cpp:17
1 XUL mozglue_static::panic_hook mozglue/static/rust/lib.rs:89
2 XUL core::ops::function::Fn::call src/libcore/ops/function.rs:72
3 XUL std::panicking::rust_panic_with_hook src/libstd/panicking.rs:475
4 XUL rust_begin_unwind src/libstd/panicking.rs:375
5 XUL core::panicking::panic_fmt src/libcore/panicking.rs:84
6 XUL core::panicking::panic src/libcore/panicking.rs:51
7 XUL cubeb_coreaudio::backend::buffer_manager::BufferManager::push_silent_data third_party/rust/cubeb-coreaudio/src/backend/buffer_manager.rs
8 XUL cubeb_coreaudio::backend::audiounit_output_callback third_party/rust/cubeb-coreaudio/src/backend/mod.rs:615
9 CoreAudio CoreAudio@0xca1e 

Crashing here https://doc.rust-lang.org/src/core/slice/mod.rs.html#1081.

Looks like we're requesting more input data than INPUT_BUFFER_CAPACITY. I think this can happen with the following setup:

Input stereo at 192kHz (for example on an external professional sound card, this is pretty common), output at 44.1kHz, IO buffer size at 512 frames (because we're doing a WebRTC call with AEC on)

If we don't have input data, we need to push:

>>> (192000 / 44100.)  * 512 * @
4458.231292517007

frames, which is bigger than out limit of 4096.

Bumping this twofold in size would make it work in this scenario, but one could have even more channels than stereo (I think we support it the days).

Chunmin, do we support more than stereo input?

Flags: needinfo?(cchang)

(In reply to Paul Adenot (:padenot) from comment #1)

Chunmin, do we support more than stereo input?

cubeb-coreaudio doesn't check the input settings inside so we follow the general cubeb policy here: The valid input channel range is from 1 to 8(included).

Crashing here https://doc.rust-lang.org/src/core/slice/mod.rs.html#1081.

Looks like we're requesting more input data than INPUT_BUFFER_CAPACITY. I think this can happen with the following setup:

Input stereo at 192kHz (for example on an external professional sound card, this is pretty common), output at 44.1kHz, IO buffer size at 512 frames (because we're doing a WebRTC call with AEC on)

If we don't have input data, we need to push:

>>> (192000 / 44100.)  * 512 * @
4458.231292517007

frames, which is bigger than out limit of 4096.

An alternative approach is appending the silence data in the LinearInputBuffer, which can happen when the needed_samples is greater than the samples we have in the buffer, so we don't need to worry about the size of BufferManager. The LinearInputBuffer is a Vec<T> so its size can grow as it needs until the process is out of memory. What do you think?

Flags: needinfo?(cchang)

Bump the priority to P1 since it could cause difficulties to use WebRTC, which is the top priority in this time.

Priority: -- → P1
Assignee: nobody → padenot
Blocks: 1530713
Depends on: 1631448
Attached file GitHub Pull Request

The fix will be imported via bug 1631448

The fix is imported in bug 1631448

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77

This also fixes 1628411 on 76.

Patches below (sha from upstream:
https://github.com/ChunMinChang/cubeb-coreaudio-rs/)

commit e8b8a052d8ce716c6a6f846d3a6fd4deea2d5ed8
Author: Paul Adenot <paul@paul.cx>
Date: Thu Apr 16 18:13:34 2020 +0200

Don't really push silence to the ring buffer (#86)

commit b49264bfce977b5ab3e84fb246235845f6720a6b
Author: Chun-Min Chang <chun.m.chang@gmail.com>
Date: Thu Apr 9 13:29:24 2020 -0700

Remove unknown devices when querying devices in scope (#81)

BMO 1628411 shows we might get some devices whose `AudioObjectID` is
`kAudioObjectUnknown`. Not sure if it's normal but we can simply remove
them from the scoped-device list when it happens.

commit 27cf89ef920d1968c06e45f2a7903725d6b635cd
Author: Paul Adenot <paul@paul.cx>
Date: Thu Apr 9 20:22:50 2020 +0200

Always pass all of the buffered input in the resampler (#79)

Depends on D72420

Attached patch uplift-76.patchSplinter Review

Ryan, this contain both fixes (bug 1628411 and bug 1629839).

Flags: needinfo?(ryanvm)

Comment on attachment 9143163 [details] [diff] [review]
uplift-76.patch

Beta/Release Uplift Approval Request

The first crash occurs when users have a changed their audio preferences from the default to something else with either a high sample-rate or a high-channel count (or both). This doesn't necessarily need special hardware. The second one occur with setups we don't know about, so we side-step an assert and skip a device when doing a specific operation on the list of device present on the machine.

  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This has baked on Nightly for some time, and is the minimum amount of code possible to fix those without drifting away too much from what has been proven to work in Nightly. I've built a beta locally and re-did the scenario I did when fixing bug 1629839.

(The other one is even less risky and we don't know how to test, it likely require special hardware/software/configuration).

  • String changes made/needed:
Attachment #9143163 - Flags: approval-mozilla-beta?
Comment on attachment 9143163 [details] [diff] [review] uplift-76.patch Fixes some cubeb crashes. Approved for 76.0rc1.
Flags: needinfo?(ryanvm)
Attachment #9143163 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: