Birch-san / juicysfplugin

Audio plugin (e.g. VST, AU) to play soundfonts on macOS, Windows, Linux
GNU General Public License v3.0
227 stars 29 forks source link

2.3.0 Release crashes FL Studio Mac #8

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi birch, just wanted to say that I greatly appreciate your work on this plugin- It is a god send for working with sound fonts on the Mac. However, 2.3.0 is crashing FL Studio for me. I have tried the Audio Unit, the VST and the VST3. The AU and VST will detect and allow selection in FL Plugin Manager / Plugin Picker but will crash the program at the step "Loading Fruity Wrapper". The VST3 will not allow for selection, FL Plugin Manager returns "error" and will not attempt to load the plugin.

The plugin seems to be working fine in Ableton 10.1 though.

juicysf 2.3.0 FL Studio 20.5.1 build 522 macOS Mojave 10.14.6

Birch-san commented 5 years ago

thanks for telling me. I'd been doing all my testing in JUCE's audio plugin host, so I missed this. FL Studio is the most important DAW, so definitely need to get this working.

the issue reproduces for me also; I've tried adding an instance of the AU plugin to an FL Studio project. A white rectangle is rendered, mouse cursor beachballs.

I've attached a debugger to OsxFL, and I've hit "pause" on program execution to see where it's hung:

image

It gets to the first line of initialising FluidSynthModel, and hangs whilst trying to allocate a new_fluid_settings(). specifically it's waiting to acquire some kind of mutex. fluid_audio_settings is nearby, so I wonder whether this is the same deadlock that we had on the previous version of FluidSynth (FL Studio wants exclusive access to CoreAudio, so fluidsynth waits forever).

Birch-san commented 5 years ago

if indeed this is the same deadlock, then this is how I fixed it last time:

// deactivate all audio drivers in fluidsynth to avoid FL Studio deadlock when initialising CoreAudio
// after all: we only use fluidsynth to render blocks of audio. it doesn't output to audio driver.
const char *DRV[] {NULL};
fluid_audio_driver_register(DRV);

I've just now tried shuffling that line up by one so that it occurs before we attempt to create new_fluid_settings(), but that didn't help. maybe a different workaround is needed in FluidSynth2.

pretty much all configurability of fluidsynth requires that you first succeed in creating a settings object. we're a bit constrained because we can't even get as far as that.

Birch-san commented 5 years ago

okay yeah; it's the same deadlock as we had in fluidsynth1:

image

inside new_fluid_settings() fluidsynth invokes fluid_core_audio_driver_settings() to configure a default audio driver (which we don't want anyway). it tries to ask how many outputs the driver has, but FL Studio has a lock on the audio object, so we have to wait (forever) to get our answer.

I wonder why the usual trick (asking to disable all audio drivers) has stopped working in fluidsynth2.

Birch-san commented 5 years ago

oh, actually: my fix did work (moving the audio driver deregistration code). the only problem was that I wasn't doing a sufficiently clean build.

image
Birch-san commented 5 years ago

@lrcaldwell please tell me whether release 2.3.1 is working any better for you.

ghost commented 5 years ago

@Birch-san 2.3.1 is now working in FL, still works in Ableton too. Thank you!~