[Bug] Editor crashes in AppUtilPINVOKE.PollCallbacks after domain reload when a custom App Check provider factory is registered
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start with app_check/src/swig/app_check.i and app_check/src/FirebaseAppCheck.cs, tracing SetAppCheckProviderFactory through AppCheckUtil.SetGetTokenCallback and the callbacks invoked by PollCallbacks. Read app/platform/Unity/FirebaseEditorDispatcher.cs around OnCleanupEvent to compare existing reload cleanup. Done means reproducing or isolating the stale-callback crash and ensuring callbacks are safely reset across domain reload or editor shutdown.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The Unity Editor intermittently crashes with a native access violation (DEP violation)
inside Firebase.AppUtilPINVOKE.PollCallbacks on the first Play after a domain reload
(script recompilation or asset import).
Our project has Enter Play Mode Options enabled with domain reload disabled
(EnterPlayModeOptions.DisableDomainReload), so a domain reload only happens on
script recompilation or asset import, not on every Play.
We started seeing this after upgrading both the Unity Editor (6000.0.59f2 -> 6000.0.83f1)
and the Firebase Unity SDK (13.9.0 -> 13.16.0) within the same week.
We have not isolated which of the two upgrades triggered it.
Expected: entering Play mode after a domain reload works normally.
Actual: the editor crashes in PollCallbacks.
Frequency observed in our editor logs:
- First Play right after a domain reload: 22 crashes / 97 Play sessions
- Play without a preceding domain reload: 0 crashes / 29 Play sessions
Suspected cause:
FirebaseAppCheck.SetAppCheckProviderFactory(factory) registers C# delegates through
AppCheckUtil.SetGetTokenCallback, which stores them in the static native globals
g_get_token_from_csharp / g_get_limited_use_token_from_csharp.
A token request queues CallGetTokenFromCSharp via callback::AddCallback,
which is then executed from PollCallbacks.
On domain reload the old AppDomain and its delegates are unloaded, but nothing resets these
native function pointers. The editor cleanup added in 13.16.0
(FirebaseEditorDispatcher.OnCleanupEvent -> DisposeAllApps() + Terminate()) does not
clear the App Check callbacks either. In our project a sign-in can issue a token request in
the new domain before the factory is registered again, so PollCallbacks appears to invoke
a stale function pointer.
References (v13.16.0):
- https://github.com/firebase/firebase-unity-sdk/blob/v13.16.0/app_check/src/swig/app_check.i#L48-L50
- https://github.com/firebase/firebase-unity-sdk/blob/v13.16.0/app_check/src/FirebaseAppCheck.cs#L105-L110
- https://github.com/firebase/firebase-unity-sdk/blob/v13.16.0/app/platform/Unity/FirebaseEditorDispatcher.cs#L227-L231
Workaround:
We added an editor script that clears the callbacks right before the reload:
[InitializeOnLoad]
static class AppCheckReloadGuard
{
static AppCheckReloadGuard()
{
AssemblyReloadEvents.beforeAssemblyReload += () =>
FirebaseAppCheck.SetAppCheckProviderFactory(null);
}
}
Because the crash is intermittent, we have not been able to confirm whether this workaround
fully prevents it.
Suggested fix: reset the App Check get-token callbacks (SetGetTokenCallback(null, null))
when the editor reloads the domain or quits, for example from a beforeAssemblyReload /
DomainUnload handler in the App Check module.
Reproducing the issue
These steps are derived from our project and have not been confirmed in a clean project.
- Unity 6000.0.83f1, Firebase Unity SDK 13.16.0 (App, App Check, Auth),
Enter Play Mode Options enabled with domain reload disabled. - Before FirebaseApp initialization, register a custom factory:
class DummyProviderFactory : IAppCheckProviderFactory
{
public IAppCheckProvider CreateProvider(FirebaseApp app) => new DummyProvider();
}
class DummyProvider : IAppCheckProvider
{
public Task<AppCheckToken> GetTokenAsync() =>
Task.FromResult(new AppCheckToken { Token = "dummy", ExpireTime = DateTime.UtcNow.AddHours(1) });
public Task<AppCheckToken> GetLimitedUseTokenAsync() => GetTokenAsync();
}
- Enter Play mode and sign in (e.g. anonymous auth), then exit Play mode.
- Edit any script to trigger a domain reload.
- Enter Play mode and sign in before calling SetAppCheckProviderFactory again.
- The editor intermittently crashes in PollCallbacks (see the frequency above).
Firebase Unity SDK Version
13.16.0
Unity editor version
6000.0.83f1
Installation Method
Unity Package Manager
Problematic Firebase Component(s)
App Check
Other Firebase Component(s) in use
Analytics, Authentication, Firestore, Functions, Installations, Messaging, Remote Config
Additional SDKs you are using
No response
Targeted Platform(s)
Desktop
Unity editor platform
Windows
Scripting Runtime
Mono
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
Expand Podfile.lock snippet
👀 Replace this line with the contents of your Podfile.lock!
- Lingua principale
- C#
- Stelle
- 325
- Fork
- 62
- Merge medio
- 1g 17h
- PR unite (30g)
- 13
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di firebase/firebase-unity-sdk
-
[Bug] Desktop managed DLLs marked Required32Bit fail to load on ARM64 CoreCLR (Unity 7 alpha)Forse già presa @AustinBenoit l’ha presa oggi. Apertaapi: core desktop production type: bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
firebase/firebase-unity-sdk#1566 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
api: core
Difficoltà 4/5 3-5 giorni Idoneità per principianti 43/100
firebase/firebase-unity-sdk#1562 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
api: crashlytics type: question
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
firebase/firebase-unity-sdk#1560 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] App Check (iOS): crash in TokenChangedMethod because AppCheckToken.expire_time_millis is left uninitializedForse già presa @AustinBenoit l’ha presa 7 giorni fa. Apertaapi: appcheck type: bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
firebase/firebase-unity-sdk#1556 · 6 commenti · 1 reazione · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
api: firestore type: feature request
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
firebase/firebase-unity-sdk#1543 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di firebase/firebase-unity-sdk
Issue simili
-
Support Flux ignore rules (drift detection ignore paths) in Microsoft.KubernetesConfiguration schemaAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Azure/azure-resource-manager-schemas#3921 ·
I maintainer di solito rispondono entro 1 giorno
-
text-align: justify is ignored in HTML to PDF conversionForse già presa @PrzemyslawKlys l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 4 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100