NEW 177478
WKWebView XHR cookies not remembered until app is backgrounded
https://bugs.webkit.org/show_bug.cgi?id=177478
Summary WKWebView XHR cookies not remembered until app is backgrounded
Grant Patterson
Reported 2017-09-25 18:21:13 PDT
This is related to Bug 140191 but while there seems to be basic cookie access now available in WKWebView, it doesn't work on initial app load. Steps to Reproduce: - Create a trivial WKWebView app (mine is a Cordova app using WKWebView) - In javascript, execute an XHR that receives a session cookie - Execute another XHR and notice that the session cookie is not sent - Background, then foreground the app - Now it will work as expected I've worked around this by executing an XHR in native code before attempting further XHRs in javascript, but even then, I must wait ~2s before attempting the XHR in javascript. Otherwise the cookies seem to be forgotten again, indefinitely, until either the app is backgrounded or I wait long enough after the native-code XHR.
Attachments
wkwebview session storage glitch app example (1.61 MB, application/octet-stream)
2019-09-27 10:58 PDT, tleach
no flags
Radar WebKit Bug Importer
Comment 2 2017-09-27 17:40:32 PDT
Geoffrey Garen
Comment 3 2017-12-01 17:31:03 PST
We know that XHR can set a session cookie in Safari. So we need a more complete description or a test application to demonstrate a case where XHR can’t set a session cookie. Can you upload a test app demonstrating this bug?
Ross
Comment 4 2019-06-02 16:17:13 PDT
This is still an issue, is there any update? I see a previous comment was looking for a sample app, is that still desired in order for the webkit team to investigate? It seems like cookies from XHR requests aren't reliably set to the WK cookie store (backgrounding or restarting the app seems to sync them). Good description here: https://stackoverflow.com/a/49534854/2757879 Also some related/relevant discussion for Ionic/Cordova users: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/22 I'd like to know what I can do to help get this one resolved. Thanks!
tleach
Comment 5 2019-09-27 10:58:19 PDT
Created attachment 379741 [details] wkwebview session storage glitch app example Attached is a simple Cordova app that attempts to incorporate the wkwebview engine. We're currently trying to switch from uiwebview to fix issues with iOS video playback, but are having issues with the users not being able to log in on the initial app launch. username: injoytester@gmail.com password: password
Niklas Merz
Comment 6 2019-09-27 16:02:06 PDT
(In reply to tleach from comment #5) > Created attachment 379741 [details] > wkwebview session storage glitch app example > > Attached is a simple Cordova app that attempts to incorporate the wkwebview > engine. We're currently trying to switch from uiwebview to fix issues with > iOS video playback, but are having issues with the users not being able to > log in on the initial app launch. If your login issues are related to cookies please check this issue: https://bugs.webkit.org/show_bug.cgi?id=200857
Geoffrey Garen
Comment 7 2019-10-07 14:34:27 PDT
Sorry, I meant source code that conforms to the original description: Steps to Reproduce: - Create a trivial WKWebView app (mine is a Cordova app using WKWebView) - In javascript, execute an XHR that receives a session cookie - Execute another XHR and notice that the session cookie is not sent - Background, then foreground the app - Now it will work as expected
Note You need to log in before you can comment on or make changes to this bug.