• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Crashes in HALPropertyListener_Call_Helper when using property listeners in threaded code.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Crashes in HALPropertyListener_Call_Helper when using property listeners in threaded code.


  • Subject: Crashes in HALPropertyListener_Call_Helper when using property listeners in threaded code.
  • From: Dale Curtis <email@hidden>
  • Date: Tue, 05 Feb 2013 17:45:09 -0800

Hi all,

Chrome is hitting a lot of crashes in HALPropertyListener_Call_Helper which appear to be due to the usage of property listeners and CoreAudio calls to the listener address on threads other than the main thread. A lot in this case is ~25% of all Chrome Mac crashes.

The tl;dr question is: When property listener callbacks are used, is it safe to call CoreAudio methods addressed for the same property from a different thread? Specifically on a thread other than the main thread.

The details; the two threads in question are:
- The main process thread: BrowserMainThread. Has a CFRunLoop. Creates the AudioThread.
- The thread on which CoreAudio methods are called and property listeners created: AudioThread.

The property we're listening for changes to:
// Property address to monitor for device changes.
const AudioObjectPropertyAddress kDefaultOutputDevicePropertyAddress = {
  kAudioHardwarePropertyDefaultOutputDevice,
  kAudioObjectPropertyScopeGlobal,
  kAudioObjectPropertyElementMaster
};

When we receive the property change event:
- We send an asynchronous message to the AudioThread indicating it should handle a device change and exit the property listener handler immediately.
- On the AudioThread we query for the new output device and the new hardware sample rate.

If we don't register any property listeners, we don't see any crashes. However, once we've created a property listener, it's a dice roll with each listener callback until the crash occurs.

The crash itself takes place in BrowserMainThread while AudioThread issues an AudioObjectGetPropertyData for the same kDefaultOutputDevicePropertyAddress used by the listener.  See http://crbug.com/158170 for more details.

On 10.6 everything works correctly once we set kAudioHardwarePropertyRunLoop to point to the CFRunLoop owned by AudioThread.

On 10.7 kAudioHardwarePropertyRunLoop appears broken and in 10.8 looks deprecated, so we've attempted to use the new AudioObject(Add|Remove)PropertyListenerBlock methods and replace AudioThread with a dispatch queue. Sadly, this doesn't work either and we're still seeing the same crashes.

The one thing that has resolved all crashes on 10.7+ is to move all CoreAudio calls onto the BrowserMainThread; however that has non-trivial implications for Chrome, so we'd prefer to avoid doing that.

Any pointers would be appreciated. If this sounds like a bug, I'll refile as appropriate.

Thanks in advance!

- dale

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Crashes in HALPropertyListener_Call_Helper when using property listeners in threaded code.
      • From: Dale Curtis <email@hidden>
  • Prev by Date: Re: AudioQueueProcessingTap broken in 6.1? (was: Re: NewTimePitch Audio Unit Distorts Signal)
  • Next by Date: Re: A number of simple questions (still a few unanswered)
  • Previous by thread: Re: Recording and streaming in a HAL plugin/driver
  • Next by thread: Re: Crashes in HALPropertyListener_Call_Helper when using property listeners in threaded code.
  • Index(es):
    • Date
    • Thread