Firebase onAuthStateChanged callback takes 20+ seconds sometimes : <p>We've been using Firebase on our applications after moving away from our own NodeJS backend running express and during this transition we've noticed one major drawback. The amount of time it takes for the initial auth state to be received by the client.</p>

<p>When my application is opened I <strong>immediately</strong> register the <code>onAuthStateChanged</code> callback to start listening for changes in authentication state, that way I can route the user to either their personal hub or the authentication screen. </p>

<p>The problem is that while sometimes this only takes a few milliseconds, at other times (Independant of internet connection) it takes anywhere from 20+ seconds, causing an extremely poor user experience. </p>

<p>We're using the Firebase WEB API on a UIWebView component.</p>

<p>I've tested this on 3G, 4G, LTE and Wifi and it's completely random. Sometimes it loads like lightning. Sometimes it's so slow that I question the reliability of the service. </p>

<p>Some may argue that this is due to the user data we have to download, but the 20-30 seconds that we're waiting is before we even attempt to pull data from the server. This is just to get the initial authorization state. We're only using email providers.</p>

<p>Does anyone know what we could do to improve this? On average the <code>onAuthStateChanged</code> callback is defined <code>562ms</code> after the applications execution. After this sometimes it can take <code>20-200ms</code> (Average latency) and sometimes it takes 20000ms+</p>
