-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SF2 hangs on open (Apple) #649
Comments
Im not sure if this is related, but everytime i load a soundfont on linux i get this ( non fatal ) warning CRITICAL **: fluid_synth_sfont_unref: assertion `sfont_info != NULL' failedperhaps related to the fluidsynth lib files? or within LMMS itself? Date: Sat, 26 Apr 2014 09:26:22 -0700 Software freezes and causes the user to "Force Quit" when opening a project with Soundfonts. The soundfont player works if added manually, but when reopening the project, the software hangs. — |
We've omitted some items for now due to some incompatible coding standards. I haven't dove too much into those messages yet. Edit: The LADSPA stuff has since been corrected and pushed upstream to Steve Harris's GitHub repo. It was the same _init() and _fini() bug that affected the tap plugins. |
Some pthread specific information for OSX which may be useful: |
A slightly better stacktrace containing more debug symbols: |
@mikobuntu after some observations of outstanding SF2 bugs, I do believe this is related to the errors you are seeing. It appears something is not initializing properly but I still cannot find it. Will continue searching. :) |
Possible duplicate of this bug report (stack overflow) |
Another bug report from 2006 which claims to have been resolved with a source code update. Seems to crash on a similar mutex lock area while initializing the fluidsynth settings. Interestingly enough, I did a similar snippet with @tobydox how would we go about trying out some of the upstream patches? Would this cause issues on the OSs which bundle fluidsynth (i.e. Linux)? Mostly concerned with #1238 although Mac support would be an added bonus if the bugs are related. |
Unfortunately, commit 240c0b2 does not fix this bug. Apple SF2 support will remain disabled on |
Had a look at the backtrace (from 2014-06-05), and... why is libfluidsynth calling into CoreAudio? AFAIK it shouldn't be doing any audio output to anywhere besides LMMS.
|
Well, I'm not explicitly linking against any CoreAudio files in the bundle, so I think it's a problem with a mutex lock, but I'm not very good with debugging these things... The closest thing I could find for an explanation is here: I don't know if it matters, but this doesn't crash every time if the instrument is added manually. I can get the instrument to add to a track and get SF2 playback about 50% of the time. However on project load, it crashes each time. Also, if I change the output device to DummyAudio, it doesn't crash either. -Tres |
This looks like an identical crash: http://www.juce.com/forum/topic/coreaudio-possible-deadlock-when-moving-mavericks So, SDL or PortAudio uses CoreAudio, and when libfluidsynth goes about using it as well, a deadlock happens if the timing is right. I'm leaning strongly towards this being a libfluidsynth bug. Think I'll file an issue for this over at SF.net and see what the Fluid people have to say on the subject. |
On 01/16/2015 08:12 PM, Raine M. Ekman wrote:
Hm... yet another reason to roll our own soundfont player? |
Hey!... That same bug is in my original post. :) |
Right, must've been a case of scrolling blindness on my part. |
or TL;DR on my part 🍰 |
@tresf, I never got around to filing an issue, but revisiting this now I have an idea. Could you try adding a line:
right after |
Ok.. I took the line back out and it's not crashing... I'm not sure how conclusive these findings are now. 😿 Edit: I installed on native hardware and the bug still exists with the recommended patch, still hangs at 83%. Not sure why the Lion VM doesn't encounter this crash (I would suspect it's sound driver related). Also, adding the instrument manually seems to be stable, it's project load that is causing the reproducible crash. |
Me too. And that's the direction the earlier backtraces point as well.
Can you load a project containing only one SF2 track or does that crash too? |
Finally found the JUCE commit that addressed this lock problem. juce-framework/JUCE@2682871#diff-80c212bebcf9de54a837d1e31270ca70R371 The problems seems to stem from a lock on CoreAudio ( Chromium suffered a similar problem here. The description is identical to what's the the backtrace. I don't believe Chrome ever fixed the problem, they just removed the feature from Mac. The description:
Can someone point me in the right direction? Does this need to be fixed inside |
This looks like a FluidSynth problem. Generic initialization triggers CoreAudio initialization. Since we do not need CoreAudio for the plug-in, this should be avoided, but there is currently no way unless we build FluidSynth without CoreAudio. |
I hope it can be circumvented if that statement is true. FluidSynth has been stale for almost 2 years which puts this bug in a bad position.
I'm interested what drives the assumption that CoreAudio is not needed for the plugin on Mac. If the soundcard is switched to Dummy Audio, the bug goes away, so there's something it uses from CoreAudio. Furthermore, instantiating the plugin from the GUI it crashes occasionally whereas on project load it crashes every time. Are there any techniques that can be used to force synchronization for this plugin loading when on Mac? |
Their mailing list is active. Do we wait until fixed versions are released?
The plug-in does not need to talk to any audio driver on Mac, Linux or other OS.
These look like different problems that should be addressed separately.
Do you mean that the plug-in should use some sort of synchronization with CoreAudio? The plug-in should not call any audio driver. |
Repeating the same words over and over without explaining why doesn't help. From everything I'm reading as well as previous bug-hunting on Mac, this is a threading problem causing the crash. Whether or not it SHOULD be talking to CoreAudio is an architectural question about the library -- one I'm not going to tackle. My question was really hoping for a threaded work-around.
We normally get fluidsynth from repos, so yes. Although it is good to see activity on the fluidsynth mailing list, the state of the bug tracker is not as promising. For example... a basic MSVC++ pull request has been open for 2 years. Anyway... Homebrew can handle custom formulae so if we do fork and patch this library, it would be trivial to shim the steps into our build procedures. I'm not familiar enough with the library to write this patch, but I'd be very happy to write the procedures around it. |
In both instances the crashes occur during plugin initialization. Since the crash occurs due to a race condition with the mutex inside CoreAudio I believe the crashes to be directly related to each other. According to the JUCE article, the callback which returns after getting the hardware information makes an assumption about what thread it is being run on. I'm not an expert on threads in C++, but I've seen these crashes happen with other apple calls in other projects and they generally come down to threading, fixed by calling everything from the same thread. |
Sf2 Player should not call to CoreAudio, ALSA, PortAudio, etc. Plug-in should deliver data to LMMS core, which is the one that calls CoreAudio, ALSA, etc. If LMMS core locks CoreAudio, Sf2 Player will hang if it tries to lock CoreAudio too. I do not understand what a threaded work-around is supposed to do.
You only need to configure with |
Fixes the crash, but the command is off a bit... # download and extract fluidsynth
mkdir build target
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../target -Denable-coreaudio=off -Denable-framework=off
cp ../target/lib64/libfluidsynth.1.5.2.dylib /path/to/LMMS.app/Contents/Frameworks/libfluidsynth.1.dylib
I'll see if I can script this into the installation script and finally close this out. |
PR is ready. #3446 |
* Add SF2 support for macOS Closes #649
Please consider using fluid_audio_driver_register() for a runtime solution which audio drivers to initialize during |
@derselbst thanks. This feature is new with 1.1.9 so I think we'll have to do some version detection. Is it sufficient to simply pass an empty array? |
You can use the FLUIDSYNTH_VERSION_* macros.
In order to deregister all of fluidsynth's audio driver, yes: |
Thanks, we'll get this added. Edit: PR is ready: #4300 |
* Add SF2 support for macOS Closes LMMS#649
Software freezes and causes the user to "Force Quit" when opening any project with at least one soundfont .
The soundfont player works if added manually, but when reopening the project, the software hangs on a dialog that says "Opening project" usually around 70-80% with the spinning wheel which never goes away.
The screenshot below (sorry, not ver descriptive) is the screen that the user will see when the freeze occurs. The default project is loaded in the background while the "Opening project" screen appears and then the pinwheel appears and the software has crashed.
Possibly related: http://www.juce.com/forum/topic/coreaudio-possible-deadlock-when-moving-mavericks
Backtrace:
https://gist.github.com/tresf/230b20f083403a11a3c7
The text was updated successfully, but these errors were encountered: