More findings:
I’m able to build Csound for iOS on my old Intel MacBook Pro with XCode 12.4, but the building doesn’t complete nicely on my M1 MacBook Pro with XCode 14.1 (it doesn’t create libcsound.a), with these logs:
If I don’t modify the two files above I get those errors:
Errors
/Users/giovanni.bedetti/Downloads/csound-6.18.0/iOS/cs6iOS/Csound.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 6.1, but the range of supported deployment target versions is 11.0 to 16.1.99. (in target 'CsoundLib-static' from project 'Csound')
error: The i386 architecture is deprecated. You should update your ARCHS build setting to remove the i386 architecture. (in target 'CsoundLib-static' from project 'Csound')
warning: Run script build phase 'CMake Rules' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'CsoundLib-static' from project 'Csound')
/Users/giovanni.bedetti/Downloads/csound-6.18.0/iOS/cs6iOS/Csound.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 6.1, but the range of supported deployment target versions is 11.0 to 16.1.99. (in target 'ZERO_CHECK' from project 'Csound')
error: The i386 architecture is deprecated. You should update your ARCHS build setting to remove the i386 architecture. (in target 'ZERO_CHECK' from project 'Csound')
warning: Run script build phase 'CMake Rules' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'ZERO_CHECK' from project 'Csound')
**** BUILD FAILED ****
Not sure if I’m getting closer to discover something, but just wanted to flag this.
Will try again later this evening!
Incase my failures are useful - I also tried initialising Csound later, rather than in the Awake, I added a waiting co-routine for 5 secs and then started the initialisation, just incase there was some delay in getting the audio system setup in Unity, but I still got the same crash.
@giovannibedetti Using the supplied “build.sh” in the IOS folder it built without issue for me on an Intel OSX 12.5 / Xcode 13.4.1
One thing I just noticed in the CMake output when building it here:
Building with 32-bit floats
I think it should be 64bit floats on iOS should it not? I think we should be enabling doubles. Modify the build.sh script so that -DUSE_DOUBLE=0 becomes -DUSE_DOUBLE=1 and see what happens. I would try myself but I need to run to class…
Yes the iOS library works pretty much everywhere as it is in the Csound release, I have some apps made using it that are still running on a very old iPad2 so it’s definitely something on the CsoundUnity side.
I pushed the changes about doubles but I still have the crash
The interesting thing is that if I run a development build from XCode it goes into a timeout and never starts
Also if I enable the doubles in the build.sh script it fails
The only sample that runs without crashing is the Csound Test, that doesn’t output any audio but only lists the available opcodes and some other settings. csoundOpcodes.txt (83.0 KB)
In the Csound test sample there is no csd set at all, I could try to make it compile an orchestra maybe, but the Csound object creation is not happening when no csd is set.
No wait it’s not true, just checked, the compilation fails (because the string is empty), but Csound is created and started.
Indeed in the first line of the log file above you can see:
I’m waiting 5 seconds before compiling the orchestra. No crash but no sound.
Edit: Of course there is no crash since Csound is not running and performance is already ended because there was no score.
If I create an empty csd with no instruments and only a f0 3600 in the score section I have the crash:
<Cabbage> bounds(0, 0, 0, 0)
form caption(“Test”) size(700, 300), guiMode(“queue”), pluginId(“test”)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 1
nchnls = 2
0dbfs = 1
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 3600
</CsScore>
</CsoundSynthesizer>
The crash happens as soon as the initialization finishes, that is when Csound starts executing its cycles.
This should be the source of the memory allocate failure log:
I’m able to launch a basic scene in the iPad emulator from Xcode without any crashes using your ios-hotfix branch. But I’m getting no sound. At least I’m set up to help now.
Great!
I haven’t tried running on the simulator (but it should work fine on M1 macs).
The issue is that no allocation of memory is happening, probably because of the size of MYFLT (it’s the first thing that can fail in kperf_nodebug, the calls to memset).
I will have some time to be on it again only on Sunday!
But keep us posted with your findings