firebase / firebase/quickstart-unity

iOS support is required on Windows for a Firebase project, causing Unity to not respond when I build for Android

Open
#1,003 7 comments 0 reactions 0 assignees View on GitHub
api: database type: bug
Dominant language
C#
Stars
923
Forks
456
PR merge metrics
No merged PRs in 30d

Description

### [REQUIRED] Please fill in the following fields:

* Unity editor version: 2020.3.0.f1
* Firebase Unity SDK version: 7.1.0
* Source you installed the SDK: Unity Package Manager
* Problematic Firebase Component: App, RealtimeDatabase
* Other Firebase Components in use: Auth.
* Additional SDKs you are using: AdMob.
* Platform you are using the Unity editor on: Windows.
* Platform you are targeting: Android.
* Scripting Runtime: IL2CPP

### [REQUIRED] Please describe the issue here:

From what I have been able to observe the database does not give an answer, it does not give the data or an error.
The problem appears in the APK not in the Editor. In the Editor it works.

#### Steps to reproduce:

do you need my Unity package name?

create a test database with:
season = 1

1 create a 3D project in Unity.
2 create the script "testFB".
3 copy and paste the code (code at the end).
4 create any object in the scene "Create Empty".
5 add the script "testFB" to the new object.
6 create a Canvas then panel and inside a Text.
7 adjust the sizes of the GUI.
8 add the created Text to the script in Result.
9 the project must run in the editor. Should read "1" from the database.
10 build the project for Android and it will stop working

#### Relevant Code:

```
// TODO(you): code here to reproduce the problem

using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using Firebase;
using Firebase.Database;
using System.Text;
public class testFB : MonoBehaviour
{
private FirebaseApp app;
DependencyStatus dependencyStatus;
public Text result;
public int season;
bool ready;
void Start()
{
season = 10;
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available)
{
app = Firebase.FirebaseApp.DefaultInstance;
ready = true;
}
else
{
Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
}
});
StartCoroutine(ReadSeason());
}
private IEnumerator ReadSeason()
{
//Query season numbre should return: 1
yield return new WaitForSeconds(1f);
Debug.Log("done1");
result.text = "done1";
if (ready)
{
DataSnapshot snapshot;
DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("season");
var DBtask = reference.GetValueAsync();
yield return new WaitUntil(predicate: () => DBtask.IsCompleted);
//<-- Here it stops working, it just waits for an answer.

result.text = "done2";
Debug.Log("done2");
if (DBtask.Exception != null)
{
Debug.Log("no");
result.text = "no";
result.text = DBtask.Exception.ToString();
}
else
{
Debug.Log("yes");
result.text = "yes";
snapshot = DBtask.Result;
season = int.Parse(snapshot.Value.ToString());
Debug.Log(season.ToString());
result.text = season.ToString();
}
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

The report provides no repository file or test; start by reproducing the inline testFB script in Unity 2020.3.0.f1 with Firebase Unity SDK 7.1.0, then build for Android on Windows. Compare the Editor and APK behavior around CheckAndFixDependenciesAsync and GetValueAsync; done means the Android build completes the read and displays the database value 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, firebase, unity
Domain
databases, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.