jellyfin / Swiftfin

Native Jellyfin Client for iOS and tvOS
Mozilla Public License 2.0
2.22k stars 241 forks source link

Logged Out Between Sessions [TVOS] #776

Open JPKribs opened 1 year ago

JPKribs commented 1 year ago

I can't get this trigger 100% of the time but I think I narrowed it down to having multiple users on the AppleTV. Since adding another user profile on the AppleTV, all saved Jellyfin users will get wiped after the TV goes to sleep or reboots.

I believe this is related to how session data is stored since this only started once I added other users. On another AppleTV, I have a single user and I have not experienced this issue (yet). I could be totally off base but if my guess is right I think this could be resolved by:

https://github.com/jellyfin/Swiftfin/pull/661

https://github.com/jellyfin/Swiftfin/issues/258

extraslute commented 1 year ago

I have experienced being logged out on a daily basis on my Apple TV 4K regardless of if there are multiple users or not. This doesn’t happen on my android tv nor any Rokus.

JPKribs commented 1 year ago

I haven't experienced this with multiple tvOS users. However, I haven't added more than one Jellyfin user.

The multiple TVOS users could be a red herring. That's just when I started seeing it. I know other people who get this regardless of TVOS users.

Is there a way to collect TVOS logs that I could help look at/provide to better understand this?

LePips commented 1 year ago

Sadly no logs would help, but I can investigate.

JPKribs commented 1 year ago

Sadly no logs would help, but I can investigate.

Thank you! I don't know if it changes anything but it's a 2nd Gen 4K

Since there is one that was impacted and one that is not, I've been racking my brain thinking what the difference between them could be. The only other thing I could think of is that the one that gets logged out also has Infuse logged into the same server. I'm not sure how that would make a difference. Just hoping maybe something there might help!

IceHawk66 commented 11 months ago

I have experienced being logged out on a daily basis on my Apple TV 4K regardless of if there are multiple users or not. This doesn’t happen on my android tv nor any Rokus.

I'm facing the same error on my apple tv 4k. Logged in yesterday (again) and I have no server today. Have to enter server + credentials again.

marvagabi commented 11 months ago

I have the same issue as well, have Swiftfin installed on 3 apple tv's with accounts for myself my wife and my kids and it seems almost daily the accounts get wiped and I have to reconnect to the server and login again.

Great-beaver commented 11 months ago

The same issue. Can we help to investigate it somehow?

bombyy commented 11 months ago

Same issue for me. My partner has an AppleTV 4K (1st Gen) and we basically get logged out every day.

Raphty commented 11 months ago

Thanks for this great tvOS app, but yes I have the same issue as the other on my 1st gen 4k

LePips commented 11 months ago

Apologies that I haven't been able to investigate, I see that this is a pressing issue. I'll take a look at this soon.

dannycab commented 11 months ago

This occurs on each Apple TV that I have of various models. It's too bad because Swiftfin is miles faster to load and navigate compared to Infuse. Just a better app IMO.

adavidzh commented 10 months ago

I’m observing the same thing. Is there information needed to help debug this?

amochkin commented 10 months ago

Same thing. Server shows multiple logged in sessions from that box. Apple TV 4K.

pumax15 commented 10 months ago

I’m still having this same issue as well. App is great, but frustrating constantly having to input credentials over and over.

jshwrner commented 10 months ago

Same problem, I have to sign in each time I open the app. I'm using the following:

AppleTV Model: A1625 tvOS: 16.5

Jellyfin Version: 10.8.3 Operating System: Linux Architecture: X64

IzaacJ commented 9 months ago

Same issue here on our 4K 1st Gen On 16.5. We have multiple AppleIDs on it, but mainly using my AppleID, and we also have 6 users configured in Jellyfin. Server info: Version: 10.8.10 Operating System: Linux Architecture: x64

douglasparker commented 9 months ago

Family members are also experiencing this bug! Looking forward to a resolution!

Esthreel commented 9 months ago

I have the same issue. My login / server info is not being saved on tvOS. Any suggestions?

extraslute commented 9 months ago

I'd like to comment on here that I've continued to experience this for several months. Jellyfin kicks off any users signed into an Apple TV after 1 day and sometimes even after a few hours. It's hot and miss. Doesn't sign out any Rokus, Android TVs, or iOS devices though.

KurzweilTV commented 9 months ago

Just adding a +1 here. I don't know of any specific trigger, but I know I won't stay logged in for more than a day or so at most.

jet082 commented 9 months ago

Adding my voice in too! Relatives can't use the service at all because of the daily login requirement.

ScoobyDoo27 commented 9 months ago

I am having the same issue as well. I am using a 1st and 2nd gen Apple TV 4K and my server is installed via docker on a NAS.

iinkfish commented 8 months ago

Happens with me too. It's just with one account though, after a certain period of time, usually a day, get logged out and I have to enter everything again including the ip address/domain

Nicxe commented 8 months ago

Same here, I need to add a server and log in every time.

BDub38 commented 8 months ago

Glad to find this issue....this has been driving me crazy and I couldn't figure out what the issue was. Hoping to see a fix soon!!

totally-a-human commented 8 months ago

For anyone experiencing issues how have you logged in? I used to have this issue when logging in with a password but after I logged in with quick connect a few days ago it's been working fine (so far...).

Raphty commented 8 months ago

I always use the password option.... but i will try the qc... It is just a bigger hassle then username and pw when you use a PWmanager, which is wehre I get the ip from as well 🤣

extraslute commented 8 months ago

I always use password also. I haven't changed how I've been logging in as a 4 year user. It does not sign out on Jellyfin for iOS nor Jellyfin for Android TV, nor on Roku -- only Apple TV. It happens everyday. Still happens everyday. At this point we're just used to it but wish

Nicxe commented 8 months ago

My wife asked me to switch to Plex instead, she was tired to log in everyday

Raphty commented 8 months ago

🤣 my said something similar yesterday as well (emby in our case)

Nicxe commented 8 months ago

I don´t even have the option to connect quick, the app does not find any server so need to enter that manually every time

ScoobyDoo27 commented 8 months ago

I can’t do quick connect either. I run my server through docker and I believe that is the reason it doesn’t show up in the list of servers.

adavidzh commented 8 months ago

I can’t do quick connect either. I run my server through docker and I believe that is the reason it doesn’t show up in the list of servers.

FWIW, my Jellyfin runs inside docker, shows up in the list of servers, and Quick Connect works. It's just not all that quick. (A QR code would be quicker.)

Still, the best would be for the credentials from logging in would be kept.

Raphty commented 8 months ago

I did try the "quick" login... it did not help. Next day I was logged out again. also I have to say that there is nothing quick about this... If you use a pw manager and your iphone to automatically put in the details that is 100times faster

still I have to say, I love the app!!! and I am super thankful ❤️

JamesDearlove commented 8 months ago

This issue finally got to me and I had some free time, so I went hunting to see if I could track down what is causing this and I might have found the problem.

CoreStore stores its SQLite db in the caches directory on tvOS by default (CoreStore doc link) and I think this gets swept up when tvOS does a cleanup when running low on space. There's no nice way to trigger this cleanup in the Simulator from what I understand, so I've deployed a fix onto my Apple TV and will see if this does actually fix it.

I've committed a patch to my fork. If this fixes it, I'll open a PR.

Edit: This is an entire thing with data and caching in tvOS, I don't understand this well enough to fix it but Apple details bits of it in App Programming Guide for tvOS

LePips commented 8 months ago

Hey all, I've started debugging this and currently trying to replicate. If it is truly something that happens over a period of 24 hours, this might be tough.

extraslute commented 8 months ago

It is definitely something that happens over a 24 hour period. Probably the absolute most annoying thing I’ve ever experienced. And since my Jellyfin server is also part of my home assistant, every single time I have to login it creates a new “device” in home assistant so I have probably 60 Apple TVs showing but 59 of them inactive. I quit deleting them because it just continues to happen.

On my bedroom Sony Bravia for the AndroidTV app I haven’t ever been signed out.

If there's anything I can do to help you out let me know.

Raphty commented 8 months ago

I am not familiar with iOS/tvOS development, but I can help as well.

and interesting thing I had the last couple of days: when I have a video open when I leave the app, it keeps that video open over night, and I don't have to log in again (most days) but when I go back to the swiftfin overview, i think I am always logged out next evening (22h later most days 😃 )

amochkin commented 8 months ago

Apparently the issue can be fixed by using UserDefaults for storing API key.

totally-a-human commented 8 months ago

Using quick connect does not solve the problem.

As @JamesDearlove and @amochkin pointed out it seems like tvOS is very aggressive with purging data.

Moreover, your app can only access 500 KB of persistent storage that is local to the device (using the NSUserDefaults class). Outside of this limited local storage, all other data must be purgeable by the operating system when space is low.

That appears to be explaining why I'm not logged out of my Apple TV (as I don't use it too much) while someone I know is logged out much more often (and they use it a lot more). As far as I can see in the code the API key and the server details are not stored in UserDefaults so they are eligible for cleanup.

LePips commented 8 months ago

API keys are not stored in UserDefaults and never should be. I'm not too concerned with the cleanup being a problem as that is something that should have been an issue a long time ago, but it isn't out of the picture.

amochkin commented 8 months ago

API keys are not stored in UserDefaults and never should be. I'm not too concerned with the cleanup being a problem as that is something that should have been an issue a long time ago, but it isn't out of the picture.

I disagree, using UserDefaults completely solves the problem. Can you please elaborate on why the app should never store API keys in UserDefaults?

Raphty commented 8 months ago

2 days in a row I was not logged out while I keep the next video on pause and not Return to the main screen - but last night I did go back so I can report tomorrow if I got logged out again 😅

Raphty commented 7 months ago

Have not been logged out since the new tv os update. Maybe that fixed it?

JPKribs commented 7 months ago

Using quick connect does not solve the problem.

As @JamesDearlove and @amochkin pointed out it seems like tvOS is very aggressive with purging data.

Moreover, your app can only access 500 KB of persistent storage that is local to the device (using the NSUserDefaults class). Outside of this limited local storage, all other data must be purgeable by the operating system when space is low.

That appears to be explaining why I'm not logged out of my Apple TV (as I don't use it too much) while someone I know is logged out much more often (and they use it a lot more). As far as I can see in the code the API key and the server details are not stored in UserDefaults so they are eligible for cleanup.

Following up on this being a purging data on low storage, I was able to successfully recreate this issue.

I have a few thousand photos in iCloud. When I remove iCloud Photos from syncing to the Apple TV, I have a lot of free space and I rarely have Swiftfin logouts. When I re-enable iCloud Photos to sync, the Apple TV downloads images to get me to ~1gb free. The next time I open Swiftfin it requires me to log back in.

I assume this would work with anything that takes up a lot of storage on the AppleTV. I've found Infuse likes to chew up storage room too and I experience the same issue when Infuse takes up >5gb of library images. In testing, it looks like when Swiftfin is not in the foreground and storage is low, credentials are lost.

I hope this helps in testing/troubleshooting! Hopefully others are able to recreate this as well.

Edit for context:

To identify the amount of storage used, I used this app: https://apps.apple.com/us/app/tv-info/id1443395433. So, a lot of this is riding off of the assumption that this app is accurate. I have a 32gb model and without Infuse/Photos I sit around 20gb in use. This number seems to fluctuate ~10gb without installing anything. I have found that it can even get to ~1gb left without adding anything new. I'm not an expert, but I would guess that Apple is pretty aggressive about caching? That being said, >1gb remaining, seems to be the sweet spot when it clears my login. When I get logged out, I found that Infuse also gives me that warning that it had to clear cached information. I hope this helps! Additionally, it would be great to confirm someone else was able to replicate this as well!

jesuslopezreynosa commented 7 months ago

I can replicate that the issue on tvOS 17 persists, and there is a new behaviour where it no longer accepts my credentials to log back into my media server.

Nicxe commented 7 months ago

I can replicate that the issue on tvOS 17 persists,

Same here, is seams to work for me know on TvOs17. Haven't ben logoed ut for a couple of days now

extraslute commented 7 months ago

This issue has seemingly disappeared on both of my Apple TVs. Gen 2 and 4 after the last time I did an update (Ubuntu). Both are also on TVOS 17. Used to kick me out every day -- does not do this anymore.

pumax15 commented 7 months ago

I updated to the latest TV Os 17 and I still have the same problem. It keeps me logged in a little longer, but I still have to keep re-entering credentials.

ioslife commented 7 months ago

This problem made me switch to Infuse. I'd love to go back to Swiftfin, but this makes it unusable