Csound doesn’t seem to be null since calling ‘some’ methods work.
I tried calling performKsmps after csoundStart, it crashes!
EDIT It works on editor (so on Windows), returning 0.
CsoundUnity Package (UPM) development
Right. I think we might need to file an issue on github. I can’t think what the problem might be. We don’t have any way of debugging this do we?
It’s the call to the native code that crashes, I can try to put some breakpoints and see, but I cannot debug the .so lib
But wouldn’t a call to any of the native method crash it also?
I don’t have a clear view on this, I discovered this morning that the Csound test was working, so GetOpcodeList() and GetNamedGens() work!
The simple test we do for errors in the csd file?
Now the Csound test in the Samples is just this:
Right, so calls to the library seem to be working fine UNTIL we call performKsmps()
? I’m afraid that doesn’t really help much does it
We know it used to work with earlier versions of Csound/Unity? I wonder if you might try an earlier version of Csound? It would make things easier if we can identify when things went south?
I did some tests with the older libraries (version 6.12), but I have the same crash as when using version 6.15.
The crash occurs as soon as PerformKsmps method is called (now it’s right after start):
int ret = Csound6.NativeMethods.csoundCompileCsdText(csound, csdFile);
Csound6.NativeMethods.csoundStart(csound);
compiledOk = ret == 0 ? true : false;
Debug.Log("csoundCompile: " + compiledOk);
Debug.Log($"started Csound version {GetVersion()}, API Version: {GetAPIVersion()}");
/// CRASHES HERE
var res = PerformKsmps();
/// THIS IS NEVER PRINTED
Debug.Log("PerformKsmps: " + res);
EDIT: This is the csound address right before the crash:
EDIT:
the crash occurs when setting memory?
at libc.memset(memset:48)
at libcsoundandroid.kperf_nodebug(kperf_nodebug:210)
at libcsoundandroid.csoundPerformKsmps(csoundPerformKsmps:70)
I think that might be enough info to post an issue on the Csound github tracker? Now, I’m expecting a few people to get back to us and say that CsoundAndroid is working fine, so the problem must be with Unity. I wonder should we prepare a simple CsoundAndroid app first to check? Without Unity?
The same calls on Android work fine, I’ll do some tests but everything seems good there.
I’ll try to test the basic scene on other Android devices, but I don’t think it will make a difference.
EDIT: same crash on android 6.0.1, 7 and 8.1.
I could also open an issue on the Unity bug reporting.
I had a look at the csound code, could the size of MYFLT be the cause of the crash?
It should be 32bit float on Android. That’s definitely something to check.
Here is a post on the Csound forum:
So the good news is that everything works perfectly on 64 bit devices!
The bad news is that is not clear why it doesn’t work on 32 bit devices
I should open a ticket in Unity issue tracker
Good news! We discovered a Unity bug!
So sooner or later the Csound macOS .framework will work as expected on Unity
You can vote for it to be solved here: https://issuetracker.unity3d.com/issues/macos-dll-inside-a-custom-plugin-cannot-be-found-when-using-a-dot-framework-extension
Voted, and nice work! Fair play for seeing this through to the bitter end
We have a working macOS build now! big thanks to the Unity Desktop Editor Team for the support!
For now it works on 2019.4 and later, I just asked if they can fix older versions.
The solution suggested by them was to convert the .framework into a .bundle.
I already uploaded the .bundle to the repo.
Here is the shell script that converts a macOS .framework into a .bundle (to be run in the folder where CsoundLib64.framework is):
#!/bin/bash
cp CsoundLib64.framework.meta CsoundLib64.bundle.meta
mkdir -p CsoundLib64.bundle/Contents/MacOS
cp CsoundLib64.framework/Versions/Current/CsoundLib64* CsoundLib64.bundle/Contents/MacOS
cp CsoundLib64.framework/libs/* CsoundLib64.bundle/Contents/MacOS
install_name_tool -change @loader_path/../../libs/libsndfile.1.dylib @loader_path/libsndfile.1.dylib CsoundLib64.bundle/Contents/MacOS/CsoundLib64
install_name_tool -id CsoundLib64 CsoundLib64.bundle/Contents/MacOS/CsoundLib64
rm CsoundLib64.framework.meta
rm -rf CsoundLib64.framework
cat > CsoundLib64.bundle/Contents/Info.plist << EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>CsoundLib64</string>
<key>CFBundleIdentifier</key>
<string>com.csound.CsoundLib64</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>CsoundLib64</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
EOL
Nice one. So that’s Windows. MacOS and Unity now working out of the box? I’ve not been using Unity at all since the late summer. I find myself leaning towards BablyonJS at the moment. But that might change in the new year as I might have to teach some Unity. That would be nice!