solid-contrib / solid-auth-fetcher

A client library for authenticating with Solid
Other
2 stars 7 forks source link

Logging in freezes the UI #18

Open NoelDeMartin opened 3 years ago

NoelDeMartin commented 3 years ago

There are some situations where the UI is frozen for a couple of seconds after calling the login method. I'm not sure why it happens, and sometimes it works properly on subsequent logins so maybe it has something to do with data stored in the browser.

To reproduce this, you can visit ramen.noeldemartin.com, click on "try using a different authentication method" and select "Log in using the community authentication library". I have tried both in Firefox and Chrome, and it's more accentuated using Firefox.

If this isn't a bug I think it'd be nice to provide an API that allows calling login within a web worker that wouldn't block the UI. Which I know is not easy as it sounds, because web workers need to be served on a different file. Just throwing ideas :).

josephguillaume commented 3 years ago

I can see the animation pause, and my guess is that it's related to localStorage. Some profiling would be needed to work out which storage calls are noticeable to the user, but this potentially seems like a good starting point: https://github.com/solid/solid-auth-fetcher/blob/1407fb9dacdfa8bf0cd31f397161ae27ce980704/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts#L81

setForUser is re-writing userData for each key, whereas it could just be done once. https://github.com/solid/solid-auth-fetcher/blob/1407fb9dacdfa8bf0cd31f397161ae27ce980704/src/localStorage/StorageUtility.ts#L125-L129

If that doesn't sufficiently fix the issue, this might not be high priority given this is not the preferred auth solution and it's not a particularly long pause (at least on my system).