[Bug][2.02.06] Android startup crash

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

    RuntimeUtils.EnforceLibraryOrder(); // move to here

    // 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);
            RuntimeUtils.DebugLogWarning("[FMOD] Cannot initialize Java wrapper");

    //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?

Thank you for giving that a shot. You mentioned already trying all the workarounds here, but can you please confirm whether you have also tried setting the FMOD_OUTPUTTYPE to OpenSL?

We use OpenSL only for 26 Android SDK because of the bug with AAudio in that version. Do you recomend to switch to OpenSL for all versions or what we should do?

It is probably best not to change output type for everything, but I would like to know whether any of your users who are on Android SDK 26, and therefore are using OpenSL, are also getting this Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged crash.
If you have any other device information on affected users we may be able to attempt a reproduction on our end?

We have such crashes only on Xiaomi devices with Android 11, 12. Most affected devices are Redmi Note 10/10s.

We’ve found stable way to reproduce the problem. Device is Xiaomi Note 10 pro. Before start you need to enable device option here: Options → Sound and vibration → Sound helper → Application sound control (It makes you able to control sound volume for all applications separetely). With that option enabled app crashes all the time when it goes foreground after being in background. Also it’s possibly connected with high workload of the device.

Thank you for the additional info, I have passed this onto the Development team to look into in more detail. I will see if it is possible for us to order one of these devices in; it is sometimes difficult for us to get the exact models required in our country. Can you please go into your settings, click on “About phone” and tell me what the specific Model value of your test device is?

Xiaomi Readmi Note 10 Pro 8/128
Model M2101K6G
Android Version 12 SKQ1.210908.001
MIUI Version

Thank you for the additional device details, I have passed these details along to the Dev team.
One of our developers pointed out that FMOD 2.02.06 should not be able to produce the callstack you are seeing- just to confirm there aren’t any issues with mismatched libs or anything like that can you please try re-downloading the 2.02.06 version of the FMOD API, replace your project’s libs and includes, and see if you still get a crash on your test device?