ExistentialAudio / BlackHole

BlackHole is a modern macOS audio loopback driver that allows applications to pass audio to other applications with zero additional latency.
GNU General Public License v3.0
15.26k stars 590 forks source link

Buffer Overflow when connecting, disconnecting, then connecting to BlackHole input again. #54

Closed jonnyg9 closed 4 years ago

jonnyg9 commented 4 years ago

In Ableton, if I set the input to device to BlackHole for the first time it works great. If I set the input device to something else, then set the input device to BlackHole again, BlackHole crashes with a Buffer Overflow.

Ableton handles it gracefully and defaults to no input device. If you try to connect to it again it works fine. (maybe because BlackHole restarts?) But there is a crash every second time you try to reconnect to BlackHole input device.

The same thing happens when you connect to BlackHole input in Ableton, close Ableton, then open Ableton again (and it tries to reconnect to BlackHole as input).

This is reproducible with Audacity as well. (I have to run Audacity from terminal as sudo for some reason). The trick to reproduce with Audacity is to actually record BlackHole once, close and reopen Audacity, then record again.

Are we not cleaning memory properly when we stop IO?

Thanks for making this!

System Info: MacOS Catalina 10.15.3 Audacity 2.3.3 Midi setup: midi setup

devinroth commented 4 years ago

Could you give me the core audio logs when this happens?

On Feb 7, 2020, at 2:59 PM, jonnyg9 notifications@github.com wrote:

 In Ableton, if I set the input to device to BlackHole for the first time it works great. If I set the input device to something else, then set the input device to BlackHole again, BlackHole crashes with a Buffer Overflow.

Ableton handles it gracefully and defaults to no input device. If you try to connect to it again it works fine. (maybe because BlackHole restarts?) But there is a crash every second time you try to reconnect to BlackHole input device.

The same thing happens when you connect to BlackHole input in Ableton, close Ableton, then open Ableton again (and it tries to reconnect to BlackHole as input).

This is reproducible with Audacity as well. (I have to run Audacity from terminal as sudo for some reason). The trick to reproduce with Audacity is to actually record BlackHole once, close and reopen Audacity, then record again.

Are we not cleaning memory properly when we stop IO?

Thanks for making this!

System Info: MacOS Catalina 10.15.3 Audacity 2.3.3

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jonnyg9 commented 4 years ago

Here is the crash report: coreaudiodCrash.txt

devinroth commented 4 years ago

I think I’ve come across this before. Is there still an issue if you use BlackHole without using a multi output? What about using a multi output without blackhole?

jonnyg9 commented 4 years ago

It seems to fail in a similar way without using multi output. I restarted my system after deleting the multi output device.

Midi Setup: blackhole_default_out_no multioutput

Crash Log: coreaudiodCrash_noMultiOutput.txt

Multi output without blackhole seems fine.

devinroth commented 4 years ago

I’ll look into it.

quantuminformation commented 4 years ago

recently I've not been able to get it to work at all, is there an upgrade to lastest version doc?

devinroth commented 4 years ago

@QuantumInformation related to this issue or a new one?

quantuminformation commented 4 years ago

I'm not getting an error as such but when using the same settings as in my Garage band setup, I am unable to get any audio to pass through to my headphones or be picked up by GB.

Must be something on my machine as there is no BH auto update.

devinroth commented 4 years ago

@QuantumInformation I'm unsure if it's related. Does it work normally after restarting?

devinroth commented 4 years ago

@jonnyg9 I'm able to reproduce your bug on my machine. Probably related https://github.com/ExistentialAudio/BlackHole/issues/52 and possibly https://github.com/ExistentialAudio/BlackHole/issues/36. Thanks for noticing this. I'll hopefully figure it out over the next week.

jonnyg9 commented 4 years ago

@QuantumInformation I had a similar issue at one point and toggling the Use column on the devices off and on again in the multi-output device sorted it out for me. I am not sure how to reproduce.

devinroth commented 4 years ago

@QuantumInformation The multi-output and aggregate devices have their own separate issues. Most companies recommend avoiding them. @jonnyg9's trick does seem to fix that issue. Ultimately I plan on bypassing the multi-output altogether. Hopefully that helps.

quantuminformation commented 4 years ago

Tried that no luck, sounds good devin.

Why do we even need to use the multi out device and not just headphones?

I understand aggregate input

quantuminformation commented 4 years ago

It also causes the audio from other programs to stop, ie youtube

image

image

also funny how I can't change anything here image

devinroth commented 4 years ago

BlackHole can’t the first in the list. Toggle it on and off and it will solve your problem.

On Feb 8, 2020, at 10:41 AM, Nikos notifications@github.com wrote:

 It also causes the audio from other programs to stop, ie youtube

also funny how I can't change anything here

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

devinroth commented 4 years ago

@jonnyg9 I was able to reproduce the bug in Logic, Pro Tools, Cubase, Audacity. Unfortunately I don't have Ableton but it'll be fine since I have a good idea of what's happening. Logic by far deals with the issue the best since nothing actually happens except it spits a message to the console and just reconnects. Cubase just pops up a message a connectivity issue error for a split second and then reconnects. Seems like the other programs don't handle it as gracefully. Honestly I'm surprise it's taken this long for anyone to notice this bug. Hopefully I'll get it all sorted out this week. If you can it would be great if you can test in Ableton once I figure it out.

devinroth commented 4 years ago

@jonnyg9. Fixed!!! Are you able to test it out? I created a new dev branch.

jonnyg9 commented 4 years ago

@devinroth Dev looks good in Ableton; I think you got it. Nice fix!