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

Syncplay sessions close after playing video for 30 seconds #5485

Closed
1 task done
soultaco83 opened this issue May 9, 2024 · 32 comments
Closed
1 task done

Syncplay sessions close after playing video for 30 seconds #5485

soultaco83 opened this issue May 9, 2024 · 32 comments
Labels
bug Something isn't working confirmed The issue has been verified regression We broke something
Milestone

Comments

@soultaco83
Copy link

soultaco83 commented May 9, 2024

Please describe your bug

Moving from #5446
When playing video from a syncplay session. The Sessions will close and stop playing

Reproduction Steps

1: Start a syncplay session
2: Play any video file
3: Wait 30 seconds
4: Stream crashes and backs to previous page

Jellyfin Version

Unstable (master branch)

if other:

No response

Environment

- OS: Unraid
- Linux Kernel: Linux 6.7.12-Unraid x86_64
- Virtualization: Docker
- Clients: Browser
- Browser: Chrome, Firefox, Edge
- FFmpeg Version: 6.0.1-6
- Playback Method: Doesn't seem to be related
- Hardware Acceleration: QSV
- GPU Model: Arc A770
- Reverse Proxy: n/a
- Base URL: n/a

Jellyfin logs

Attached below are server logs and snippet of console
Debug enabled



-05-09 03:18:31.074 -04:00] [DBG] [21] Jellyfin.Api.Auth.CustomAuthenticationHandler: AuthenticationScheme: "CustomAuthentication" was successfully authenticated.
[2024-05-09 03:18:31.083 -04:00] [INF] [21] Emby.Server.Implementations.SyncPlay.Group: Session "167f9f73419f326929282b1271a2ff32" requested Play in group "0210dd87-f79b-4b5a-9f5e-697e852764cc" that is Idle.
[2024-05-09 03:18:31.083 -04:00] [INF] [21] Emby.Server.Implementations.SyncPlay.Group: Group "0210dd87-f79b-4b5a-9f5e-697e852764cc" switching from Idle to Waiting.
[2024-05-09 03:18:31.085 -04:00] [DBG] [21] MediaBrowser.Controller.Entities.BaseItem: "test" has no parental rating set.

...

[2024-05-09 03:18:31.102 -04:00] [DBG] [21] MediaBrowser.Controller.SyncPlay.GroupStates.WaitingGroupState: Session "167f9f73419f326929282b1271a2ff32" set a new play queue in group "0210dd87-f79b-4b5a-9f5e-697e852764cc".

...


[2024-05-09 03:19:04.272 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: PingTranscodingJob PlaySessionId="f65f00d9b9204b0a956bf4d62f84394b" isUsedPaused: False
[2024-05-09 03:19:05.272 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: PingTranscodingJob PlaySessionId="f65f00d9b9204b0a956bf4d62f84394b" isUsedPaused: False
[2024-05-09 03:19:05.574 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef12-1.mp4"
[2024-05-09 03:19:05.574 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef120.mp4"
[2024-05-09 03:19:05.574 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef121.mp4"
[2024-05-09 03:19:05.575 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef122.mp4"
[2024-05-09 03:19:05.575 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef123.mp4"
[2024-05-09 03:19:05.576 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef124.mp4"
[2024-05-09 03:19:05.576 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef125.mp4"
[2024-05-09 03:19:05.577 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef126.mp4"
[2024-05-09 03:19:05.577 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef127.mp4"
[2024-05-09 03:19:05.577 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef128.mp4"
[2024-05-09 03:19:05.577 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef129.mp4"
[2024-05-09 03:19:05.578 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1210.mp4"
[2024-05-09 03:19:05.578 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1211.mp4"
[2024-05-09 03:19:05.579 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1212.mp4"
[2024-05-09 03:19:05.579 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1213.mp4"
[2024-05-09 03:19:05.580 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1214.mp4"
[2024-05-09 03:19:05.580 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1215.mp4"
[2024-05-09 03:19:05.580 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1216.mp4"
[2024-05-09 03:19:05.581 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1217.mp4"
[2024-05-09 03:19:05.581 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1218.mp4"
[2024-05-09 03:19:05.581 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1219.mp4"
[2024-05-09 03:19:05.582 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1220.mp4"
[2024-05-09 03:19:05.582 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1221.mp4"
[2024-05-09 03:19:05.582 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1222.mp4"
[2024-05-09 03:19:05.583 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1223.mp4"
[2024-05-09 03:19:05.584 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1224.mp4"
[2024-05-09 03:19:05.584 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1225.mp4"
[2024-05-09 03:19:05.584 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1226.mp4"
[2024-05-09 03:19:05.584 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1227.mp4"
[2024-05-09 03:19:05.585 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1228.mp4"
[2024-05-09 03:19:05.585 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1229.mp4"
[2024-05-09 03:19:05.585 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1230.mp4"
[2024-05-09 03:19:05.585 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef1231.mp4"
[2024-05-09 03:19:05.585 -04:00] [DBG] [10] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting HLS file "/transcodes/bd091fbc4f17ec8aca4768956042ef12.m3u8"
[2024-05-09 03:19:05.589 -04:00] [INF] [10] Emby.Server.Implementations.Session.SessionManager: Playback stopped reported by app "Jellyfin Web" "10.9.0" playing "Undertaker". Stopped at "29724" ms
[2024-05-09 03:19:05.599 -04:00] [DBG] [10] Jellyfin.Api.Middleware.ResponseTimeMiddleware: Slow HTTP Response from "http://10.10.10.23:8096/Sessions/Playing/Stopped" to "192.168.108.170" in 0:00:01.5857745 with Status Code 204
[2024-05-09 03:19:07.113 -04:00] [DBG] [14] Emby.Server.Implementations.Session.SessionWebSocketListener: Watching 1 WebSockets.


### FFmpeg logs

```shell
Not a hardware transcode issue

Please attach any browser or client logs here

log_20240509.log

FFmpeg.Remux-2024-05-09_03-29-11_394aef7aa8fdf3830840f9d598a199d3_11a3f9c7.log
FFmpeg.Remux-2024-05-09_03-29-52_394aef7aa8fdf3830840f9d598a199d3_612a87ea.log

Please attach any screenshots here

image

Code of Conduct

  • I agree to follow this project's Code of Conduct
@soultaco83 soultaco83 added the bug Something isn't working label May 9, 2024
@jellyfin-bot

This comment was marked as outdated.

@TIITANIC1912
Copy link

Hello.

Same thing here with Jellyfin Server 10.9.0.0 in Debian 12, in a VM with the latest package from the jellyfin repo 10.9.0+deb12. it works a bit better before the update.

@poulpor
Copy link

poulpor commented May 12, 2024

Same here too with Jellyfin Server 10.9.0 latest stable, on a Synology (DSM 7.2.1-69057 Update 4), didn't have this strange behavior with 10.8.13. Tried with and without hardware transcoding, same result, syncplay closes after 30 secondes on both computers and return to previous page.

@TimGels
Copy link
Member

TimGels commented May 12, 2024

I am able to reproduce this behavior on current master (latest commit 25c23af8659700909995ca9c91c5dafccc6d348b) and latest web master (latest commit b40cbb2).

afbeelding

@TimGels TimGels added the confirmed The issue has been verified label May 12, 2024
@thornbill
Copy link
Member

The error message in web is that the api request reporting the playback start times out and I don't see anything in the provided server logs indicating why... server logs of the failed request would likely give some details as to cause of the issue.

@TimGels
Copy link
Member

TimGels commented May 12, 2024

I am not seeing anything weird with a quick glance on the terminal output of visual studio of the server when this problem occurs.

[18:03:44] [INF] [39] Emby.Server.Implementations.SyncPlay.Group: Session 2ab1b5d58aa78b0eff5aaf44cfb9179f requested IgnoreWait in group 1a871bf4-f845-4e16-a316-92000eef541e that is Waiting.
[18:03:44] [INF] [23] MediaBrowser.Controller.MediaEncoding.TranscodingJob: Stopping ffmpeg process with q command for C:\Users\Tim\AppData\Local\jellyfin\cache\transcodes\cc3c2e1bf77f00eeb3d2f487fa629cb8.m3u8
[18:03:44] [INF] [39] MediaBrowser.Controller.MediaEncoding.TranscodingJob: Stopping ffmpeg process with q command for C:\Users\Tim\AppData\Local\jellyfin\cache\transcodes\ad5c48a15455f427854b21d31c9c7513.m3u8
[18:03:44] [INF] [40] Emby.Server.Implementations.SyncPlay.Group: Session a0338c7db866e181c8763d7f052d56d1 requested IgnoreWait in group 1a871bf4-f845-4e16-a316-92000eef541e that is Waiting.
[18:03:44] [INF] [40] Emby.Server.Implementations.SyncPlay.Group: Group 1a871bf4-f845-4e16-a316-92000eef541e switching from Waiting to Playing.
[18:03:44] [INF] [23] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: FFmpeg exited with code 0
[18:03:44] [INF] [23] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting partial stream file(s) C:\Users\Tim\AppData\Local\jellyfin\cache\transcodes\cc3c2e1bf77f00eeb3d2f487fa629cb8.m3u8
[18:03:44] [INF] [39] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: FFmpeg exited with code 0
[18:03:44] [INF] [39] MediaBrowser.MediaEncoding.Transcoding.TranscodeManager: Deleting partial stream file(s) C:\Users\Tim\AppData\Local\jellyfin\cache\transcodes\ad5c48a15455f427854b21d31c9c7513.m3u8
[18:03:45] [INF] [22] Emby.Server.Implementations.Session.SessionManager: Playback stopped reported by app Jellyfin Web 10.10.0 playing The Red-Nosed Reindeer. Stopped at 29694 ms
[18:03:46] [INF] [39] Emby.Server.Implementations.Session.SessionManager: Playback stopped reported by app Jellyfin Web 10.10.0 playing The Red-Nosed Reindeer. Stopped at 29689 ms

Will continue looking into it what might be going wrong.

@thornbill
Copy link
Member

Any failed requests in the browser's network tab?

@TimGels
Copy link
Member

TimGels commented May 12, 2024

Any failed requests in the browser's network tab?

None failed in the browser network log:
afbeelding

@TimGels
Copy link
Member

TimGels commented May 12, 2024

I am still unsure what endpoint it calls where it times out on. Does it even call one?

@thornbill
Copy link
Member

Oh good call... I thought this was related to a progress reporting request, but it could just be events within web. 🤔

@TimGels
Copy link
Member

TimGels commented May 12, 2024

It looks like it times out on line 170 (QueueCore.js). It times out on the default configured 30s WaitForEventDefaultTimeout timeout located in Helper.js
afbeelding

@PeachesMLG
Copy link

PeachesMLG commented May 12, 2024

I think this is just a race condition, from what I can tell the playbackstart event is being called here, however from spamming a bunch of logs everywhere, it looks like it gets called before we run the code to wait for the event

@PeachesMLG
Copy link

https://github.com/jellyfin/jellyfin-web/blob/master/src/plugins/syncPlay/core/QueueCore.js#L237

So moving this.scheduleReadyRequestOnPlaybackStart above playerWrapper.localPlay does fix this issue, but I dont really know the code well enough to know if there are any side effects to this or not. But its definatly just a case of the event being called before we start listening to it

@TimGels
Copy link
Member

TimGels commented May 12, 2024

Amazing find. Perhaps someone from web knows if that is a good way to fix it.

@thornbill thornbill transferred this issue from jellyfin/jellyfin May 12, 2024
@thornbill
Copy link
Member

Nice find... this seems like one of those things that should have never worked. Clearly you should register the event listener before starting playback. 🤔🤷‍♂️

@PeachesMLG
Copy link

Looks like this commit broke it: 1b2c99a

@PeachesMLG
Copy link

So Ive been looking at this for a while, and I have no idea why that commit broke anything, from what I can see it should be executing the exact same code, but for some reason it changes the timing order of things.

But Ive decided its just magic, so ive raised a pr to revert the refactor, if anyone wants to investigate into why the refactor broke stuff feel free to close my pr and open your own

@soultaco83
Copy link
Author

soultaco83 commented May 14, 2024

@PeachesMLG I cloned the jellyfin-web repo and built the web interface with your changes to the playbackmanager.js file. Restarted the server after install.
I am still failing at the 30 second mark.
10.10.10.20-1715654232556.log
playbackmanager.txt
changed to txt for upload

@PeachesMLG
Copy link

Oh, weird. so I ran it locally again, and it worked fine, so I did a few more tests and again everything was working fine. However on the 5th attempt it broke.

At a guess we are running two async tasks in parralel when they need to be waiting on one another... (which is probabbly why my fix "worked" since it changed the timings a few fractions of a milliseconds?)

Let me investigate this further...

@TimGels
Copy link
Member

TimGels commented May 14, 2024

Maybe it is a good idea to mention something in the pull request on why it's closed. Can even be just a link to your comment.

@PeachesMLG
Copy link

So from what I can see by spamming a bunch of logs everywhere, the promise somehow gets released here:

https://github.com/jellyfin/jellyfin-web/blob/master/src/components/playback/playbackmanager.js#L478

So the scheduleReadyRequestOnPlaybackStart method gets released and runs before it should (Which in this case is good because it should be called before the event anyways)

I think my original suggestion of moving the scheduleReadyRequestOnPlaybackStart above the playerWrapper.localPlay is the best option here, the only issue is that two playbackstart events are triggered, so im not sure if thats going to cause any issues (potentially we want to wait for the second one?)

Javascript isnt really my forte and I dont know this codebase that well, so ill leave this for somone smarter to do, but id be interested in seeing what the fix ends up being

@dmitrylyzo
Copy link
Contributor

The "magic" is that my PR has bound apiClient.getEndpointInfo and playAfterBitrateDetect promises to play call. This way the playback start becomes "sync", allowing to wait for success or error. A side effect is that the scheduleReadyRequestOnPlaybackStart call now waits for the play (localPlay) promise to be resolved , which is too late.

I think my original suggestion of moving the scheduleReadyRequestOnPlaybackStart above the playerWrapper.localPlay is the best option here

This is actually the correct way to handle events. As Bill said, subscribe before performing an action that might trigger an event. The only question is how to stop waiting for playbackstart in case of an error?

the only issue is that two playbackstart events are triggered

From the same object?
playbackstart is triggered from 3 different objects:

  • Playback manager
  • Player
  • SyncPlay player

@PeachesMLG
Copy link

No idea about what object they originate from, but if you look in dev console it triggers two events
image

@dmitrylyzo
Copy link
Contributor

No idea about what object they originate from, but if you look in dev console it triggers two events image

These are the handlers. Look to the right where these lines are coming from.
I guess:

  1. onPlaybackStart from components/nowPlayingBar.
  2. onStateChanged from components/nowPlayingBar.
  3. onPlaybackStart from controllers/playback/video.

The latter is difficult to reproduce. SyncPlay just probably triggers an additional event after sync.

If so, I think that's fine.

@PeachesMLG
Copy link

PeachesMLG commented May 14, 2024

Yeah, your right, I didnt realise they were handlers listening to an event, I thought they were indicating an event was called/triggered.

@soultaco83
Copy link
Author

Good to know. For now I will revert the change back to the original and await a new update

@Mondrethos
Copy link

Went crazy trying to troubleshoot this over the last 2 days. Glad someone already make an issue.

@thornbill thornbill changed the title [Issue]: Syncplay sessions close after playing video for 30 seconds Syncplay sessions close after playing video for 30 seconds May 15, 2024
@thornbill
Copy link
Member

thornbill commented May 15, 2024

@PeachesMLG Do you plan to open a PR?

I opened a PR to try to get the fix in the next release.

@soultaco83
Copy link
Author

I have built the webui with the new change. This appears to be working. I will continue to test. Thank you for your work @PeachesMLG and @thornbill

@chokonmainatsu
Copy link

Is there a rough time window, when this will be released with version 10.9.2?

@TimGels
Copy link
Member

TimGels commented May 16, 2024

Is there a rough time window, when this will be released with version 10.9.2?

As soon as it is ready. Don't expect it to take months.

@PeachesMLG
Copy link

@PeachesMLG Do you plan to open a PR?

I opened a PR to try to get the fix in the next release.

Sorry, I didnt want to raise one since I dont know the codebase well enough to know if there was any side effects to moving it

Release 10.9.z automation moved this from To do to Done May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed The issue has been verified regression We broke something
Projects
Development

No branches or pull requests

10 participants