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 macOS build when using any Firestore method call #1105

Open
An-try opened this issue Sep 5, 2024 · 12 comments
Open

[Bug] Crash on macOS build when using any Firestore method call #1105

An-try opened this issue Sep 5, 2024 · 12 comments
Assignees
Labels
api: firestore needs-attention Need Googler's attention

Comments

@An-try
Copy link

An-try commented Sep 5, 2024

Description

When using FirebaseFirestore.DefaultInstance.Collection().Listen(), the function works as expected in the Unity Editor. However, when I launch the built .app or run it through Xcode, the app crashes with 90% chance.

Expected Behavior: Listen() should work without crashing in the macOS build, just as it does within the Unity Editor.

Actual Behavior: The function call crashes the app during runtime when executed from the macOS .app build or when launched from Xcode.

I need assistance in identifying why this issue occurs only in the macOS build and not in the Unity Editor.

Reproducing the issue

  1. Set Up Firestore in Unity.
  2. Implement calling the Listen() method after Firebase is initialized.
  3. Build the Unity project for macOS and run the .app or launch it from Xcode.

Behavior: After calling the StartListen() method, the log shows "id:..." as expected, but a crash occurs immediately afterward.

using UnityEngine;
using Firebase.Firestore;

public class FirestoreListener : MonoBehaviour
{
    private void Update()
    {
        if (Input.GetKeyUp(KeyCode.Space))
        {
            StartListen();
        }
    }

    private void StartListen()
    {
        Debug.Log("id: " + FirebaseFirestore.DefaultInstance.Collection("Development").Id);

        FirebaseFirestore.DefaultInstance.Collection("Development").Listen(snapshot =>
        {
            Debug.Log("snapshot");
        });
    }
}

image

Firebase Unity SDK Version

12.2.0

Unity editor version

2022.3.20f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Firestore

Other Firebase Component(s) in use

Analytics, Authentication, Storage

Additional SDKs you are using

DOTween, Extenject, Photon Fusion, Agora Video Call

Targeted Platform(s)

Apple Platforms, Desktop

Unity editor platform

Mac, Windows

Scripting Runtime

Mono

Release Distribution Type

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

Relevant Log Output

[UnityMemory] Configuration Parameters - Can be set up in boot.config
    "memorysetup-bucket-allocator-granularity=16"
    "memorysetup-bucket-allocator-bucket-count=8"
    "memorysetup-bucket-allocator-block-size=4194304"
    "memorysetup-bucket-allocator-block-count=1"
    "memorysetup-main-allocator-block-size=16777216"
    "memorysetup-thread-allocator-block-size=16777216"
    "memorysetup-gfx-main-allocator-block-size=16777216"
    "memorysetup-gfx-thread-allocator-block-size=16777216"
    "memorysetup-cache-allocator-block-size=4194304"
    "memorysetup-typetree-allocator-block-size=2097152"
    "memorysetup-profiler-bucket-allocator-granularity=16"
    "memorysetup-profiler-bucket-allocator-bucket-count=8"
    "memorysetup-profiler-bucket-allocator-block-size=4194304"
    "memorysetup-profiler-bucket-allocator-block-count=1"
    "memorysetup-profiler-allocator-block-size=16777216"
    "memorysetup-profiler-editor-allocator-block-size=1048576"
    "memorysetup-temp-allocator-size-main=4194304"
    "memorysetup-job-temp-allocator-block-size=2097152"
    "memorysetup-job-temp-allocator-block-size-background=1048576"
    "memorysetup-job-temp-allocator-reduction-small-platforms=262144"
    "memorysetup-allocator-temp-initial-block-size-main=262144"
    "memorysetup-allocator-temp-initial-block-size-worker=262144"
    "memorysetup-temp-allocator-size-background-worker=32768"
    "memorysetup-temp-allocator-size-job-worker=262144"
    "memorysetup-temp-allocator-size-preload-manager=262144"
    "memorysetup-temp-allocator-size-nav-mesh-worker=65536"
    "memorysetup-temp-allocator-size-audio-worker=65536"
    "memorysetup-temp-allocator-size-cloud-worker=32768"
    "memorysetup-temp-allocator-size-gfx=262144"
Mono path[0] = '/Users/********/Library/Developer/Xcode/DerivedData/6-csgfbabqszjtfnbwblujxcwowknl/Build/Products/Release/********.app/Contents/Resources/Data/Managed'
Mono config path = '/Users/********/Library/Developer/Xcode/DerivedData/6-csgfbabqszjtfnbwblujxcwowknl/Build/Products/Release/********.app/Contents/MonoBleedingEdge/etc'
[Physics::Module] Initialized MultithreadedJobDispatcher with 7 workers.
Initialize engine version: 2022.3.20f1 (61c2feb0970d)
[Subsystems] Discovering subsystems at path /Users/********/Library/Developer/Xcode/DerivedData/6-csgfbabqszjtfnbwblujxcwowknl/Build/Products/Release/********.app/Contents/Resources/Data/UnitySubsystems
GfxDevice: creating device client; threaded=1; jobified=0
Color LCD preferred device: Intel(R) Iris(TM) Plus Graphics 655 (low power)
Metal devices available: 1
0: Intel(R) Iris(TM) Plus Graphics 655 (low power)
Using device Intel(R) Iris(TM) Plus Graphics 655 (low power)
Initializing Metal device caps: Intel(R) Iris(TM) Plus Graphics 655
Begin MonoManager ReloadAssembly
- Loaded All Assemblies, in  0.336 seconds
- Finished resetting the current domain, in  0.002 seconds
UnloadTime: 1.719745 ms
<color=green>[Network]</color> Cannot get local network player because client is not connected
Enable module 'analytics' for 'Firebase.Analytics.FirebaseAnalytics, Firebase.Analytics'
Enable module 'auth' for 'Firebase.Auth.FirebaseAuth, Firebase.Auth'
Enable module 'storage' for 'Firebase.Storage.FirebaseStorage, Firebase.Storage'
SetVideoSource for user 0, chanelId 
Firebase initialized: Available
Cloud Storage gs://*******.appspot.com: Created __FIRAPP_DEFAULTgs://*******.appspot.com
Disabling all app initializers
Disable analytics
Disable app_check
Disable auth
Disable crashlytics
Disable database
Disable dynamic_links
Disable functions
Disable messaging
Disable remote_config
Disable storage
analytics app initializer Enabling
app_check app initializer Disabling
auth app initializer Enabling
crashlytics app initializer Disabling
database app initializer Disabling
dynamic_links app initializer Disabling
functions app initializer Disabling
App initializer installations not found, failed to enable.
App initializer invites not found, failed to enable.
messaging app initializer Disabling
App initializer performance not found, failed to enable.
remote_config app initializer Disabling
storage app initializer Enabling
App initializer test_lab not found, failed to enable.
Database URL not set in the Firebase config.
Creating Firebase App __FIRAPP_DEFAULT for Firebase C++ 12.2.0
Validating semaphore creation.
Added app name=__FIRAPP_DEFAULT: options, api_key=*****************************, app_id=*:***********:android:*******************, database_url=, messaging_sender_id=**********, storage_bucket=**********.appspot.com, project_id=********** (*********)
id: Development

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

No response

@An-try An-try added new New issue. type: bug labels Sep 5, 2024
@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.

@dconeybe
Copy link
Contributor

dconeybe commented Sep 5, 2024

Hi @An-try. What type of mac are you using? Namely, is it an Intel-based or ARM-based CPU? Also, please enable debug logging, reproduce, and attach updated logs. To enable debug logging, run FirebaseFirestore.LogLevel = LogLevel.Debug before doing anything with Firestore. If you are able to attach a zip file of a complete project that would also be helpful.

@An-try
Copy link
Author

An-try commented Sep 5, 2024

Hi @dconeybe.

I’m using a MacBook Pro with a 2.3 GHz Quad-Core Intel Core i5.

I have already enabled FirebaseApp.LogLevel = LogLevel.Debug, but enabling FirebaseFirestore.LogLevel = LogLevel.Debug didn’t change the logs. If needed, I can attach the logs below.

I will also prepare the Unity project and send it to you soon.

[UnityMemory] Configuration Parameters - Can be set up in boot.config
    "memorysetup-bucket-allocator-granularity=16"
    "memorysetup-bucket-allocator-bucket-count=8"
    "memorysetup-bucket-allocator-block-size=4194304"
    "memorysetup-bucket-allocator-block-count=1"
    "memorysetup-main-allocator-block-size=16777216"
    "memorysetup-thread-allocator-block-size=16777216"
    "memorysetup-gfx-main-allocator-block-size=16777216"
    "memorysetup-gfx-thread-allocator-block-size=16777216"
    "memorysetup-cache-allocator-block-size=4194304"
    "memorysetup-typetree-allocator-block-size=2097152"
    "memorysetup-profiler-bucket-allocator-granularity=16"
    "memorysetup-profiler-bucket-allocator-bucket-count=8"
    "memorysetup-profiler-bucket-allocator-block-size=4194304"
    "memorysetup-profiler-bucket-allocator-block-count=1"
    "memorysetup-profiler-allocator-block-size=16777216"
    "memorysetup-profiler-editor-allocator-block-size=1048576"
    "memorysetup-temp-allocator-size-main=4194304"
    "memorysetup-job-temp-allocator-block-size=2097152"
    "memorysetup-job-temp-allocator-block-size-background=1048576"
    "memorysetup-job-temp-allocator-reduction-small-platforms=262144"
    "memorysetup-allocator-temp-initial-block-size-main=262144"
    "memorysetup-allocator-temp-initial-block-size-worker=262144"
    "memorysetup-temp-allocator-size-background-worker=32768"
    "memorysetup-temp-allocator-size-job-worker=262144"
    "memorysetup-temp-allocator-size-preload-manager=262144"
    "memorysetup-temp-allocator-size-nav-mesh-worker=65536"
    "memorysetup-temp-allocator-size-audio-worker=65536"
    "memorysetup-temp-allocator-size-cloud-worker=32768"
    "memorysetup-temp-allocator-size-gfx=262144"
Mono path[0] = '/Users/**********/Library/Developer/Xcode/DerivedData/7-athypxnicyziwyhimuerzhyefppf/Build/Products/Release/**********.app/Contents/Resources/Data/Managed'
Mono config path = '/Users/**********/Library/Developer/Xcode/DerivedData/7-athypxnicyziwyhimuerzhyefppf/Build/Products/Release/**********.app/Contents/MonoBleedingEdge/etc'
[Physics::Module] Initialized MultithreadedJobDispatcher with 7 workers.
Initialize engine version: 2022.3.20f1 (61c2feb0970d)
[Subsystems] Discovering subsystems at path /Users/**********/Library/Developer/Xcode/DerivedData/7-athypxnicyziwyhimuerzhyefppf/Build/Products/Release/**********.app/Contents/Resources/Data/UnitySubsystems
GfxDevice: creating device client; threaded=1; jobified=0
Color LCD preferred device: Intel(R) Iris(TM) Plus Graphics 655 (low power)
Metal devices available: 1
0: Intel(R) Iris(TM) Plus Graphics 655 (low power)
Using device Intel(R) Iris(TM) Plus Graphics 655 (low power)
Initializing Metal device caps: Intel(R) Iris(TM) Plus Graphics 655
Begin MonoManager ReloadAssembly
- Loaded All Assemblies, in  0.393 seconds
- Finished resetting the current domain, in  0.003 seconds
UnloadTime: 1.947683 ms
<color=green>[Network]</color> Cannot get local network player because client is not connected
Enable module 'analytics' for 'Firebase.Analytics.FirebaseAnalytics, Firebase.Analytics'
Enable module 'auth' for 'Firebase.Auth.FirebaseAuth, Firebase.Auth'
Enable module 'storage' for 'Firebase.Storage.FirebaseStorage, Firebase.Storage'
SetVideoSource for user 0, chanelId 
Firebase initialized: Available
Cloud Storage gs://**********.appspot.com: Created __FIRAPP_DEFAULTgs://**********.appspot.com
Disabling all app initializers
Disable analytics
Disable app_check
Disable auth
Disable crashlytics
Disable database
Disable dynamic_links
Disable functions
Disable messaging
Disable remote_config
Disable storage
analytics app initializer Enabling
app_check app initializer Disabling
auth app initializer Enabling
crashlytics app initializer Disabling
database app initializer Disabling
dynamic_links app initializer Disabling
functions app initializer Disabling
App initializer installations not found, failed to enable.
App initializer invites not found, failed to enable.
messaging app initializer Disabling
App initializer performance not found, failed to enable.
remote_config app initializer Disabling
storage app initializer Enabling
App initializer test_lab not found, failed to enable.
Database URL not set in the Firebase config.
Creating Firebase App __FIRAPP_DEFAULT for Firebase C++ 12.2.0
Validating semaphore creation.
Added app name=__FIRAPP_DEFAULT: options, api_key=**********, app_id=*:**********:android:**********, database_url=, messaging_sender_id=**********, storage_bucket=**********.appspot.com, project_id=********** (**********)
id: Development

@dconeybe
Copy link
Contributor

dconeybe commented Sep 5, 2024

Thank you for the extra info. Could you try two things for me and let me know if the crash still occurs:

  1. Delete the call to Listen()
  2. Change the call to Listen() to GetSnapshotAsync()

@dconeybe
Copy link
Contributor

dconeybe commented Sep 5, 2024

@An-try Can you also try running https://github.com/firebase/quickstart-unity to see if you experience the same crash?

@dconeybe dconeybe self-assigned this Sep 5, 2024
@dconeybe
Copy link
Contributor

dconeybe commented Sep 5, 2024

Oh, another thing: Are you calling FirebaseApp.CheckAndFixDependenciesAsync()? Make sure that you are doing this, as per the example in the quickstart: https://github.com/firebase/quickstart-unity/blob/3e667f84276c0d079eca89cc5e7e8764ae3c6358/firestore/testapp/Assets/Firebase/Sample/Firestore/UIHandler.cs#L64-L74

@An-try
Copy link
Author

An-try commented Sep 5, 2024

I am calling FirebaseApp.CheckAndFixDependenciesAsync(), and it works, as indicated by the log message Firebase initialized: Available that I sent previously.

I also tried the Firestore quickstart project and experienced the same issue.

I tried removing the Listen call and leaving only Debug.Log while retrieving the CollectionReference (FirebaseFirestore.DefaultInstance.Collection("Development")). For some reason, this is crashing the app too. Additionally, my other two Firestore methods also start crashing the app after that. And I experience this behaviour only in build, in Unity Editor everything fine. Something strange is happening and I will get back to this later and try to check all this again.

@An-try
Copy link
Author

An-try commented Sep 6, 2024

Hi @dconeybe

I created a completely new Firebase project and used the Firestore quickstart project, but I'm experiencing crashes on any button press in this quickstart project only in builds for macOS. I set everything up according to the guides, and everything works fine in the Unity Editor on macOS, but not in Xcode or the built .app.

I tested this on two different Mac devices:

MacBook Pro, 2.3 GHz Quad-Core Intel Core i5, macOS Sonoma 14.6.1 (23G93)
MacBook Pro, Apple M1 Pro, macOS Sonoma 14.6.1 (23G93)

I have no pending updates for my system or Xcode (v15.4).

I think we can close this issue and open a new one in the quickstart GitHub repository?

@An-try
Copy link
Author

An-try commented Sep 6, 2024

Also, I tested it with Unity 2022.3.20f1, Unity 2022.3.44f1, Unity 2023.2.19f1
And the newest Firebase package 12.2.1

@An-try
Copy link
Author

An-try commented Sep 6, 2024

Additionally, I tried creating a build (.app) directly from Unity without using Xcode, and the issue still persists.

@argzdev
Copy link

argzdev commented Sep 6, 2024

Hey @An-try, just wanted to add some insights here. I noticed that I was also able to replicate the crashing behavior on macOS platform with our Firebase Unity Quickstart for Firestore. However, I accidentally resolved this after adding my login for the keychain.

Screenshot 2024-09-06 at 8 37 34 PM

Steps I took:

  1. Opened Firestore quickstart
  2. Added Firebase Auth Sign In Anonymously (We've setup Firestore rules to restrict unauthorized transactions)
  3. Build and Run for macOS, app crashes after any transaction with Firestore
  4. Tried changing platform to iOS
  5. Tested with iOS, app runs normal
  6. Changed platform back and run macOS
  7. The referenced pop up showed up to add login credential for keychain
  8. The built macOS app no longer crashes.

I wonder if the issue in your case is also the same, though I'm not sure how to trigger or show the login credential for keychain manually. Let me know if this helps!

@argzdev argzdev added the needs-info Need information for the developer label Sep 6, 2024
@An-try An-try changed the title [Bug] Crash on macOS build when using Firestore Listen() call [Bug] Crash on macOS build when using any Firestore method call Sep 10, 2024
@An-try
Copy link
Author

An-try commented Sep 11, 2024

@argzdev Unfortunately, I cannot reproduce your solution. The keychain popup is not showing up after several attempts. I will look for a way to manually trigger this window somehow... or maybe another solusion

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore needs-attention Need Googler's attention
Projects
None yet
Development

No branches or pull requests

4 participants