jellyfin / jellyfin-web

Web Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.38k stars 1.27k forks source link

TV series become unwatchable when they have too many episodes #5779

Open maybeanerd opened 4 months ago

maybeanerd commented 4 months ago

Describe The Bug When starting an episode in a series with many episodes (e.g. one piece, 1110 episodes) the playback is stuck in the loading (before opening player) state forever. This behavior does not occur when I remove 800 of the 1110 episodes and try to play the exact same episode, so it seemed to be related to the amount of total episodes. This also happens on all episodes I tried, not only specific ones.

When digging deeper, I found that on server side, no errors are being thrown, but on client side, there is a request to get all episodes (https://jellyfin.cluster.diluz.io/Shows/cfe.../Episodes?IsVirtualUnaired=false&IsMissing=false&UserId=93d..&Fields=Chapters,Trickplay) which is huge. For one piece, it ends up being 2.4MB and takes quite some time to finish.

The client seems to be unhappy about the duration of the request, as it logs Request timed out image

although in the network tab, the request finishes with 200 (but maybe is stopped early by the client? the response is truncated) image

Steps To Reproduce

  1. Add a series with approx. 1000 episodes
  2. Let library scan finish (important! it doesn't happen if the library scan hasn't added all of the episodes yet)
  3. Try to play one of the episodes
  4. It will load forever

Expected Behavior The episode should start playing (even if it takes long, which I would not expect, but tolerate)

Logs jellyfin.log

Screenshots This is what it will look like forever image

System (please complete the following information):

Additional Context none

maybeanerd commented 4 months ago

I'm going to try to adjust some things in the client experimentally to see if that would actually fix the entire issue - will need to first figure out where even to look If in the meantime a maintainer sees this, feel free to drop some extra info and context on this behavior please

maybeanerd commented 4 months ago

first attempts seem to not break any existing behavior, but stop the problematic call from fetching all episodes: https://github.com/jellyfin/jellyfin-web/compare/master...maybeanerd:jellyfin-web:fix/playback-of-series-with-large-set-of-episodes

I have yet to test this with the 1000+ episode setup, though. Will do so soon™️ to ensure that this actually fixes the cause of the loading issue

maybeanerd commented 4 months ago

Tested the solution, works! It fixes the issue for 1110 episodes. I'll open it as a PR, where I would hope someone who knows more about the system itself can check if this would break other existing behavior. I did try around everything I could think of and nothing seemed broken

jellyfin-bot commented 2 days ago

This issue has gone 120 days without comment. To avoid abandoned issues, it will be closed in 21 days if there are no new comments.

If you're the original submitter of this issue, please comment confirming if this issue still affects you in the latest release or master branch, or close the issue if it has been fixed. If you're another user also affected by this bug, please comment confirming so. Either action will remove the stale label.

This bot exists to prevent issues from becoming stale and forgotten. Jellyfin is always moving forward, and bugs are often fixed as side effects of other changes. We therefore ask that bug report authors remain vigilant about their issues to ensure they are closed if fixed, or re-confirmed - perhaps with fresh logs or reproduction examples - regularly. If you have any questions you can reach us on Matrix or Social Media.

maybeanerd commented 1 day ago

Still open. There were valid concerns with the PR I prepared but I haven't gotten to addressing them, since doing so needs a deeper dive into the APIs and application state. If anybody else wants to, feel free to take over. Otherwise I'll probably get to it at some point

maybeanerd commented 1 day ago

Could actually be that https://github.com/Namo2/InPlayerEpisodePreview/pull/33 solved this issue? Could be a source of inspiration

alimbada commented 1 day ago

How are your episodes structured? Are they all in one folder on the server or split by season?

maybeanerd commented 1 day ago

It's ~1100 episodes split into 22 folders/seasons Most have < 100 episodes, some have more

alimbada commented 1 day ago

Interesting. I have the same setup but don't experience this issue. I wonder if it's due to how your library is set up?

This is how mine's set up:

Image

Image

Image

maybeanerd commented 1 day ago

Can you trace the the request your client does when loading an episode? As mentioned in the original issue text, the request seems to not fail, instead it is a 200 that is probably cancelled due to a client side timeout.

Could be that your hardware is so much faster than mine that the timout doesn't hit?

In any case, I'll add back the content (removed tons of intermittent seasons for it to work) and see if I have the same issue with version 10.10.1 as well

maybeanerd commented 1 day ago

I was still able to reproduce the issue, but in the PR that is linked to this issue, I think I now finally have provided a usable solution.

alimbada commented 6 hours ago

Can you trace the the request your client does when loading an episode? As mentioned in the original issue text, the request seems to not fail, instead it is a 200 that is probably cancelled due to a client side timeout.

Yep, I get a 1.83MB response which is truncated (I have ~100 fewer episodes than you do). It took 1.27s to fetch it.

Could be that your hardware is so much faster than mine that the timout doesn't hit?

Client I used for checking the above is Firefox + Windows 10 on a Ryzen 7 3700X machine with 16GB RAM but I also use the Android TV app on Chromecast with Google TV, the LG webOS app on an LG C2 TV and the iOS app on an iPhone 11.

Server is the official Docker image running on a NanoPi R6C running Armbian.

I just had a look at your PR and it seems there are some limitations with your new implementation though I'm not too familiar with the Jellyfin API or frontend but if there's any issues raised by the maintainers I can look into making the necessary API changes to expedite a better solution if needed.