Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari 12.1.1: All text fields empty after login to YouTrack #1

Open
fschopp opened this issue Jun 2, 2019 · 3 comments
Open

Safari 12.1.1: All text fields empty after login to YouTrack #1

fschopp opened this issue Jun 2, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@fschopp
Copy link
Owner

fschopp commented Jun 2, 2019

Unfortunately, localStorage and sessionStorage seem to be unreliable in some browsers. Safari 12.1.1 exhibits a similar behavior as described in this StackOverflow post. Both localStorage and sessionStorage sometimes appear empty if our function handlePotentialOauthRedirect() is called “too soon” (and they remain empty while staying on the same page). Unlike hypothesized in the StackOverflow discussion, however, the issue in Safari still occurs when this function is called only after the DOM-ready event. The workaround mentioned on StackOverflow -- accessing sessionStorage.length -- does not help.

Interestingly, after one or sometimes multiple reloads (in the same window/tab), Safari suddenly does show the expected key/value pairs (as expected in the first place -- since we previously created them in goToOauthPage()). Since Safari switches to a new process when goToOauthPage() sets window.location.href, it’s possible that instead of the new process accessing sessionStorage “too soon,” it is actually the previous process that persists sessionStorage “too late.” Indeed, Safari writes sessionStorage updates to disk with a delay of up to 1 second:
https://trac.webkit.org/browser/webkit/releases/Apple/Safari%2012.1.1/WebKit/UIProcess/WebStorage/LocalStorageDatabase.cpp#L235

Other relevant source code in WebKit:

The following FIXME in the WebKit code could be a contributor to the problem, too:

Interestingly, the FIXME suggestion could be done easily, given this changeset:

There is also another StackOverflow post mentioning the above StackOverflow post (though no conclusive answer, either).

@fschopp fschopp added the bug Something isn't working label Jun 2, 2019
@fschopp
Copy link
Owner Author

fschopp commented Jul 19, 2019

A simple self-contained test case is here. See also this repository: https://github.com/fschopp/safari-local-storage-bug

@fschopp
Copy link
Owner Author

fschopp commented Jul 19, 2019

Upstream report: Bug 199928 in WebKit Bugzilla

@fschopp
Copy link
Owner Author

fschopp commented Jul 19, 2019

For now, the only known workaround is an artificial delay before calling handlePotentialOauthRedirect(). See https://fschopp.github.io/safari-local-storage-bug/ for details.

fschopp added a commit that referenced this issue Jul 19, 2019
In light of Safari/WebKit bug 199929, add the workaround from
https://fschopp.github.io/safari-local-storage-bug/ to the demo site.
Also update the documentation of handlePotentialOauthRedirect().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant