mozilla-mobile / firefox-ios

Firefox for iOS
Mozilla Public License 2.0
12.14k stars 2.91k forks source link

After update IOS to 16.0 strange cookie behavior. #11994

Open wub1990 opened 1 year ago

wub1990 commented 1 year ago

Does somebody have an idea why this is happening?

Steps to reproduce

Expected behavior

After opening Firefox, I expect to see the google.com homepage with a dark background.

Actual behavior

I get google.com homepage with a white background and a cookie pop-up.

after denying the pop-up and closing the google tab I open a new google homepage tab and still have a white background. After again closing the tab and opening a new google homepage tab I have a dark background.

Device & build information

1. Notes

Attachments:

Test website with cookies: https://f6gvvn.csb.app/

┆Issue is synchronized with this Jira Task

Sebazzz commented 1 year ago

I also ran into this issue with the Dutch website tweakers.net. However, it doesn't seem to happen with every website. Take Hacker News for instance, which is perfectly able to send persistent cookies. It is just that some cookies from some websites are treated as session cookies, which disappear when the Firefox app is closed or thombstoned (or whatever the iOS equivalent of this Windows Phone term is 😉).

crsohara commented 1 year ago

~This was happening to me too, I fixed it by uninstalling and reinstalling the app~ It problem returned again after a few days 😕

GenderCompass commented 1 year ago

I'm facing the exact same issue after updating to ios 16. It used to happen occasionally but since yesterday it's happening most of the time I open the app.

SimonBasca commented 1 year ago

@wub1990 by "dark mode enabled" are you referring to "Night mode" from the hamburger menu or dark theme from Firefox Settings?

SimonBasca commented 1 year ago

Possible duplicate of https://github.com/mozilla-mobile/firefox-ios/issues/12279

Sebazzz commented 1 year ago

@adudenamedruby this is still happening and #12279 did not fix this. IMHO this is actively hurting the ecosystem as many sites are actively resetting missing or invalid cookies and the log out is permanent and not fixed by refreshing the page. It is very easily reproducible by creating a free account on Tweakers.net for instance.

adudenamedruby commented 1 year ago

Heya @Sebazzz. You're correct in that #12279 didn't fix this; that was an investigation into what was happening. We're hoping to get to this soon, but we do have to balance our time for various issues against the other priorities we're given from the org level. I'll ask our PM to re-take another look at these cookie issues and re-evaluate their priorities.

However, if you have an idea for a fix, the team is more than happy to help get that landed.

data-sync-user commented 1 year ago

➤ Nishant Bhasin commented:

Yoana Rios Diaz Do you have any information on this?

data-sync-user commented 1 year ago

➤ Nishant Bhasin commented:

This should be timeboxed to 3

data-sync-user commented 1 year ago

➤ Yoana Rios Diaz commented:

I didn’t investigate this one specifically but it looks consistent with my findings on https://mozilla-hub.atlassian.net/browse/FXIOS-5951 ( https://mozilla-hub.atlassian.net/browse/FXIOS-5951|smart-link ) , from the actual behavior description it looks like only the selected restoring tab is failing to keep the cookies, we hoped the Tab refactoring will fix this issue for good but the Webkit restore process has not started yet so we should take another look with fresh eyes. I talked with Orla Mitchell last week about the ticket above so whoever takes this one can sync with us so we don’t double efforts

lmarceau commented 1 year ago

Related https://github.com/mozilla-mobile/firefox-ios/issues/12279, https://github.com/mozilla-mobile/firefox-ios/issues/12740, https://github.com/mozilla-mobile/firefox-ios/issues/13520, https://github.com/mozilla-mobile/firefox-ios/issues/14030, https://github.com/mozilla-mobile/firefox-ios/issues/15670.

locolau commented 1 year ago

It's not fixed at all. Can anyone look into this again?

lmarceau commented 1 year ago

@locolau this issue wasn't closed and is currently being investigated. Thank you.

glitchedmob commented 1 year ago

Wanted to jump in here with some insights I've found after debugging something related to this in another app I'm working on.

I put together a demo that I think shows that this is a bug in WKWebView itself. glitchedmob/WKWebsiteDataStorePersistanceTest

This demo just puts twoWKWebViews on the screen, one using a nonPersistant WKWebsiteDataStore and the other using a default WKWebsiteDataStore. What I'm seeing is that if the nonPersistent store is in memory, both webviews behave as if they're nonPersistent. If I remove the nonPersistent store all together, I don't see the issue and even more interesting, cookies from previous sessions actually come back.

I was also looking at Brave's implementation (which I believe is a fork of this project) and they don't have this issue where cookies get cleared. What they do is clear all private tabs and remove the nonPersistent store from memory every time a user leaves private mode, which seems to alleviate the issue.

To me this seems that the fix here might actually be to remove the option in settings to "Close Private Tabs" and turn the option on by default, as well as ensure the nonPersistent stores get cleaned up.

adudenamedruby commented 1 year ago

@yoanarios , I know you were working on this and have part (all?) of a solution. Just wanted to make sure you saw @glitchedmob's comment, in case it adds additional context for you. :)

yoanarios commented 1 year ago

Thank you very much @glitchedmob for the comment yes I agree and I arrived at the same conclusions. I open a PR which reduces the occurrence of the bug because we were setting up nonPersistentDataStore on every app start. For the following steps, the team will meet to find a solution.

data-sync-user commented 1 year ago

➤ Alina Moldovan commented:

Validated this issue using FF v116.1 and iPhone 14+ (16.0.3).

Using this version I was not able to reproduce the background issue but the cookie pop-up issue still reproduces intermittently. (please see the video attached)

We had a separate bug logged for the cookie issue but now it is closed as a duplicate of this bug.

Would you like me to reopen this bug or close this one and reopen the old one: [[FXIOS-5951] #13520 ⁃ Cookies not saved after a specific scenario - Jira (atlassian.net)|https://mozilla-hub.atlassian.net/browse/FXIOS-5951]

Yoana Rios Diaz Daniela Arcese

data-sync-user commented 1 year ago

➤ Yoana Rios Diaz commented:

Alina Moldovan do you have private tabs open? Unfortunately, this bug is a WKWebkit issue and is still reproducible if private tabs are open. The improvement done in this PR is related to avoiding initializing the nonPersistentStore if there are no private tabs which reduce the bug occurrence. But if there are private tabs the bug will still be reproducible.

data-sync-user commented 1 year ago

➤ Alina Moldovan commented:

Yoana Rios Diaz I can confirm that I had private tabs opened

Tecnio commented 10 months ago

Issue still persists on iPhone 14 and Firefox 119.1.

eguun commented 9 months ago

I have this issue, reported in https://github.com/mozilla-mobile/firefox-ios/issues/16423 and merged here today.

But I observed this "strange cookie behavior" is not limited to dark mode (as described in first post), or google.com: it happens also in 'light mode' and to all websites using cookies.

Tecnio commented 9 months ago

I think I might have found the culprit, it seems to be caused by the "Close Private Tabs" setting. When disabled and relaunched issue doesn't persist, however when enabled and restarted the issues comes back.

thisiskeithb commented 9 months ago

it seems to be caused by the "Close Private Tabs" setting.

That fix works for me as well. Thank you for finding that! It was getting really old having to reopen sites multiple times before they'd recognize an existing logged in session.

alcortazzo commented 9 months ago

I think I might have found the culprit, it seems to be caused by the "Close Private Tabs" setting. When disabled and relaunched issue doesn't persist, however when enabled and restarted the issues comes back.

I found that the "Close private tabs" option affects this browser issue (#14030). But after a while I noticed that disabling this option does not completely solve the problem. If you wait for a long time and open the browser, it can open again without cookies.

eguun commented 8 months ago

I think I might have found the culprit, it seems to be caused by the "Close Private Tabs" setting. When disabled and relaunched issue doesn't persist, however when enabled and restarted the issues comes back.

I disabled this option 2 weeks ago and have not experienced the bug again. This workaround is working, thank you very much for having found it!

mcfilib commented 8 months ago

I disabled this setting and see the issue less frequently but it still occurs.

ahohns commented 8 months ago

Still happening for me and it's infuriating, it's never a nice surprise when FireFox is backgrounded for a while then closed by the OS, so next time I open FireFox it's opening fresh on the last site I was browsing and this bug happens. I'll try the "Close Private Tabs" fix mentioned above to see if it helps.

bcutter commented 8 months ago

Safari works great, unfortunately. Firefox lacks features, brakes things or even looses my data. Curious to see if this issue (from September 2022... ⚠️) will ever reach a solved state.

pashynskykh commented 6 months ago

I haven't had this problem since I turned off the "Close Private Tabs" option. But it came back last week without me making any changes to the settings. Cookies are no longer saved whether "Close Private Tabs" is on or off for me, which makes FF completely unusable as a main browser. Unfortunately, I will have to switch to another browser until this problem is fixed. I hope this will happen one day...

iamironz commented 1 month ago

After the last update to version 129.0 (44146) from the App Store, the bug started reproducing again because the "Close Private Tabs" option that I turned off manually (and it worked for about the year as the questionable workaround) was suddenly turned on again.

data-sync-user commented 1 month ago

➤ Alina Moldovan commented:

Able to reproduce the cookie banner related issue on v129, v130, and v9000(44253) builds and iPhone 14+ (16.0.3).

Please find the videos below:

LiamDawe commented 3 weeks ago

I think I might have found the culprit, it seems to be caused by the "Close Private Tabs" setting. When disabled and relaunched issue doesn't persist, however when enabled and restarted the issues comes back.

Just commenting to confirm this in fact solved it for my testing on my own website (https://www.gamingonlinux.com/). Users have been reporting, and I can reproduce to 100% that closing Firefox and re-opening and cookies on my site do not load until a refresh. Turning that setting off has completely fixed it.