[Bug][2.02.06] Android startup crash

Build in Unity 2021.2.15f1.

Right after app start we get this CRASH:
2022-05-23 16:43:56.063 18138-18138/***** E/.FMOD.OutputAAudioHeadphonesChanged() (tried Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged and Java_org_fmod_FMOD_OutputAAudioHeadphonesChanged__)
2022-05-23 16:43:56.064 18138-18138/
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ****, PID: 18138
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(Unknown Source:0)
at org.fmod.FMOD$PluginBroadcastReceiver.onReceive(Unknown Source:0)
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1666)
at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

This only happens on some devices but also not always. But it has a 8/10 likelihood to crash.

We did not receive this crash when we ware on 2.02.04. We upgraded to 2.02.06 as it fixed out IL2CPP issues.

This is a major issue for us.

This error probably indicates a missing lib. If you open up the apk (rename the “.apk” part to “.zip” and then unzip it and navigate to “lib{architecture}”, are any fmod .so libraries present?
If there is, how big is the library? If there is not, can you please check the import settings for libfmod.so and libfmodstudio.so for that platform inside Unity, and make sure it is set to be included on Android? e.g

All the libs are in the apk/aab.

We investigated the issue some more and found its correlated to USB-C Headphones.

  • Disconnect Headphones
  • Reboot Device
  • Launch APP
    => no Crash, Working sound
  • Connect Headphones
    => no Crash, Working sound on headphones
  • Close App
  • Launch App
    => Crash on startup
  • Disconnect Headphones
  • Launch App
    => Crash on startup

From this point on, even with the headphones disconnected the app will crash. After a restart of the device it will work until the headphones get connected once before the app Launches.
It is not required for the crash that the heads are connected during the running of the app.

Device: Samsung Galaxy S20 5G (Sm-G9810)
Android: 11 (RP1A.200720.012.G9810ZHS3DUL3)
Headphones: Samsung EO-IC100

Thanks for the extra info- I haven’t been able to reproduce this issue on a device with USB-C headphones. Would it be possible for you to upload a reproduction to your FMOD Profile? Just a debug build of your APK with API Error Logging enabled and the Logging Level set to “Log” should be sufficient.
There was a change to the AAudio headset detection code in 2.02.06 which might relate to this issue. In the FMOD Unity Settings, can you please try setting your Output Mode for the “Android” platform to “OpenSL” and tell me whether you still get a 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

    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*)