onAuthStateChanged inconsistent
<p>When a user comes to my site, I use <code>onAuthStateChanged</code> to determine if the user is already signed-in from a previous session or not.</p>

<p>Main issue is that it has been inconsistent for a small % of users - code seems to not be detecting that they do have a valid signed-in session going on.</p>

<p>The following code is on the app itself, users are on that page after a redirect from the homepage or login page.</p>

<p>The homepage of the site also uses <code>onAuthStateChanged</code> to determine if the user should be redirected to the app directly. The login page uses signInWithEmailAndPassword and when the log in is successful, redirects them to the app page (which has the following code).</p>

<pre><code>firebase.auth().onAuthStateChanged(function (authUser) {
  if (authUser) return initApp(authUser);

  // issue: sometimes users that *should* be signed-in get signed in anonymously here
  firebase.auth().signInAnonymously().then(function (authUser) {
    initApp(authUser);
  }
});
</code></pre>

<p>Is <code>onAuthStateChanged</code> just not something I should be using for my use case? Any idea how to improve / fix this?</p>

<p>Edit: This SEEMS to happen more with users on mobiles.</p>