Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Crash on Android 15 Emulator Triggered by Unreferenced CrashMethods.cs – Full Repro Steps (Related to #1180) #1194

Open
b3lypscfcon opened this issue Feb 25, 2025 · 3 comments

Comments

@b3lypscfcon
Copy link

Description

This issue is related to #1180. I have managed to reproduce a crash 100% of the time using the following steps. In our project, if we include a class (CrashMethods.cs) that is not referenced by any other code, the app crashes on an Android 15 emulator during Firebase initialization—specifically, the callback from CheckAndFixDependenciesAsync() is never received, and the app subsequently crashes with a native error. Removing CrashMethods.cs (or ensuring that both CrashMethods1() and CrashMethods2() are completely removed) prevents the crash.

Notably, even if only one of the methods in CrashMethods.cs remains, the crash occurs. I have verified this in a completely new project as well, so it appears to be a direct interaction that triggers the crash. Additionally, when the project that crashes in Unity 2022 was opened in Unity6 (6000.0.35f1) and built, the crash still occurred.

Reproducing the issue

  1. Create a new 3D project in Unity 2022.3.23f1 (using Built-in Rendering).
  2. Add google-services.json to the project (downloaded from the Firebase Console).
  3. Import FirebaseMessaging.unitypackage into the project.
  4. Switch the platform to Android in Build Settings.
  5. In the Firebase settings, enable Auto Resolution.
  6. In gradleTemplate.properties, add the following line to work around a Gradle build error:
    android.aapt2FromMavenOverride=C:/Program Files/2022.3.23f1/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/build-tools/34.0.0/aapt2.exe
    
  7. Change the build settings to:
    • Target Architecture: Arm64
    • Scripting Backend: IL2CPP
    • minSDKVersion: 25
    • targetSDKVersion: 35
  8. Create Initializer.cs and attach it to an object in the scene.
  9. Create CrashMethods.cs and place it in the Assets folder (do not reference this class anywhere).
  10. Build and run the project on an Android 15 emulator.
    • Expected behavior:
      • The log "Call CheckAndFixDependenciesAsync" is output.
      • No log "CallBack CheckAndFixDependenciesAsync" is output, indicating that CheckAndFixDependenciesAsync() never returns.
      • The app crashes with a native error shortly thereafter.
    • Note:
      • If CrashMethods.cs is removed entirely from the project, the crash does not occur.
      • If either CrashMethods1() or CrashMethods2() remains (i.e., the file is not completely removed), the crash still occurs.

Code Samples:

Initializer.cs:

using System.Collections;
using System.Collections.Generic;
using Firebase;
using Firebase.Extensions;
using UnityEngine;

public class initializer : MonoBehaviour
{
    private FirebaseApp app;
    void Start()
    {
        Debug.Log("Call CheckAndFixDependenciesAsync");
#if UNITY_ANDROID && !UNITY_EDITOR
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
            Debug.Log("CallBack CheckAndFixDependenciesAsync");
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available) {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                app = Firebase.FirebaseApp.DefaultInstance;
                // Set a flag here to indicate whether Firebase is ready to use by your app.
            } else {
                UnityEngine.Debug.LogError(System.String.Format(
                    "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });
#endif
    }
}

CrashMethods.cs:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CrashMethods
{
    private void CrashMethods1()
    {
        Firebase.Messaging.FirebaseMessaging.SubscribeAsync("")
            .ContinueWith(task => { });
    }

    private void CrashMethods2()
    {
        Firebase.Messaging.FirebaseMessaging.UnsubscribeAsync("")
            .ContinueWith(task => { });
    }
}

Environment:

  • Host OS: Windows 11
  • Unity Version: 2022.3.23f1 (3D project using Built-in Rendering)
  • Android Build Settings:
    • Target Architecture: Arm64
    • Scripting Backend: IL2CPP
    • minSDKVersion: 25, targetSDKVersion: 35
  • Firebase Plugin: FirebaseMessaging.unitypackage
  • gradleTemplate.properties: Contains the aapt2 override as specified above.
  • Emulator: Pixel 9 Pro using an x86-64 system image (Android 15, API Level 35, with 16KB page sizes not supported)
    • Emulator Image:
      Emulator Image

Thank you for your attention to this matter. I look forward to your updates regarding this persistent crash.

Firebase Unity SDK Version

11.9.0, 12.5.0, 12.6.0

Unity editor version

2022.3.23f1, 6000.0.35f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Messaging

Other Firebase Component(s) in use

No response

Additional SDKs you are using

No response

Targeted Platform(s)

Android

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

Relevant Log Output

If using CocoaPods for Apple platforms, the project's Podfile.lock

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@argzdev
Copy link

argzdev commented Feb 25, 2025

Hey @b3lypscfcon, thanks for bringing this to our attention again. I've escalated this issue during our engineering sync, and we're currently still in progress with the investigation. We'll post back here once we have updates to share. Thanks!

@b3lypscfcon
Copy link
Author

@argzdev
Thanks for your reply. I appreciate your efforts and look forward to hearing more when you have further updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants