Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
Is Firebase Unity SDK eating exceptions on the main thread?

The second half of the code in one of my methods is not running. Unity logs main thread exceptions to the console by default. Even though my function is running on the main thread, I don't see any error logs in console. This makes finding bugs and fixing the code really really cumbersome.

Here is my method simplified:

    private void DoInitialize() {
        LogWarn($"HERE 1.5 item {i}"); // this prints
        LogWarn($"THIS SHIT {i.shardPrice.amount}"); // this causes a null pointer exception
        LogWarn($"HERE 1.6 item {i}"); // this doesn't print
    }

I attached the debugger and stepped through code until I found the line that is causing the issue. Commenting out the line will cause the program to run correctly. Upon inspection it turns out I have a null pointer exception in that line.

How do I know the code is running on the main thread? I print the Thread.CurrentThread.ManagedThreadId.ToString() before the faulty line and in Start() callbacks and make sure the id is the same.

Here is the stack trace of the thread just before it goes to some random place I don't have the symbols for. My only explanation for this is that Firebase methods at the bottom of the stack catch the exception and don't let it propagate to Unity. enter image description here

Here are my questions:

  1. Am I missing something in my diagnosis?
  2. How can I confirm Firebase actually catches the exceptions? The SDK code is not on github so I can't take a look at the code. Can someone from the Firebase team verify this?
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I realized that since firebase uses C# Tasks, it is expected that the exceptions are caught. I wrote a helper method to print task exceptions to console. You can use it for tasks that you expect to succeed (just like normal Unity code).

    public static class TaskExts {
        public static void LogExceptionIfFaulted(this Task task) {
            task.ContinueWithOnMainThread(t => {
                if (t.IsFaulted) {
                    Debug.LogException(t.Exception.Flatten().InnerException);
                }
            });
        }
    }

usage

    FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task => {
        // custom code which may throw exceptions
    }).LogExceptionIfFaulted();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda