mlemgroup / mlem

Mlem for Lemmy
https://lemmy.ml/c/mlemapp
GNU General Public License v3.0
181 stars 31 forks source link

Using more than one account on ipad removes all accounts #1416

Open nocturne213 opened 4 weeks ago

nocturne213 commented 4 weeks ago

Describe the bug What did you do to trigger the bug? Added a second account on ipad

Expected Behavior What did you expect to happen? I would be able to swap between accounts

Actual Behavior What actually happened? The next time i opened mlem both of my accounts were removed and i had to log in again.

To Reproduce What steps do I need to take to trigger the bug? Log into an account (i was using sipuli.xyz) then add a second account (i used mtgzone.com) then when opening a link from within a post mlem fully closed, when i reopened mlem neither account was available and mlem was showing a guest Lemmy.world account.

Mlem Information: Version + Build number If this started happening recently, write which version introduced the bug I remember this happening when version 2.0 first came out, i almost exclusively use my sopuli account so I never tried again after the first time until tonight. I am using ver 2.0 (114) on ipad pro iOS 18.1.

Additional Context Any other relevant information

nocturne213 commented 3 weeks ago

It appear to not be limited to iPad, but possibly certain instances. I was logged into mtgzone on both my iPhone and iPad and was logged out of all accounts on both devices. I previously had 2 or 3 different accounts logged in on the iPhone. The only difference was adding the mtgzone account.

Sjmarf commented 3 weeks ago

Hmm, that's interesting. I've not seen this issue so it being related to mtg.zone is plausible. Accounts being wiped is a result of a decoding error when opening the app, normally... we should really make Mlem log those errors somewhere permanent to make debugging easier.

When the accounts gets wiped, an "error" popup might be shown - if it happens again and you tap on the "error" popup before it goes away, it'll show the exact error. On the off chance it happens again, having that error information would be useful for us.

nocturne213 commented 3 weeks ago

The operation couldn’t be completed. (Mlem.UserAccount.DecodingError error 1.)

after more testing it happens on iPhone as well as iPad. It happens when I am logged in only on mtgzone.com as well as logged into other instances as well. It was more noticeable on iPad because pretty much every time you minimize Mlem on iPad it crashes. But if you log in on iPhone, then swipe away Mlem and reopen it it gives the above error and logs out all accounts.

Sjmarf commented 3 weeks ago

Thanks, that's narrowed it down a lot.

The issue is caused by Mlem not being able to retrieve the account authorization token from the keychain. I can't reproduce this issue myself, which makes the exact cause tricky to pinpoint and fix. For now, I've submitted a PR that makes Mlem ask for the account password if it can't retrieve the token, rather than wiping the accounts list. I'll keep looking for a proper fix.

nocturne213 commented 3 weeks ago

I do not know if you're change made it into the weekly, but the issue persisted today after updating.

Sjmarf commented 3 weeks ago

That change hasn't merged yet, no. It'll probably be in the next weekly

nocturne213 commented 1 week ago

It looks like this may be resolved with the last update.

After updating, i logged into mtgzone, swiped away mlem, and reopened it. Mtgzone prompted me to refresh my session with my password, could that be what was causing the error? Either way i am still logged in after re-entering my password.

Sjmarf commented 1 week ago

Yep, that's the change I was talking about. Instead of wiping your accounts when the error occurs, Mlem will ask for that account's password. This will happen every time you open the app and log into the account.

It isn't a complete fix for the problem - ideally, Mlem would be able to store your account password and wouldn't need to ask for it every time. I implemented that fix to make the bug more manageable until we get a proper solution.