Search Unity

Audio Crash on OnAudioFilterRead()

Discussion in 'Audio & Video' started by jsantander2, Apr 22, 2019.

  1. jsantander2

    jsantander2

    Joined:
    Mar 20, 2019
    Posts:
    4
    Hello,
    I'm trying to sample the audio stream to, eventually, postprocess it. However, for now I'm starting with a very small set-up.

    Using 2018.3.13f1, building a Linux player (x86_64) on Ubuntu 19.04. The scene contains:
    • Directional Light
    • Sphere + Audio Source (playing a wav file in a loop)
    • Main Camera + Audio Listener + Test script
    The Test.cs looks like:
    Code (CSharp):
    1. using UnityEngine;
    2. using System;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.  
    7.     void Update()
    8.     {
    9.      
    10.     }
    11.     void OnAudioFilterRead(float[] data, int channels)
    12.     {
    13.         Byte[] t = new Byte[2];
    14.     }
    15. }
    Running the player (
    ./audio.x86_64 -logfile
    ) I'll get:

    Begin MonoManager ReloadAssembly
    - Completed reload, in 0,194 seconds
    Default vsync count 1
    requesting resize 1024 x 600
    resizing window to 1024 x 600
    Desktop is 1600 x 900 @ 60 Hz
    UnloadTime: 1,812000 ms
    Stack overflow in unmanaged: IP: 0x7fb2a8e5a903, fault addr: 0x7fb258014ff8
    Stack overflow in unmanaged: IP: 0x7fb2a8f0c5ce, fault addr: 0x7fb258014f58
    Stack overflow in unmanaged: IP: 0x7fb2a8f5223b, fault addr: 0x7fb258012eb8
    Stack overflow in unmanaged: IP: 0x7fb2a8fb8603, fault addr: 0x7fb258011ff8
    Stack overflow in unmanaged: IP: 0x7fb2a8fc3c87, fault addr: 0x7fb258010948
    Stack overflow in unmanaged: IP: 0x7fb2a8fc3c87, fault addr: 0x7fb25800fb88
    StackOverflowException: The requested operation caused a stack overflow.
    at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
    at Test.OnAudioFilterRead (System.Single[] data, System.Int32 channels) [0x00001] in /home/jsantand/Code/video/inno/VR/new/Unity/TestAudio2/Assets/Scripts/Test.cs:13
    UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    UnityEngine.Logger:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
    System.Object:__icall_wrapper_ves_icall_array_new_specific(IntPtr, Int32)
    Test:OnAudioFilterRead(Single[], Int32) (at /home/jsantand/Code/video/inno/VR/new/Unity/TestAudio2/Assets/Scripts/Test.cs:13)
    (Filename: /home/jsantand/Code/video/inno/VR/new/Unity/TestAudio2/Assets/Scripts/Test.cs Line: 13)

    and the player will just freeze.

    The code above is a minimal example that reproduces the problem. It seems to hint is something related to memory allocation, as if I do the memory allocation elsewhere, the problem does not appear.

    A similar thing happens with Unity 2019.1.0f2

    Please advice.

    Thanks in advance and best regards

    Julian