Ableton / LinkKit

iOS SDK for Ableton Link, a new technology that synchronizes musical beat, tempo, and phase across multiple applications running on one or more devices.
http://ableton.github.io/linkkit
Other
147 stars 10 forks source link

Crash when attempting to enable or disable Link, possible race condition? #47

Closed crelseyce closed 2 years ago

crelseyce commented 6 years ago

We've implemented Link with an openFrameworks based app that uses ofxPd and ofxPof. We're encountering a crash that can be easily replicated using the example patch included in the attached zip. The patch uses the abl_link~ and pof externals which can be installed via Deken using vanilla Pd-0.48-1 on macOS or Linux.

In the example patch, a pofutil object is checking connection every second in order to make it simple to trigger the crash by clicking the toggle attached to the connect message sent to abl_link~. It only takes a few clicks to crash. If you disable the metro banging pofutil to stop the connection check, the crash will not occur.

Antoine (ofxPof) has done some fairly extensive testing and feels this is likely a race condition with Link. The crash occurs the same on all platforms we've tested so far, including iOS with libPd, Pd 0.48-1 or earlier on macOS and Linux, and can be triggered with or without the abl_link~ external included on iOS. On iOS the crash is triggered by toggling Link on/off with ABLLinkSettingsViewController instead of sending a connect message to abl_link~ in the Pd patch.

I know this is a bit of an edge case but any help would be appreciated, thanks!

linkpofcrash.zip

cdi-ableton commented 6 years ago

Thanks for filing this issue and attaching the PD-patch. For now, I tried it on MacOS and can reproduce the crash. I'll look into it the next days.

cdi-ableton commented 6 years ago

We're still in the middle of the investigation but wanted to share some observations we made so far:

This crash is coming from Poco which is used by [pofutil] for networking (Check out the attached patch and backtrace).

If or how this is related to the original crash, we can't tell, yet.

potutil_crash.zip

crelseyce commented 6 years ago

Thanks for the help, I appreciate it. We get the same results regarding pofutil, the crash only occurs if pofutil is downloading.

I'm not getting a crash when quitting Pd with your modified patch without abl_link~, but will test on other machines, so far I've only tested on 10.12.6 with Pd 0.48-1. I will also pass this on to Antoine.

crelseyce commented 6 years ago

Following up on this, Antoine is getting the same results on Linux, no crash with the modified patch on its own. However, if we try to create/destroy an abl_link~ object inside the modified patch a few times, the crash happens consistently. (Create an abl_link~ object, copy it, then delete/paste a few times to trigger the crash.)

Antoine suggested perhaps the difference here is that you may have abl_link~ configured to pre-load by default in Pd preferences, causing the crash on quit?

cdi-ableton commented 6 years ago

Interesting that you cannot reproduce the crash. I checked the preferences and there is no library loaded on startup. Also, the crash-on-quit doesn't occur with an open patcher solely containing a [abl_link~] object that is connected. I tried it on a different machine running Ubuntu 17.10 and Pd 0.48.0 with pof-v0.1.8 installed via "Find externals". Unfortunately, it's not even possible to add [declare -lib pof] to a patcher without Pd crashing. All paths are set correctly.

crelseyce commented 6 years ago

Yes it's very weird I don't get the crash with the modified patch unless [abl_link~] is involved, I also don't get a crash if I add [declare -lib pof] to a patcher. (macOS 10.12.6)

Antoine mentioned that pof may have issues on Ubuntu 17+ as he hasn't tested past 16.4 yet, so he will look into it soon. It will probably be a couple of weeks before we can revisit this as Antoine is on holiday now, but if I find anything noteworthy in the meantime I'll update here. Thanks again for your help.

cdi-ableton commented 2 years ago

Please re-open the issue if it's still relevant.