firebase / firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
https://firebase.google.com/
Apache License 2.0
4.58k stars 1.06k forks source link

Redirection after authentication is very slow #436

Closed deepfriedbrain closed 6 years ago

deepfriedbrain commented 6 years ago

I'm migrating from Google Identity Toolkit to Firebase Auth and noticed that the redirection to the signInSuccessUrl after successful authentication takes on average 6 secs to complete. The loading bar goes across 3-4 times before the redirection is completed. Is this considered normal? It is significantly slower than the Identity Toolkit.

I also noticed that it is spitting several messages started with Received message: in the browser console while the redirection is taking place. It shouldn't be logging anything to the console unless it's running in some kind of debug mode.

Note that I'm currently testing it on localhost. Could that be the reason for seeing those log messages?

bojeil-google commented 6 years ago

We have added optimization in the latest version. It should take less than a second. You can try it out in our demo app: https://fir-ui-demo-84a6c.firebaseapp.com/widget. We do not log anything in the console (apart from deprecation notices which can be addressed). You must be using accountchooser.com. These logs are coming from that and not from firebaseui.

deepfriedbrain commented 6 years ago

Thanks for the help.

I switched to the latest version and I do see an improvement of 33% in the sense that the bar now moves across 2 times compared to 3 times earlier. It's more like 4 secs now (compared to 6 secs with the previous version).

I compared it with the demo app and it's exactly the same i.e. the bar moves across 2 times before the redirection is done. It's nowhere close to 1 sec.

With Identity Toolkit, it's definitely less than 1 sec and that's what I was hoping to get with Firebase Auth, but the latter is still about 4x slower.

UPDATE 1:

The Google and Facebook logins are slow (~4 secs) but the email/password login is much faster (~1 sec).

I also continue to see log messages in the console. I'm not using accountchooser.com as far as I can tell but you are right that the messages are coming from accountchooser. I don't see the log messages in the demo app though.

Here's my configuration:

<body>
    <div id="firebaseui-auth-container"></div>

    <script type="text/javascript">
        var uiConfig = {
            'signInSuccessUrl': '/',
            'signInOptions': [
                firebase.auth.GoogleAuthProvider.PROVIDER_ID,
                firebase.auth.FacebookAuthProvider.PROVIDER_ID,
                firebase.auth.EmailAuthProvider.PROVIDER_ID
            ],
            'tosUrl': '/terms',
            'credentialHelper': firebaseui.auth.CredentialHelper.NONE
        };

        var ui = new firebaseui.auth.AuthUI(firebase.auth());
        ui.start('#firebaseui-auth-container', uiConfig);

    </script>
</body>

CredentialHelper is set to NONE, but for some reason accountchooser is still interfering. Is there anything that I may be missing? Could that be slowing down the redirection?

bojeil-google commented 6 years ago

This is not a subjective issued. We reduced 2 network requests from the sign in flow. The issue is clearly related to your environment. Google identity toolkit's dependency on accountchooser.com also logged console messages. You don't see the messages in the demo app because it uses one-tap sign-up as its credential manager.

deepfriedbrain commented 6 years ago

There are 2 issues here. Let's deal with them separately. I will create a separate issue for the log messages. Let this issue focus on the slow sign in redirection.

Federated sign in (Google/Facebook) flow is slow. Email/password sign in is fine. It is slow in the Demo app too. That can't be related to my environment. And as I said, I do see improvement from yesterday, but 4 secs to redirect is still very slow.

I'm on a high end hardware and very fast broadband connection. So those can't be the factors for sure. Also, Google Identity Toolkit doesn't exhibit this slowness.

bojeil-google commented 6 years ago

This is the expected behavior of signInWithRedirect. There is nothing we can change about it. We don't do anything fancy here. We call signInWithRedirect on a copy of the Auth instance when the redirect is triggered and then on return to page, after sign in completion (automatically done under the hood by underlying SDK), we call updateCurrentUser to copy the result to the Auth instance you provide. The latter makes no additional network call. There is little FirebaseUI can change here. If you have an issue with this, open one with the core Firebase JS SDK

The code is open sourced. If you have suggestions on how to improve, your contribution would be more than welcome.

We would also appreciate more complete and verifiable examples when opening issues. Thank you.

deepfriedbrain commented 6 years ago

I'm willing to provide all the details that I can, but since this issue is reproducible on your demo app, I don't know what other verifiable examples can I provide. Are you saying that you don't see the 3-4 sec delay? Should I do a screen recording to share with you as proof? Let's first establish whether you acknowledge the 3-4 secs delay or not. If you do, then I'll file an issue with Firebase JS SDK.

As I've mentioned before, I'm currently on Google Identity Toolkit and it doesn't suffer from this delay. It is also using signInWithRedirect. What is different with Firebase Auth then?

Identity toolkit is partially broken (password reset is not working) and there's no proper channel to get support for it. That forced me to kick-off the migration to Firebase Auth that Firebase Auth is not working even half as good as Identity Toolkit. As a developer, I put a lot of trust in Google and always thought that if I go with a Google product, I can't go wrong. But Firebase Auth seems like a half-baked product with lots of problem and no proper channel to get support. The responses from the Firebase support channel have been mostly non-technical and unhelpful.

deepfriedbrain commented 6 years ago

@bojeil-google I have uploaded a screen recording to show the slow redirection in real-time. After selecting a Google account when the empty white box with a progress bar at the top is shown, the bar moves across about 1 and a 3 quarter (1.75) times. This is about 3 secs. This is in fact on the faster side as the average is 2-3 times.

I'm not sure how you claim it to be about a second.

Link to the video recording:

https://drive.google.com/open?id=1kAHMIgjzYw0S6wS4yMXEdTxAJiuI8BCp

bojeil-google commented 6 years ago

I can't replicate this on my end. I have tested dozens of times with our demo app https://fir-ui-demo-84a6c.firebaseapp.com/widget on Chrome/Linux and Safari/Mac browsers and it takes a second to complete the sign in. As I explained, there may be local factors affecting this on your end. It is not possible for me to speculate on the cause with the information I have.

deepfriedbrain commented 6 years ago

@bojeil-google Thanks for confirming that you are "not" seeing this issue. Taking a clue from this, I used an online browser simulator and the performance is much better (1-2 secs).

So I'm "speculating" that it may have something to do with geographical location. I'm based in SE Asia and that may be causing the delay. The simulator is connection from Montreal, Canada.

Other than that, I have tried it from 2 different MBPs and an iPhone, 3 different browsers (Chrome, FF, Safari) across these devices, 3 different networks (home, office and mobile), and it consistently gives me the same 3-6 secs redirection delay.

But using the simulator, I'm able to get a much better performance. Do you think it would be slower from Asia? But again, I don't have this slow redirection issue with Google Identity Toolkit and I've been using it for more than 2 years now, and also it's just with federated logins. Email/password login works fine.

I don't want to give up because I'm pretty sure there's a genuine problem here. Addressing it would not just help me but other customers too.

alvinwoon commented 5 years ago

Just want to add another datapoint that this issue is still prominent in east Asia (Tokyo, Taipei). Specifically the redirects flow from login -> home page. I found a couple questions on SO that exactly mirror my experience.

https://stackoverflow.com/questions/41158695/firebase-authentication-using-google-redirect-redirects-to-my-login-page

dandv commented 5 years ago

I've previously reported major slowness when logging in with Twitter, and the problem still persists.

Here's logging in with Twitter to the Firebase Auth demo:

Firebase redirection slow Twitter

And here's logging in with Twitter to Spectrum.chat. Way, way faster:

Spectrum chat redirection FAST Twitter

Wirespec commented 4 years ago

Signing in with Github is really slow if the user is signing in for the first time and needs to authorize the app. It takes around 10 seconds. Way too slow to be of any practical use for end users. I can't recommend Firebase authentication. Handling the sign in manually with Github is the only way to go.

nikita-fuchs commented 4 years ago

Can confirm waiting times for google login and facebook login of up till 6 seconds.

lightsound commented 4 years ago

I also have the same problem. Twitter login takes more than 4 seconds.

rajorpratyush commented 3 years ago

The problem i think is with local isp blocking some service or I dunno slowing firebase services. I have seen this happening a lot lately in India where firebase auth and sometimes hosting goes timeouts and sometime works fine and this behaviour varies around different isp's all across country

thomashagstrom commented 3 years ago

How is this closed? The service is still unusable due to this performance issue

nikita-fuchs commented 3 years ago

In my case, I have the suspicion that already running realtime database connections clogg up the processing queue on google's side. Can anyone verify if removing them speeds up the login?

dandv commented 3 years ago

@nikita-fuchs In my comment above, I wasn't using the database at all.

pedrorabbi commented 2 years ago

Still very slow (Google and Facebook ~20 seconds). For me, the issue happens only on mobile (Safari-iPhone). It has nothing to do with my internet connection (200Mbps fiber). In computer, the sign in with both (Facebook and Google) is pretty fast.

pedrorabbi commented 2 years ago

Just found out that the problem was that my local IP wasn´t whitelisted as a domain on Firebase. Added it on Firebase console and now the redirect is pretty fast (even on mobile), on both Facebook and Google.

sbrett commented 10 months ago

I'm experiencing this on mobile web (Chrome browser on Pixel) after signing in with google. Taking approx 20 seconds