Cabbage Logo
Back to Cabbage Site

CsoundUnity Package (UPM) development

Let me try with this: https://docs.unity3d.com/Manual/AndroidNativePlugins.html
then if I can’t make it work he’s our last hope :sweat_smile:

I tried to understand what to do, but I’m kinda lost… The problem is that the libs are not copied at all inside the apk.
Maybe a hint from Hector would be helpful!
I’ll try again with his .so libs and try to understand why they are copied (I think they are linked somehow with libnative.so)
Maybe I should rebuild the jni libs and link them with libnative.so? :man_shrugging:
Do you think Steven could help?

This are the relevant scripts that build Csound for Android:

I’m sorry but I have no experience with this kind of stuff :sob:

Hector got back to me. He doesn’t think he created libnative.so at all. :laughing:He thinks it did, in which case it is probably just this. We haven’t needed that for some time, so I think libnative.so might be a red herring. Hector said he will take a look and see if he can offer any advise. Fingers crossed.

When you create the package from Unity? Can’t we simply place them there afterwards?

Really? Just the two methods?

:crossed_fingers:

Yeah when I build the apk for Android the libs simply aren’t copied inside it, while with Hector libs are. :man_shrugging:
Yes we can place them there afterwards but the procedure is a bit ugly since the apk has to be unzipped, then rebuilt after the copy, which requires aligning and signing again. Not something the CsoundUnity user would like doing (me too :sweat_smile:)
And at the end, I’m not sure it will work! (I used to do something like this to add some kind of assets to an already compiled application when I didn’t want to reopen an old Unity project)

I see what you mean. Hector wasn’t using the new packages system in his builds was he? Could that have anything to do with it?

No I think not, because it works with the libs that were inside his .unitypackage!
It just crashes as soon as we call GetSpoutSample

Hector was definitely using an older version of Csound than we are.

I think so. Is there method to retrieve the version?

I’m not sure how you might. Steven did mention something some time ago about creating a .aar package for Csound on Android ubt I’m not sure how far he got. One thing we could probably do is remove the calls to GetSpoutSample and SetSpinSample and just use spin/spout pointers instead. We had that working before if I’m not mistaken, but went back to using the GetSpoutSample() methods because they we cleaner. If we did that, then we could probably use Hector’s package. But it leaves us in a bad place for future release.

It should be easier to use the .aar instead of the .so, hope he managed to do it!
Indeed we should have the latest libs also on Android, so that all the platforms use the same API, and avoid having too much platform dependent code.

Finally back on this for a while!
I’m focusing on Android support, the problem we have there is that GetOutputSample crashes with this log:

Crash Log

2021-01-12 13:36:23.838 12537-12616/com.gb.TestCsoundUnity E/mono-rt: =================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
2021-01-12 13:36:23.878 12537-12616/com.gb.TestCsoundUnity E/CRASH: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: Version ‘2020.2.1f1 (270dd8c3da1c)’, Build type ‘Release’, Scripting Backend ‘mono’, CPU ‘armeabi-v7a’
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: Build fingerprint: ‘samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys’
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: Revision: ‘7’
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: ABI: ‘arm’
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: Timestamp: 2021-01-12 13:36:23+0000
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: pid: 12537, tid: 12616, name: FMODAudioDevice >>> com.gb.TestCsoundUnity <<<
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: uid: 10261
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: Cause: null pointer dereference
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: r0 00000000 r1 00000000 r2 00001e34 r3 00000002
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: r4 00000000 r5 c0d9bf70 r6 b7bfe8e0 r7 00000000
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: r8 00000000 r9 b686db88 r10 c50b5830 r11 b7bfe4b0
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: ip bd548fe7 sp b7bfe3a0 lr b758ffb0 pc bd548ff4
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: backtrace:
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #00 pc 001edff4 /data/app/com.gb.TestCsoundUnity-1/lib/arm/libcsoundandroid.so (csoundGetSpoutSample+14) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #01 pc 00003fae anonymous:b758c000
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: managed backtrace:
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #00 (wrapper managed-to-native) csoundcsharp.Csound6/NativeMethods:csoundGetSpoutSample (intptr,int,int)
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #01 CsoundUnityBridge:GetSpoutSample (int,int) <0x27>
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #02 CsoundUnity:GetOutputSample (int,int) <0x2f>
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #03 CsoundUnity:ProcessBlock (single[],int) <0x313>
2021-01-12 13:36:23.879 12537-12616/com.gb.TestCsoundUnity E/CRASH: #04 CsoundUnity:OnAudioFilterRead (single[],int) <0x33>
2021-01-12 13:36:23.880 12537-12616/com.gb.TestCsoundUnity E/CRASH: #05 (wrapper runtime-invoke) :runtime_invoke_void__this___object_int (object,intptr,intptr,intptr)
2021-01-12 13:36:24.070 12537-12560/com.gb.TestCsoundUnity E/CRASH: other thread is trapped; signum = 11
2021-01-12 13:36:24.074 12537-12560/com.gb.TestCsoundUnity E/AndroidRuntime: FATAL EXCEPTION: UnityMain
Process: com.gb.TestCsoundUnity, PID: 12537
java.lang.Error: FATAL EXCEPTION [UnityMain]
Unity version : 2020.2.1f1
Device model : samsung SM-J730F
Device fingerprint: samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys
Build Type : Release
Scripting Backend : Mono
ABI : armeabi-v7a
Strip Engine Code : false

Caused by: java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2020.2.1f1 (270dd8c3da1c)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a'
Build fingerprint: 'samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys'
Revision: '7'
ABI: 'arm'
Timestamp: 2021-01-12 13:36:23+0000
pid: 12537, tid: 12616, name: FMODAudioDevice  >>> com.gb.TestCsoundUnity <<<
uid: 10261
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    r0  00000000  r1  00000000  r2  00001e34  r3  00000002
    r4  00000000  r5  c0d9bf70  r6  b7bfe8e0  r7  00000000
    r8  00000000  r9  b686db88  r10 c50b5830  r11 b7bfe4b0
    ip  bd548fe7  sp  b7bfe3a0  lr  b758ffb0  pc  bd548ff4

backtrace:
      #00 pc 001edff4  /data/app/com.gb.TestCsoundUnity-1/lib/arm/libcsoundandroid.so (csoundGetSpoutSample+14) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
      #01 pc 00003fae  <anonymous:b758c000>

managed backtrace:
      #00 (wrapper managed-to-native) csoundcsharp.Csound6/NativeMethods:csoundGetSpoutSample (intptr,int,int)
      #01 CsoundUnityBridge:GetSpoutSample (int,int) <0x27>
      #02 CsoundUnity:GetOutputSample (int,int) <0x2f>
      #03 CsoundUnity:ProcessBlock (single[],int) <0x313>
      #04 CsoundUnity:OnAudioFilterRead (single[],int) <0x33>
      #05 (wrapper runtime-invoke) <Module>:runtime_invoke_void__this___object_int (object,intptr,intptr,intptr)

    at libcsoundandroid.csoundGetSpoutSample(csoundGetSpoutSample:14)
    at csoundcsharp.Csound6.NativeMethods.csoundGetSpoutSample (intptr,int,int)(Native Method)
    at CsoundUnityBridge.GetSpoutSample (int,int)(0x27:39)
    at CsoundUnity.GetOutputSample (int,int)(0x2f:47)
    at CsoundUnity.ProcessBlock (single[],int)(0x313:787)
    at CsoundUnity.OnAudioFilterRead (single[],int)(0x33:51)
    at <Module>.runtime_invoke_void__this___object_int (object,intptr,intptr,intptr)(Native Method)

So the good thing is that the build includes the libraries (I’m testing this on the latest Unity version), the bad one is that the code we are using inside OnAudioFilterRead doesn’t work on Android:

//if csound nChnls are more than the current channel, set the last csound channel available on the sample (assumes GetNchnls above 0)
var outputSampleChannel = channel < GetNchnls() ? channel : GetNchnls() - 1;
samples[i + channel] = (float)GetOutputSample((int)ksmpsIndex, (int)outputSampleChannel) / zerdbfs;

what can we do? Why the crash?
Is there an alternative method we can use on Android?
I also tried to wait until Csound has finished initialisation, but I always have the crash.

Hi @giovannibedetti. I’m not sure what the problem is. If you replace the calls to GetOutputSample() and return random floats between -1 and 1 does it still crash? Are we certain this is the cause of the crash, or will calls to any CsoundAPI method in the OnAudioFilterRead() method cause a crash?

Good point.
I just tried to remove the call to GetOutputSample on the development project (Unity 2019.3.9f1) and got a crash, so could it be something related with FMOD?

Crash log

2021-01-12 15:09:44.744 20592-20624/? I/Unity: SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 8, Memory = 2816mb
2021-01-12 15:09:44.744 20592-20624/? I/Unity: SystemInfo ARM big.LITTLE configuration: 8 big (mask: 0xff), 0 little (mask: 0x0)
2021-01-12 15:09:44.745 20592-20624/? I/Unity: ApplicationInfo com.DefaultCompany.CsoundUnity_DevelopmentProject version 0.1 build 71391a27-c272-4398-8edb-5072a91fcf5f
2021-01-12 15:09:44.745 20592-20624/? I/Unity: Built from ‘2019.3/staging’ branch, Version ‘2019.3.9f1 (e6e740a1c473)’, Build type ‘Release’, Scripting Backend ‘il2cpp’, CPU ‘armeabi-v7a’, Stripping ‘Enabled’
2021-01-12 15:09:44.750 2939-5009/? V/WindowManager: Relayout Window{7a90c8ed0 u0 com.DefaultCompany.CsoundUnity_DevelopmentProject/com.unity3d.player.UnityPlayerActivity}: viewVisibility=0 req=1080x1920 WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#80810580 pfl=0x20000 fmt=-3 wanim=0x1030465 vsysui=0x600 needsMenuKey=2 naviIconColor=0}
2021-01-12 15:09:44.755 20592-20592/? D/ViewRootImpl@baee071[UnityPlayerActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -437942272} surfaceGenerationChanged=false
2021-01-12 15:09:44.767 2939-8227/? V/WindowManager: Relayout Window{7a90c8ed0 u0 com.DefaultCompany.CsoundUnity_DevelopmentProject/com.unity3d.player.UnityPlayerActivity}: viewVisibility=0 req=1080x1920 WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#80810580 pfl=0x20000 fmt=-3 wanim=0x1030465 vsysui=0x1706 sysuil=true needsMenuKey=2 naviIconColor=0}
2021-01-12 15:09:44.772 20592-20592/? D/ViewRootImpl@baee071[UnityPlayerActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -437942272} surfaceGenerationChanged=false
2021-01-12 15:09:44.937 20592-20624/? E/Unity: Unable to find libcsoundandroid
2021-01-12 15:09:44.958 20592-20624/? E/Unity: Unable to find libsndfile
2021-01-12 15:09:44.960 20592-20624/? E/Unity: Unable to find libc++_shared
2021-01-12 15:09:44.975 20592-20624/? D/vulkan: searching for layers in ‘/data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm’
2021-01-12 15:09:44.975 20592-20624/? D/vulkan: searching for layers in ‘/data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/base.apk!/lib/armeabi-v7a’
2021-01-12 15:09:45.673 2939-6133/? V/WindowManager: Relayout Window{7a90c8ed0 u0 com.DefaultCompany.CsoundUnity_DevelopmentProject/com.unity3d.player.UnityPlayerActivity}: viewVisibility=0 req=1080x1920 WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#80810580 pfl=0x20000 fmt=-3 wanim=0x1030465 preferredDisplayMode=1 vsysui=0x1706 needsMenuKey=2 naviIconColor=0}
2021-01-12 15:09:45.678 20592-20592/? D/ViewRootImpl@baee071[UnityPlayerActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -437942272} surfaceGenerationChanged=false
2021-01-12 15:09:45.726 2939-5330/? V/WindowManager: Relayout Window{7a90c8ed0 u0 com.DefaultCompany.CsoundUnity_DevelopmentProject/com.unity3d.player.UnityPlayerActivity}: viewVisibility=0 req=1080x1920 WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#80810580 pfl=0x20000 fmt=-3 wanim=0x1030465 preferredDisplayMode=1 vsysui=0x1706 sysuil=true needsMenuKey=2 naviIconColor=0}
2021-01-12 15:09:45.727 19923-19923/? I/[SC]AllowConnectionList: addWhiteList : com.DefaultCompany.CsoundUnity_DevelopmentProject
2021-01-12 15:09:45.733 20592-20592/? D/ViewRootImpl@baee071[UnityPlayerActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -437942272} surfaceGenerationChanged=false
2021-01-12 15:09:46.086 20755-20755/? D/KnoxPackageStateReceiver: received intent Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.DefaultCompany.CsoundUnity_DevelopmentProject flg=0x4000010 cmp=com.samsung.knox.securefolder/.containeragent.KnoxPackageStateReceiver launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } bqHint=1 (has extras) }
2021-01-12 15:09:46.086 20755-20755/? D/KnoxPackageStateReceiver: packageName:com.DefaultCompany.CsoundUnity_DevelopmentProject
2021-01-12 15:09:47.638 20592-20624/? I/Unity: AudioSettings.outputSampleRate: 44100
UnityEngine.Logger:Log(LogType, Object)
CsoundUnity:Awake()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2021-01-12 15:09:47.641 20592-20624/? I/Unity: Updated path:;/Packages/com.csound.csoundunity/Runtime
UnityEngine.Logger:Log(LogType, Object)
CsoundUnity:Awake()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2021-01-12 15:09:47.644 20592-20624/? I/Unity: CsoundUnityBridge constructor from dir: /Packages/com.csound.csoundunity/Runtime csdFile:
form caption (“Basic Test”), size(300, 100)

hslider bounds(0, 0, 300, 50) range(20, 16000, 440, 1, 0.001) valuetextbox(1) channel("freqSlider") value(440) velocity(50)
</Cabbage>

<CsoundSynthesizer>
<CsOptions>
;-n -d -m0d 
;-odac
-n ; -m0d
</CsOptions>
<CsInstruments> 
sr 	= 	44100 
ksmps 	= 	64
nchnls 	= 	2
0dbfs	=	1 

instr 1
a1 oscil .2, chnget:k("freqSlider"), 1
outs a1, a1

endin

</CsInstruments>
<CsScore>
f0 3600
f1 0 4096 10 1
i1 0 5
</CsScore>
</CsoundSynthesizer>

UnityEngine.Logger:Log(LogType, Object)
CsoundUnityBridge:.ctor(String, String)
CsoundUnity:Awake()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2021-01-12 15:09:47.679 20592-20624/? I/Unity: System buffer size: 1024, buffer count: 4 , samplerate: 44100
UnityEngine.Logger:Log(LogType, Object)
CsoundUnityBridge:.ctor(String, String)
CsoundUnity:Awake()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2021-01-12 15:09:47.716 20592-20624/? I/Unity: csoundCompile: True
UnityEngine.Logger:Log(LogType, Object)
CsoundUnityBridge:.ctor(String, String)
CsoundUnity:Awake()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2021-01-12 15:09:47.724 20592-20624/? I/Unity: zerdbfs 1
UnityEngine.Logger:Log(LogType, Object)
CsoundUnity:Awake()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2021-01-12 15:09:47.729 20592-20624/? I/Unity: CsoundUnity done init
UnityEngine.Logger:Log(LogType, Object)
CsoundUnity:Awake()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
2021-01-12 15:09:47.849 20592-20700/? E/CRASH: pid: 20592, tid: 20700, name: FMODAudioDevice  >>> com.DefaultCompany.CsoundUnity_DevelopmentProject <<<
2021-01-12 15:09:47.849 20592-20700/? E/CRASH:       #01 pc 001ecba3  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libcsoundandroid.so (kperf_nodebug+210) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
2021-01-12 15:09:47.849 20592-20700/? E/CRASH:       #02 pc 001edbab  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libcsoundandroid.so (csoundPerformKsmps+70) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #03 pc 00609b5c  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #04 pc 00607df8  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #05 pc 00176d80  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #06 pc 0010f540  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #07 pc 00129205  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #08 pc 0013242b  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #09 pc 0005fe31  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
2021-01-12 15:09:47.850 20592-20700/? E/CRASH:       #10 pc 0042129b  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
2021-01-12 15:09:48.403 20592-20624/? E/AndroidRuntime: FATAL EXCEPTION: UnityMain
    Process: com.DefaultCompany.CsoundUnity_DevelopmentProject, PID: 20592
    java.lang.Error: FATAL EXCEPTION [UnityMain]
    Unity version     : 2019.3.9f1
    Device model      : samsung SM-J730F
    Device fingerprint: samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys
    
    Caused by: java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Version '2019.3.9f1 (e6e740a1c473)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
    Build fingerprint: 'samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys'
    Revision: '7'
    ABI: 'arm'
    Timestamp: 2021-01-12 15:09:47+0000
    pid: 20592, tid: 20700, name: FMODAudioDevice  >>> com.DefaultCompany.CsoundUnity_DevelopmentProject <<<
    uid: 10262
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    Cause: null pointer dereference
        r0  00000000  r1  00000000  r2  000001c0  r3  00000000
        r4  00000000  r5  00000040  r6  c55dfdf4  r7  bcffe728
        r8  c55d6588  r9  c55d6570  r10 c55d4740  r11 c55d4cb8
        ip  00000000  sp  bcffe6bc  lr  c330cba7  pc  e70a4830
    
    backtrace:
          #00 pc 00017830  /system/lib/libc.so (memset+48) (BuildId: 780e66cc3f4645d1839dfe6ba628dcc2)
          #01 pc 001ecba3  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libcsoundandroid.so (kperf_nodebug+210) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
          #02 pc 001edbab  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libcsoundandroid.so (csoundPerformKsmps+70) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
          #03 pc 00609b5c  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
          #04 pc 00607df8  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
          #05 pc 00176d80  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
          #06 pc 0010f540  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libil2cpp.so (BuildId: 3ebf18917d709c0e68d4ab6ba4ecd58ea8e7878e)
          #07 pc 00129205  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
          #08 pc 0013242b  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
          #09 pc 0005fe31  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
          #10 pc 0042129b  /data/app/com.DefaultCompany.CsoundUnity_DevelopmentProject-1/lib/arm/libunity.so (BuildId: 0a272357a879ab2945106af5f96dda3a8a6f8baa)
    
        at libc.memset(memset:48)
        at libcsoundandroid.kperf_nodebug(kperf_nodebug:210)
        at libcsoundandroid.csoundPerformKsmps(csoundPerformKsmps:70)
        at libil2cpp.0x609b5c(Native Method)
        at libil2cpp.0x607df8(Native Method)
        at libil2cpp.0x176d80(Native Method)
        at libil2cpp.0x10f540(Native Method)
        at libunity.0x129205(Native Method)
        at libunity.0x13242b(Native Method)
        at libunity.0x5fe31(Native Method)
        at libunity.0x42129b(Native Method)
2021-01-12 15:09:48.409 2939-6133/? W/ActivityManager:   Force finishing activity com.DefaultCompany.CsoundUnity_DevelopmentProject/com.unity3d.player.UnityPlayerActivity

Notice that the libs are not found this time. I’ll push the change to the repo and try with the latest Unity version.

With the newest Unity the libraries are found, but still a crash on Android, now related to PerformKsmps:

Crash log
2021-01-12 15:25:28.671 22448-22448/? I/IapReceiver: packageName = com.gb.TestCsoundUnity
2021-01-12 15:25:29.796 22183-22216/? I/Unity: AudioSettings.outputSampleRate: 24000
2021-01-12 15:25:29.827 22183-22216/? I/Unity: Updated path:;/Packages/com.csound.csoundunity/Runtime
2021-01-12 15:25:29.866 22183-22216/? I/Unity: CsoundUnityBridge constructor from dir: /Packages/com.csound.csoundunity/Runtime csdFile: <Cabbage>
    form caption ("Basic Test"), size(300, 100)
    
    hslider bounds(0, 0, 300, 50) range(20, 16000, 440, 1, 0.001) valuetextbox(1) channel("freqSlider") value(440) velocity(50)
    </Cabbage>
    
    <CsoundSynthesizer>
    <CsOptions>
    ;-n -d -m0d 
    ;-odac
    -n ; -m0d
    </CsOptions>
    <CsInstruments> 
    sr 	= 	44100 
    ksmps 	= 	64
    nchnls 	= 	2
    0dbfs	=	1 
    
    instr 1
    a1 oscil .2, chnget:k("freqSlider"), 1
    outs a1, a1
    
    endin
    
    </CsInstruments>
    <CsScore>
    f0 3600
    f1 0 4096 10 1
    i1 0 5
    </CsScore>
    </CsoundSynthesizer>
2021-01-12 15:25:29.878 22183-22216/? I/Unity: System buffer size: 512, buffer count: 4 , samplerate: 24000
2021-01-12 15:25:29.893 22183-22216/? I/Unity: csoundCompile: True
2021-01-12 15:25:29.920 22183-22216/? I/Unity: zerdbfs 1
2021-01-12 15:25:29.921 22183-22216/? I/Unity: CsoundUnity done init
2021-01-12 15:25:29.940 2939-4151/? V/WindowManager: Relayout Window{3a11596d0 u0 com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity}: viewVisibility=0 req=1080x1920 WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#80810500 pfl=0x20000 fmt=-3 wanim=0x1030465 preferredDisplayMode=1 vsysui=0x1706 needsMenuKey=2 naviIconColor=0}
2021-01-12 15:25:29.944 22183-22183/? D/ViewRootImpl@baee071[UnityPlayerActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -644952064} surfaceGenerationChanged=false
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd2d5000-bd62d000 r-xp 00000000 fe:01 9830                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd62e000-bd63f000 r--p 00358000 fe:01 9830                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd63f000-bd654000 rw-p 00369000 fe:01 9830                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd657000-bd844000 r-xp 00000000 fe:01 9844                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libsndfile.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd845000-bd853000 r--p 001ed000 fe:01 9844                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libsndfile.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd853000-bd854000 rw-p 001fb000 fe:01 9844                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libsndfile.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd85a000-bd8de000 r-xp 00000000 fe:01 9801                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libc++_shared.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd8de000-bd8e3000 r--p 00083000 fe:01 9801                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libc++_shared.so
2021-01-12 15:25:30.075 22183-22291/? E/mono-rt: bd8e3000-bd8e4000 rw-p 00088000 fe:01 9801                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libc++_shared.so
2021-01-12 15:25:30.077 22183-22291/? E/mono-rt: be401000-be405000 r--s 01a02000 fe:01 9797                               /data/app/com.gb.TestCsoundUnity-2/base.apk
2021-01-12 15:25:30.081 22183-22291/? E/mono-rt: c602c000-c6561000 r-xp 00000000 fe:01 9820                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libmonobdwgc-2.0.so
2021-01-12 15:25:30.081 22183-22291/? E/mono-rt: c6562000-c6565000 r--p 00535000 fe:01 9820                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libmonobdwgc-2.0.so
2021-01-12 15:25:30.081 22183-22291/? E/mono-rt: c6565000-c656d000 rw-p 00538000 fe:01 9820                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libmonobdwgc-2.0.so
2021-01-12 15:25:30.081 22183-22291/? E/mono-rt: c65ea000-c75c0000 r-xp 00000000 fe:01 9803                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libunity.so
2021-01-12 15:25:30.081 22183-22291/? E/mono-rt: c75c0000-c75fb000 r--p 00fd5000 fe:01 9803                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libunity.so
2021-01-12 15:25:30.081 22183-22291/? E/mono-rt: c75fb000-c7612000 rw-p 01010000 fe:01 9803                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libunity.so
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4aa2000-e4aa6000 r-xp 00000000 fe:01 1756                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libmain.so
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4aa6000-e4aa7000 r--p 00003000 fe:01 1756                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libmain.so
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4aa7000-e4aa8000 rw-p 00004000 fe:01 1756                               /data/app/com.gb.TestCsoundUnity-2/lib/arm/libmain.so
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4aaa000-e4aab000 r--s 006a5000 fe:01 9797                               /data/app/com.gb.TestCsoundUnity-2/base.apk
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4acc000-e4ad0000 r--s 01a02000 fe:01 9797                               /data/app/com.gb.TestCsoundUnity-2/base.apk
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4bcf000-e4bed000 r--p 00000000 fe:01 9855                               /data/app/com.gb.TestCsoundUnity-2/oat/arm/base.odex
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4bed000-e4bf1000 r-xp 0001e000 fe:01 9855                               /data/app/com.gb.TestCsoundUnity-2/oat/arm/base.odex
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4bf5000-e4bf6000 r--p 00022000 fe:01 9855                               /data/app/com.gb.TestCsoundUnity-2/oat/arm/base.odex
2021-01-12 15:25:30.093 22183-22291/? E/mono-rt: e4bf6000-e4bf7000 rw-p 00023000 fe:01 9855                               /data/app/com.gb.TestCsoundUnity-2/oat/arm/base.odex
2021-01-12 15:25:30.107 22183-22291/? E/mono-rt: e8e95000-e8e96000 r--s 01a01000 fe:01 9797                               /data/app/com.gb.TestCsoundUnity-2/base.apk
2021-01-12 15:25:30.153 22183-22291/? E/CRASH: pid: 22183, tid: 22291, name: FMODAudioDevice  >>> com.gb.TestCsoundUnity <<<
2021-01-12 15:25:30.153 22183-22291/? E/CRASH:       #01 pc 001ecba3  /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so (kperf_nodebug+210) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
2021-01-12 15:25:30.153 22183-22291/? E/CRASH:       #02 pc 001edbab  /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so (csoundPerformKsmps+70) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
2021-01-12 15:25:30.153 22183-22291/? E/CRASH:       #01 CsoundUnityBridge:PerformKsmps () <0x17>
2021-01-12 15:25:30.153 22183-22291/? E/CRASH:       #02 CsoundUnity:PerformKsmps () <0x1f>
2021-01-12 15:25:30.153 22183-22291/? E/CRASH:       #03 CsoundUnity:ProcessBlock (single[],int) <0x11f>
2021-01-12 15:25:30.153 22183-22291/? E/CRASH:       #04 CsoundUnity:OnAudioFilterRead (single[],int) <0x33>
2021-01-12 15:25:30.444 22558-22558/? D/UMC:CoreReceiver: PackageName : com.gb.TestCsoundUnity
2021-01-12 15:25:30.444 22558-22558/? D/UMC:CoreReceiver: do nothing for UMC Agent : com.gb.TestCsoundUnity
2021-01-12 15:25:30.476 3453-3453/? D/[IMSFW6]: SessionModule: needDeRegister com.gb.TestCsoundUnity
2021-01-12 15:25:30.770 22183-22216/? E/AndroidRuntime: FATAL EXCEPTION: UnityMain
    Process: com.gb.TestCsoundUnity, PID: 22183
    java.lang.Error: FATAL EXCEPTION [UnityMain]
    Unity version     : 2020.2.1f1
    Device model      : samsung SM-J730F
    Device fingerprint: samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys
    Build Type        : Release
    Scripting Backend : Mono
    ABI               : armeabi-v7a
    Strip Engine Code : false
    
    Caused by: java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Version '2020.2.1f1 (270dd8c3da1c)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a'
    Build fingerprint: 'samsung/j7y17ltexx/j7y17lte:7.0/NRD90M/J730FXXU1AQI5:user/release-keys'
    Revision: '7'
    ABI: 'arm'
    Timestamp: 2021-01-12 15:25:30+0000
    pid: 22183, tid: 22291, name: FMODAudioDevice  >>> com.gb.TestCsoundUnity <<<
    uid: 10261
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    Cause: null pointer dereference
        r0  00000000  r1  00000000  r2  000001c0  r3  00000000
        r4  00000000  r5  00000040  r6  b3c91274  r7  b7bfe3a8
        r8  b3c87a08  r9  b3c879f0  r10 b3c85bc0  r11 b3c86138
        ip  00000000  sp  b7bfe33c  lr  bd4c1ba7  pc  e70a4830
    
    backtrace:
          #00 pc 00017830  /system/lib/libc.so (memset+48) (BuildId: 780e66cc3f4645d1839dfe6ba628dcc2)
          #01 pc 001ecba3  /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so (kperf_nodebug+210) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
          #02 pc 001edbab  /data/app/com.gb.TestCsoundUnity-2/lib/arm/libcsoundandroid.so (csoundPerformKsmps+70) (BuildId: e34e0df6b64e176aacb8d4e1bc0e600a15f21127)
          #03 pc 00004626  <anonymous:bad10000>
    
    managed backtrace:
          #00 (wrapper managed-to-native) csoundcsharp.Csound6/NativeMethods:csoundPerformKsmps (intptr)
          #01 CsoundUnityBridge:PerformKsmps () <0x17>
          #02 CsoundUnity:PerformKsmps () <0x1f>
          #03 CsoundUnity:ProcessBlock (single[],int) <0x11f>
          #04 CsoundUnity:OnAudioFilterRead (single[],int) <0x33>
          #05 (wrapper runtime-invoke) <Module>:runtime_invoke_void__this___object_int (object,intptr,intptr,intptr)
    
        at libc.memset(memset:48)
        at libcsoundandroid.kperf_nodebug(kperf_nodebug:210)
        at libcsoundandroid.csoundPerformKsmps(csoundPerformKsmps:70)
        at csoundcsharp.Csound6.NativeMethods.csoundPerformKsmps (intptr)(Native Method)
        at CsoundUnityBridge.PerformKsmps ()(0x17:23)
        at CsoundUnity.PerformKsmps ()(0x1f:31)
        at CsoundUnity.ProcessBlock (single[],int)(0x11f:287)
        at CsoundUnity.OnAudioFilterRead (single[],int)(0x33:51)
        at <Module>.runtime_invoke_void__this___object_int (object,intptr,intptr,intptr)(Native Method)
2021-01-12 15:25:30.778 2939-4151/? W/ActivityManager:   Force finishing activity com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity
2021-01-12 15:25:30.800 22183-22183/? D/ViewRootImpl@baee071[UnityPlayerActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2021-01-12 15:25:30.856 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: ThreadedRenderer.create() translucent=true
2021-01-12 15:25:30.857 2939-2986/? D/WindowManager: openInputChannel mInputChannel: c2033fa Application Error: com.gb.TestCsoundUnity (server)
2021-01-12 15:25:30.859 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: setView = DecorView@6e87dab[TestCsoundUnity] touchMode=true
2021-01-12 15:25:30.864 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: dispatchAttachedToWindow
2021-01-12 15:25:30.867 2939-2986/? V/WindowManager: Relayout Window{c2033fad0 u0 Application Error: com.gb.TestCsoundUnity}: viewVisibility=0 req=1015x441 WM.LayoutParams{(0,0)(wrapxwrap) gr=#11 sim=#120 ty=2003 fl=#1820002 pfl=0x110 fmt=-3 wanim=0x103038b surfaceInsets=Rect(6, 6 - 6, 6) needsMenuKey=2 naviIconColor=0}
2021-01-12 15:25:30.868 2412-2412/? I/SurfaceFlinger: id=28281 createSurf (13x13),1 flag=4, Application Error: com.gb.TestCsoundUnity
2021-01-12 15:25:30.884 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[32,771][1047,1212] result=0x27 surface={isValid=true -1377832960} surfaceGenerationChanged=true
2021-01-12 15:25:30.885 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: mHardwareRenderer.initialize() mSurface={isValid=true -1377832960} hwInitialized=true
2021-01-12 15:25:30.891 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: MSG_WINDOW_FOCUS_CHANGED 1
2021-01-12 15:25:30.891 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -1377832960}
2021-01-12 15:25:30.908 2939-2986/? D/WindowManager: finishDrawingWindow: Window{c2033fad0 u0 Application Error: com.gb.TestCsoundUnity} mDrawState=DRAW_PENDING
2021-01-12 15:25:30.909 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: MSG_RESIZED_REPORT: frame=Rect(32, 771 - 1047, 1212) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
2021-01-12 15:25:30.915 2939-2986/? D/WindowManager: finishDrawingWindow: Window{c2033fad0 u0 Application Error: com.gb.TestCsoundUnity} mDrawState=HAS_DRAWN
2021-01-12 15:25:31.208 22700-22700/? D/AASAservice-UpdateReceiver: onReceive() : package = com.gb.TestCsoundUnity, uid = -1
2021-01-12 15:25:31.210 22700-22700/? D/AASAservice-AASABinder: getManagedSharedPkgList() : packageName - com.gb.TestCsoundUnity, uid - -1
2021-01-12 15:25:31.265 22026-22026/? I/GameLauncher: [PackageChangedReceiver:onReceive:32] PackageChangedReceiver com.gb.TestCsoundUnity action : android.intent.action.PACKAGE_ADDED
2021-01-12 15:25:31.271 3196-3196/? D/VvmPackageInstallReceiver: onReceive intent : Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.gb.TestCsoundUnity flg=0x4000010 cmp=com.android.phone/.vvm.omtp.VvmPackageInstallReceiver launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } bqHint=1 (has extras) }
2021-01-12 15:25:31.301 2939-2985/? W/ActivityManager: Activity pause timeout for ActivityRecord{4cb4436d0 u0 com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity t4722 f}
2021-01-12 15:25:31.303 2939-2985/? D/ActivityManager: resumeTopActivityInnerLocked() : #0 prevTask=TaskRecord{bff6dc2d0 #4722 A=com.gb.TestCsoundUnity U=0 StackId=1 sz=1} next=ActivityRecord{b881dcfd0 u0 com.sec.android.app.launcher/.activities.LauncherActivity t4256} mFocusedStack=ActivityStack{21b5486d0 stackId=0, 2 tasks}
2021-01-12 15:25:31.423 2412-2412/? D/SurfaceFlinger:   Display[0] configurations (* current):
        * 0: 1080x1920, xdpi=403.411011, ydpi=403.040985, refresh=16949152
      numHwLayers=7, flags=00000000
        type   |  handle  | hint | flag | tr | blnd |   format    |     source crop (l,t,r,b)      |          frame         | name 
    -----------+----------+------+------+----+------+-------------+--------------------------------+------------------------+------
           HWC | edd84b40 | 0000 | 0020 | 00 | 0100 | RGBx_8888   |  420.0,    0.0, 1500.0, 1920.0 |    0,    0, 1080, 1920 | com.android.systemui.ImageWallpaper
          GLES | edd85400 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |  179.0,  318.0,  901.0, 1601.0 |    0,    0, 1080, 1920 | com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity
          GLES | 00000000 | 0000 | 0220 | 00 | 0105 | ? ffffffff  |    0.0,    0.0,   -1.0,   -1.0 |    1,    3, 1077, 1916 | SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity
          GLES | edd84e60 | 0000 | 0020 | 00 | 0105 | RGBA_8888
2021-01-12 15:25:31.423 2412-2412/? D/SurfaceFlinger:    |    0.0,    0.0, 1080.0, 1920.0 |    1,    3, 1077, 1916 | SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity
          GLES | 00000000 | 0000 | 0200 | 00 | 0105 | ? ffffffff  |    0.0,    0.0,   -1.0,   -1.0 |    0,    0, 1080, 1920 | DimLayerController/Stack=0
           HWC | edd848c0 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1027.0,  453.0 |   26,  765, 1053, 1218 | Application Error: com.gb.TestCsoundUnity
     FB TARGET | edd84500 | 0000 | 0000 | 00 | 0105 | RGBA_8888   |    0.0,    0.0, 1080.0, 1920.0 |    0,    0, 1080, 1920 | HWC_FRAMEBUFFER_TARGET
2021-01-12 15:25:31.534 3210-3210/? D/ApplicationPackageManager: updateItemMetaDataForFixedIconScale: package: com.gb.TestCsoundUnity
2021-01-12 15:25:31.534 2939-6133/? D/PackageManager: getSelectedMetaData : packageName(com.gb.TestCsoundUnity) or Metadata strings {[Ljava.lang.String;@6c8e67c}
2021-01-12 15:25:31.535 3210-3210/? I/ApplicationPackageManager: load=com.gb.TestCsoundUnity, bg=144-144, dr=252-252, forDefault=true
2021-01-12 15:25:31.544 3210-3210/? I/ApplicationPackageManager: load=com.gb.TestCsoundUnity-crop, bg=216-216, dr=216-216
2021-01-12 15:25:31.912 12262-12262/? I/Finsky: [1] znj.g(-1): Invalidating cached PackageState for com.gb.TestCsoundUnity
2021-01-12 15:25:31.959 12262-22091/? I/Finsky: [84429] hco.a(-1): Asset module broadcast after update successful for package com.gb.TestCsoundUnity. 0 sessions broadcast.
2021-01-12 15:25:32.009 22095-22095/? D/GOS:PkgData: PkgData(), pkgName: com.gb.TestCsoundUnity
2021-01-12 15:25:32.010 22095-22095/? D/GOS:PkgData: setCustomFeatureFlag, pkgName: com.gb.TestCsoundUnity, old featureFlag: 342277969731031827, new featureFlag: 346781844236309267
2021-01-12 15:25:32.393 13659-22859/? I/ChromeSync: [Sync,SyncIntentOperation] Handling the intent: Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.gb.TestCsoundUnity flg=0x4000010 pkg=com.google.android.gms cmp=com.google.android.gms/.chimera.GmsIntentOperationService launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } bqHint=1 (has extras) }.
2021-01-12 15:25:33.122 22435-22435/? D/KnoxPackageStateReceiver:  received intent Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.gb.TestCsoundUnity flg=0x4000010 cmp=com.samsung.knox.securefolder/.containeragent.KnoxPackageStateReceiver launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } bqHint=1 (has extras) }
2021-01-12 15:25:33.122 22435-22435/? D/KnoxPackageStateReceiver: packageName:com.gb.TestCsoundUnity
2021-01-12 15:25:33.296 3453-3453/? D/[IMSFW6]: SessionModule: needRegister com.gb.TestCsoundUnity
2021-01-12 15:25:33.344 22026-22026/? I/GameLauncher: [PackageChangedReceiver:onReceive:32] PackageChangedReceiver com.gb.TestCsoundUnity action : android.intent.action.PACKAGE_REPLACED
2021-01-12 15:25:33.392 22095-22920/? D/GOS:MainIntentService: onHandleIntent(). PACKAGE_CHANGED. changeType : 8, packageName : com.gb.TestCsoundUnity
2021-01-12 15:25:33.439 22095-22920/? D/GOS:DataManager: onPackageUpdated(). packageName: com.gb.TestCsoundUnity, versionCode: 1
2021-01-12 15:25:33.441 22095-22920/? D/GOS:PkgData: PkgData(), pkgName: com.gb.TestCsoundUnity
2021-01-12 15:25:33.441 22095-22920/? D/GOS:PkgData: setCustomFeatureFlag, pkgName: com.gb.TestCsoundUnity, old featureFlag: 346781844236309267, new featureFlag: 346781844236309267
2021-01-12 15:25:34.666 22996-22996/? D/UpdateCompleteReceiver: UpdateCompleteReceiver. pkgName : com.gb.TestCsoundUnity
2021-01-12 15:25:34.806 22183-22183/? W/Unity: Timeout while trying to pause the Unity Engine.
2021-01-12 15:25:34.845 23018-23018/? D/RCP_PackageUpdateReceiver: Update Package Name :com.gb.TestCsoundUnity
2021-01-12 15:25:34.862 23018-23018/? D/RCP_PackageUpdateReceiver: Update Class Name :com.unity3d.player.UnityPlayerActivity
2021-01-12 15:25:34.871 22448-22448/? I/IapReceiver: packageName = com.gb.TestCsoundUnity
2021-01-12 15:25:35.177 23034-23034/? D/myFiles: [0002/AppUpdateReceiver   ] AppUpdateReceiveronReceive() - pkgName : com.gb.TestCsoundUnity
2021-01-12 15:25:35.223 3453-3453/? D/[IMSFW6]: SessionModule: needRegister com.gb.TestCsoundUnity
2021-01-12 15:25:38.812 2939-5009/? V/WindowManager: Relayout Window{70b1570d0 u0 SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity}: viewVisibility=8 req=1080x1920 WM.LayoutParams{(0,0)(1080x1920) gr=#800033 ty=1001 fl=#4218 pfl=0x12040 fmt=4 naviIconColor=0}
2021-01-12 15:25:41.796 2939-2985/? W/ActivityManager: Activity destroy timeout for ActivityRecord{4cb4436d0 u0 com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity t4722 f}
2021-01-12 15:25:41.817 2939-2985/? I/WindowManager_SurfaceController: Destroying surface Surface(name=SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity) called by com.android.server.wm.WindowStateAnimator.destroyDeferredSurfaceLocked:1172 com.android.server.wm.WindowState.removeLocked:1922 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2998 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2958 com.android.server.wm.WindowManagerService.removeWindowLocked:2938 com.android.server.wm.WindowManagerService.removeWindowLocked:2740 com.android.server.wm.WindowManagerService.removeWindowLocked:2735 com.android.server.wm.AppWindowToken.removeAllWindows:618 
2021-01-12 15:25:41.818 2412-3002/? I/SurfaceFlinger: id=28279 Removed SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (6/10)
2021-01-12 15:25:41.819 2412-9332/? I/SurfaceFlinger: id=28279 Removed SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (-2/10)
2021-01-12 15:25:41.819 2412-9332/? I/SurfaceFlinger: id=28280 Removed SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (5/9)
2021-01-12 15:25:41.823 2412-3002/? I/SurfaceFlinger: id=28280 Removed SurfaceView - com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (-2/9)
2021-01-12 15:25:41.829 2939-2985/? D/WindowManager: disposeInputChannel mInputChannel: 3a11596 com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (server)
2021-01-12 15:25:41.830 2939-2985/? I/WindowManager_SurfaceController: Destroying surface Surface(name=com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:3070 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:1138 com.android.server.wm.WindowState.removeLocked:1923 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2998 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2958 com.android.server.wm.WindowManagerService.removeWindowLocked:2938 com.android.server.wm.WindowManagerService.removeWindowLocked:2740 com.android.server.wm.WindowManagerService.removeWindowLocked:2735 
2021-01-12 15:25:41.831 2412-3002/? I/SurfaceFlinger: id=28278 Removed com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (5/8)
2021-01-12 15:25:41.832 2412-2418/? I/SurfaceFlinger: id=28278 Removed com.gb.TestCsoundUnity/com.unity3d.player.UnityPlayerActivity (-2/8)
2021-01-12 15:25:42.833 22183-22183/? W/Unity: Timeout while trying detaching primary window.
2021-01-12 15:25:42.930 2939-3100/? I/ActivityManager: Process com.gb.TestCsoundUnity (pid 22183) has died(122,713)
2021-01-12 15:25:42.941 2939-4151/? W/ActivityManager: Ignoring remove of inactive process: ProcessRecord{32655b7 0:com.gb.TestCsoundUnity/u0a261}
2021-01-12 15:25:42.972 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: mHardwareRenderer.destroy()#4
2021-01-12 15:25:42.972 2939-2986/? D/ViewRootImpl@7362a1c[TestCsoundUnity]: dispatchDetachedFromWindow
2021-01-12 15:25:42.972 2939-2986/? D/WindowManager: disposeInputChannel mInputChannel: c2033fa Application Error: com.gb.TestCsoundUnity (server)
2021-01-12 15:25:43.291 2939-2995/? I/WindowManager_SurfaceController: Destroying surface Surface(name=Application Error: com.gb.TestCsoundUnity) called by com.android.server.wm.WindowStateAnimator.destroySurface:3070 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:1138 com.android.server.wm.WindowState.destroyOrSaveSurface:2798 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementInner:510 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop:284 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement:232 com.android.server.wm.WindowManagerService$H.handleMessage:9606 android.os.Handler.dispatchMessage:102 
2021-01-12 15:25:43.292 2412-2418/? I/SurfaceFlinger: id=28281 Removed Application Error: com.gb.TestCsoundUnity (6/7)
2021-01-12 15:25:43.292 2412-3834/? I/SurfaceFlinger: id=28281 Removed Application Error: com.gb.TestCsoundUnity (-2/7)

Is FMOD the problem? If I try to call GetOpcodeList() or GetNamedGens() without adding a csd to compile, I have no crash, and the functions return correctly:

OpcodeList

2021-01-12 15:40:14.569 24008-24031/? I/Unity: [0] [a] [<color=blue>in: k] [<color=red>out: a] [<color=purple>flags: 0]
2021-01-12 15:40:14.569 24008-24031/? I/Unity: [1] [abs] [<color=blue>in: a] [<color=red>out: a] [<color=purple>flags: 0] [<color=blue>in: i] [<color=red>out: i] [<color=purple>flags: 0] [<color=blue>in: k] [<color=red>out: k] [<color=purple>flags: 0]
2021-01-12 15:40:14.569 24008-24031/? I/Unity: [2] [active] [<color=blue>in: Soo] [<color=red>out: i] [<color=purple>flags: 0] [<color=blue>in: ioo] [<color=red>out: i] [<color=purple>flags: 0] [<color=blue>in: Soo] [<color=red>out: k] [<color=purple>flags: 0] [<color=blue>in: koo] [<color=red>out: k] [<color=purple>flags: 0]
2021-01-12 15:40:14.569 24008-24031/? I/Unity: [3] [adsr] [<color=blue>in: iiiio] [<color=red>out: a] [<color=purple>flags: 0] [<color=blue>in: iiiio] [<color=red>out: k] [<color=purple>flags: 0]
2021-01-12 15:40:14.570 24008-24031/? I/Unity: [4] [adsyn] [<color=blue>in: kkkSo] [<color=red>out: a] [<color=purple>flags: 0] [<color=blue>in: kkkio] [<color=red>out: a] [<color=purple>flags: 0]
2021-01-12 15:40:14.570 24008-24031/? I/Unity: [5] [adsynt] [<color=blue>in: kkiiiio] [<color=red>out: a] [<color=purple>flags: 8]
2021-01-12 15:40:14.570 24008-24031/? I/Unity: [6] [adsynt2] [<color=blue>in: kkiiiio] [<color=red>out: a] [<color=purple>flags: 8]

etc.

I don’t see anything in the log to indicate that Csound has compiled correctly? I would expect to see some output Csound? What about you try to compile a csd string instead of a file? If there is an error when you call performKsmps() it might be that the file didn’t compile correctly? I don’t know, just clutching at straws here…

Yes the csd is compiled correctly:

2021-01-12 15:25:29.878 22183-22216/? I/Unity: System buffer size: 512, buffer count: 4 , samplerate: 24000
2021-01-12 15:25:29.893 22183-22216/? I/Unity: csoundCompile: True
2021-01-12 15:25:29.920 22183-22216/? I/Unity: zerdbfs 1
2021-01-12 15:25:29.921 22183-22216/? I/Unity: CsoundUnity done init

Well the sample rate is a bit strange… but apart from this, the fact is that the crash comes when there is a computation in OnAudioFilterRead: we’re compiling the csd as a string now (if a csd has been set), and if it compiles this we set a compiledOK bool to true, and the code in OnAudioFilterRead is executed.

Are we overriding the sample rate? I thought we did, but it looks commented out:

Do you still have the source from the version @virtualHC send you? Are there any Android specific things he added that we’re missing?

Yes I can uncomment that part, I don’t remember exactly why it is commented :thinking:
EDIT: I think it’s because we’re using Params to set the control rate and sample rate, and probably this is not working

I’ll have a look at the code by Hector again to see what’s different :male_detective:
EDIT: I’m having a look, but the code is mostly the same: we’re not copying anymore csds from the StreamingAssets folder to the PersistentFolder, the Csound initialisation is the same.
In OnAudioFilterRead we’re using the same getOutputSample, so I can’t understand the crash!!

I wonder if it might be worth trying some older versions of Csound to see if they work Ok? How does one go about debugging unity apps on Android? Might there be something destroying Csound at some point during the process? Or does it somehow become NULL at some point?

Actually, can you try calling performKsmps() straight after starting Csound?