[Bug][2.02.06] Android startup crash

We tried OpenSL, and still the same error.

We have a Debug build with full error logging ready. How to share this link with you in privet? The seems to be now PM option.

Thank you for preparing that- if you could please upload it to your FMOD Profile I will take a look through and try to reproduce the issue.

I uploaded the build.

Thank you for the reproduction, we are able to reproduce this issue as you have described. Everything seems to be indicating a fault in the headset detection code, which as I mentioned previously came in at 2.02.06. While we investigate this issue, would it be possible for you to move back to the 2.02.05 version of the integration to continue development?

We upgraded to 2.02.06 as we need this fix:
Unity - Fixed il2cpp crash caused by CREATESOUNDEXINFO callbacks not being marshaled when loading sounds from audio tables.

Is there a estimate on how long until a version with a fix to this issue becomes available ?

Unfortunately we have no estimate on when a fix for this issue will become available.

There is a workaround for this particular issue in 2.02.05 that you can try, which is to explicitly null out any unused exinfo callbacks before calling System.createSound. More details on this workaround are available here FMOD programmer sounds no longer work Unity 2021.2.* - #5 by jeff_fmod

Good day! I want to add that we have similar issue with Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged with version 2.02.03. Interesting thing that it reproduces only on Xiaomi devices with Android 11 version when app goes foreground after some time in background. Is it sounds familiar to you? May be it’s already fixed in the latest version?
Also I want to add that we don’t use createSound method, so we can not use offered workround.

Strange that you are getting this in 2.02.03. Does this issuse occur in 2.02.05?

We don’t have released version of the app with FMOD 2.02.05 at the moment. We are waiting for particular Xiaomi devices to come to test it ourselves.

Started getting this crash on 2.02.07. Tested on OpenSL too, still crashing.

We have found that this issue reproduces in 2.02.06 when there are no FMOD Studio Listener components in the first scene. We are currently working on a fix for this which should be available in the next release. In the meantime, can you please confirm whether you have any FMODUnity components (StudioListener, StudioEventEmitter etc) in your first scene? If you do not, does adding one prevent the crash?

Yes, there is a FMOD listener and event emitters present in the first scene. However, I did a mistake and left a Unity Audio Listener component in a new camera I created for the UI at build time. Removing it didn’t fix the issue for subsequent builds, as they keep crashing in the same manner at the opening of the game. Somewhere in this timeframe before the crashes starting happening I tested the game with headphones plugged on, possibly at build time. Only time I have got the app not crash since then was when I plugged the headphones just as the game was launching.

Hello every one. Did you guys found the way out. I’m facing the exact same issue.
I’m using FMOD version 2.02.07 and other details are given below.

OS : Android 12

java.lang.Error: FATAL EXCEPTION [main]
Unity version     : 2020.3.32f1
Device model      : Xiaomi M2101K6G
Device fingerprint: Redmi/sweet_global/sweet:12/SKQ1.210908.001/V13.0.8.0.SKFMIXM:user/release-keys
Build Type        : Release
Scripting Backend : IL2CPP
ABI               : arm64-v8a
Strip Engine Code : true

Caused by: java.lang.UnsatisfiedLinkError: No implementation found for void org.fmod.FMOD.OutputAAudioHeadphonesChanged() (tried Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged and Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged__)
	at org.fmod.FMOD.OutputAAudioHeadphonesChanged(Native Method)
	at org.fmod.FMOD.access$000(FMOD.java:18)
	at org.fmod.FMOD$PluginBroadcastReceiver.onReceive(FMOD.java:168)
	at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1694)
	at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(Unknown Source:2)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:210)
	at android.os.Looper.loop(Looper.java:299)
	at android.app.ActivityThread.main(ActivityThread.java:8168)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1037)

Thank you for the additional information. This still appears to be due to an issue with initialization order. As a workaround, you can try moving the call to RuntimeUtils.EnforceLibraryOrder() inside RuntimeManager.cs RuntimeManager.Instance.get to be at the top of the try/catch block, ie

try
{
    RuntimeUtils.EnforceLibraryOrder(); // move to here

    #if UNITY_ANDROID && !UNITY_EDITOR
    // First, obtain the current activity context
    AndroidJavaObject activity = null;
    using (var activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    {
        activity = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
    }

    using (var fmodJava = new AndroidJavaClass("org.fmod.FMOD"))
    {
        if (fmodJava != null)
        {
            fmodJava.CallStatic("init", activity);
        }
        else
        {
            RuntimeUtils.DebugLogWarning("[FMOD] Cannot initialize Java wrapper");
        }
    }
    #endif

    //RuntimeUtils.EnforceLibraryOrder(); // remove from here
    initResult = instance.Initialize();
}

Please let me know if that works around the issue.

I just applied this FIX/Workaround to our project and it seems to work on my Test device.

We have a QA run on android scheduled soon. If there are any issues i will update.

Tank you for solving this issue for us.
Have a nice week.

1 Like

Good day! Do you have any date/version when such crashes will be fixed? We are still have crash reports from our Android users, but we can not reproduce it locally. We use 2.02.06 version and I don’t see any workarounds in this thread that is suitable for us. There is example of crash stack trace below:

* libc.so 0x43100f98 + 901016
* libc.so 0x430bac08 + 613384
* libbinder.so 0x42f980b4 + 340148
* libbinder.so 0x42f992f0 + 344816
* libbinder.so 0x42f99034 + 344116
* libbinder.so 0x42f90b28 + 310056
* libbinder.so 0x42fd4ec8 + 589512
* libbinder.so 0x42f9d4f0 + 361712
* libaudioclient.so 0x5915e0a8 + 725160
* libaaudio_internal.so 0xabc6e3f4 + 119796
* libaaudio_internal.so 0xabc75590 + 148880
* libaaudio_internal.so 0xabc7ada8 + 171432
* libaaudio_internal.so 0xabc74a70 + 146032
* libaaudio_internal.so 0xabc73d40 + 142656
* libaaudio.so 0xab1dfc7c + 15484
* libfmod.so Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged
* libfmod.so Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged
* libfmod.so FMOD::SystemI::setInternalCallback(int, FMOD_RESULT (*)(FMOD_SYSTEM*, unsigned int, void*, void*, void*), void*)
* libfmod.so FMOD::System::init(int, unsigned int, void*)
* libfmodstudio.so 0xf34d29d0 + 371152
* libfmodstudio.so FMOD::Studio::System::initialize(int, unsigned int, unsigned int, void*)

Just to confirm, are you using the Unity Integration, Unreal Integration or the FMOD C/C++ API?
This crash should be fixed in the Unity Integration in the next release, in the meantime there is small change you can make to RuntimeManager.cs to workaround the issue.
Please let me know if you are not using the FMOD Unity Integration and I will investigate further.

We are using FMOD C/C++ API.

The solution in the case of the Unity integration is essentially to call java.lang.System.loadLibrary("fmod") before calling into the FMOD API. In the C++ API examples we call this from a static initialization block as described in the Android Platform Specifics section of the docs. Are you making a similar call in your application?

We’ve added all needed code as described in documentation but still having same crashes with
Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged. Do you have any ideas?