Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very slow initial loading time for media playback #1444

Open
mattiapv opened this issue Mar 3, 2025 · 8 comments
Open

Very slow initial loading time for media playback #1444

mattiapv opened this issue Mar 3, 2025 · 8 comments
Labels
bug Something isn't working

Comments

@mattiapv
Copy link

mattiapv commented Mar 3, 2025

Describe the bug

The app has become extremely slow during the initial loading of a movie or episode. Once playback starts, seeking (e.g., skipping to the middle of an episode) works instantly. The delay only affects the initial load time, which varies depending on the media, and it takes between 60 to 90 seconds to start.

Currently, the app runs behind an Nginx reverse proxy, configured as per the official documentation: Jellyfin Nginx Guide. However, when bypassing the proxy, media loads significantly faster (around 5 seconds on average).

I’m currently using the beta version, but the issue persists in the stable release as well. When I first started using the app a few months ago, this problem did not exist.

The official macOS client and Infuse for iOS do not experience this issue.

Here’s where the loading process gets stuck:

Image

Application version

1.3

Where did you install the app from?

TestFlight

Device information

iPhone 16 Pro Max

OS version

18.3.1

Jellyfin server version

10.10.6

@mattiapv mattiapv added the bug Something isn't working label Mar 3, 2025
@JPKribs
Copy link
Member

JPKribs commented Mar 4, 2025

Hey, if you go to Settings > Playback Quality, can you confirm if you have the Maximum Bitrate set to Auto? If it is, can you change it to Maximum and try again?

In my experience the slow start is often tied to transcoding. It could be the Auto Bitrate Test is returning slower from behind NGINX, resulting in a transcode. Or, waiting on the bitrate test to resolve. Either way, it's a good place to start for troubleshooting!

@LePips
Copy link
Member

LePips commented Mar 4, 2025

Checking the VLCKit repo we can take a look at passing recommended options in some cases, if it helps with hls streams.

https://code.videolan.org/videolan/VLCKit/-/issues/451

@mattiapv
Copy link
Author

mattiapv commented Mar 4, 2025

Hey, if you go to Settings > Playback Quality, can you confirm if you have the Maximum Bitrate set to Auto? If it is, can you change it to Maximum and try again?

In my experience the slow start is often tied to transcoding. It could be the Auto Bitrate Test is returning slower from behind NGINX, resulting in a transcode. Or, waiting on the bitrate test to resolve. Either way, it's a good place to start for troubleshooting!

Hi, I set it to the Maximum and also tried all the options in Compatibility, but it's still not loading.
Transcoding is disabled on the server side, this is what I mean:

Image

I also enabled transcoding and tried different bitrates, but it didn’t solve the issue.

@mattiapv
Copy link
Author

mattiapv commented Apr 6, 2025

Hi, it looks like the issue has been resolved in the latest beta.

I haven't changed any configuration, except for upgrading Jellyfin. A few days ago, I pulled a new image and updated the server, but since the version was still 10.10.6, I'm not sure if anything actually changed. I'm using the Docker image from LinuxServer.io.

Yesterday, I updated to version 10.10.7 and everything is still working fine.

However, when not using the beta version, the issue is still present for some movies. For example, this video only plays correctly in the beta version:

Image

Previously, nothing would load regardless of whether I was using the beta or not. Now, some videos work even without the beta.

This is my Nginx configuration for Jellyfin, in case it's useful to anyone.
It's based on the official example from the Jellyfin documentation.
I'm also using a Base URL, as explained here.
There used to be a dedicated guide for using Base URL with Nginx, but it was removed.
I've also added Known Proxies configuration since is required from 10.10.7.

server {
    listen 443 ssl;
    http2 on;
    server_name 7s435a14gd2841fe49b5a3okfdf.example.com;
                
    ssl_certificate ssl/acme.sh/example.com_ecc/fullchain.pem;
    ssl_certificate_key ssl/acme.sh/example.com_ecc/key.pem;
    
    # modern configuration
    ssl_protocols TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384;
    ssl_ecdh_curve X25519:prime256v1:secp384r1;
    ssl_conf_command Ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256;
    ssl_prefer_server_ciphers off;

    # intermediate configuration
    #ssl_protocols TLSv1.2 TLSv1.3;
    #ssl_ecdh_curve X25519:prime256v1:secp384r1;
    #ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
    #ssl_prefer_server_ciphers off;
    
    #ssl_dhparam dhparam.pem;

    # uncomment to enable if ssl_protocols includes TLSv1.2 or earlier;
    #ssl_session_timeout 1h;
    #ssl_session_cache shared:SSL:10m;
    #ssl_session_tickets off;
    
    # 1 year HSTS
    add_header Strict-Transport-Security "max-age=31536000" always;
    
    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;

    ssl_trusted_certificate ssl/acme.sh/example.com__ecc/chain.pem;

    resolver 1.1.1.1 8.8.8.8 valid=30s;
    resolver_timeout 30s;
    
    #geoip block
    if ($allowed_country = no) {
           return 444;
    }
    
    client_max_body_size 20M;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header Content-Security-Policy "default-src https: data: blob: ; img-src 'self' https://* ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://www.gstatic.com https://www.youtube.com blob:; worker-src 'self' blob:; connect-src 'self'; object-src 'none'; frame-ancestors 'self'";
    
    location / {
       return 444;
    }
    
    location /asecretjellyfinlocation {
        return 302 $scheme://$host/asecretjellyfinlocation/;
    }
    
    location /asecretjellyfinlocation/ {
        access_log off;
        # Proxy main Jellyfin traffic
        proxy_pass http://ip:8096;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Host $http_host;

        # Disable buffering when the nginx proxy gets very resource heavy upon streaming
        proxy_buffering off;
    }

    location /asecretjellyfinlocation/socket {
        access_log off;
        # Proxy Jellyfin Websockets traffic
        proxy_pass http://ip:8096;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Host $http_host;
    }
}

@JPKribs
Copy link
Member

JPKribs commented Apr 6, 2025

VLCKit (Swiftfin Player) does not support TLS 1.3. Please see our player documentation here:

https://github.com/jellyfin/Swiftfin/blob/main/Documentation/players.md#feature-support

Please enable fallback to 1.2 (commented out in the intermediate settings) and let us know if the issue persists.

https://code.videolan.org/videolan/VLCKit/-/issues/595

@mattiapv
Copy link
Author

mattiapv commented Apr 6, 2025

And why is it working for me using TLS 1.3 only?

I added 1.2

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve X25519:prime256v1:secp384r1;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;

Also tried like this

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;

That video still loads only in beta version of Swiftfin

@JPKribs
Copy link
Member

JPKribs commented Apr 6, 2025

Thank you for testing that. Honestly, I'm not sure. VLCKit isn't supposed to support TLS 1.3. If it works, it works, but it's documented in a way where it allegedly shouldn't.

In my own testing, 1.3 is not currently working but 1.2 is. Please note, that only applies to the Swiftfin player. Native should work correctly with 1.3. Depending on your configuration, 1.2 fallback could be in a parent or child conf file for NGINX as well.

As for the Beta working, I can't tell you what would have changed for player code between 1.2 and 1.3(8) but I'm always willing to take a win if it works for you!

@mattiapv
Copy link
Author

mattiapv commented Apr 6, 2025

Yes I'm using the Swiftfin player not the native one.
I also tried to comment the ciphers like this:

ssl_protocols TLSv1.3;
#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384;
#ssl_ecdh_curve X25519:prime256v1:secp384r1;
# ssl_conf_command Ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256;

And still works so I guess something is changed in the beta version or VLCKit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants