firebase / firebase/firebase-unity-sdk

[Question] Why does FirebaseDatabase.GetInstance(URL) never fail except when passing in an empty or null URL?

Open
#1,155 3 comments 0 reactions 0 assignees View on GitHub
api: database type: bug
Dominant language
C#
Stars
320
Forks
60
Avg merge
11h 15m
Merged PRs (30d)
11

Description

### What is your question?

As the question suggest, if I pass any string at all into that function I get back a FirebaseDatabase instance.

If I try to use that instance to get a ref - the process simple hangs, no errors, no exceptions, just nothing.

That's the internal code so it seems like it thinks it could be null - but the cpp side of things seems to just new one up regardless of the URL validity.

If this is intentional - how can I check if I have a valid FirebaseDatabase instance?

```
FirebaseDatabase value = null;
string key = $"({app.Name}, {url})";
lock (databases)
{
if (!databases.TryGetValue(key, out value))
{
InitResult init_result_out;
InternalFirebaseDatabase instanceInternal = InternalFirebaseDatabase.GetInstanceInternal(app, url, out init_result_out);
if (instanceInternal == null || init_result_out != 0)
{
throw new DatabaseException("Failed to get FirebaseDatabase instance. Please check the log for more information.");
}

value = new FirebaseDatabase(app, instanceInternal);
value.name = key;
databases[key] = value;
}
}
```

### Firebase Unity SDK Version

12.3

### Unity editor version

2022.3.43f1

### Installation Method

Unity Package Manager

### Problematic Firebase Component(s)

Database

### Other Firebase Component(s) in use

Authentication

### Additional SDKs you are using

_No response_

### Targeted Platform(s)

Apple Platforms, Android

### Unity editor platform

Windows

### Scripting Runtime

IL2CPP

### Release Distribution Type

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.