ThaUnknown / miru

Bittorrent streaming software for cats. Stream anime torrents, real-time with no waiting for downloads.
https://miru.watch
GNU General Public License v3.0
2.43k stars 134 forks source link

Subtitles intermittently disappearing #112

Closed ghost closed 2 years ago

ghost commented 2 years ago

Describe the bug While watching an episode subtitles will randomly at times stop showing up during dialogue and reappear after some time.

To Reproduce Steps to reproduce the behavior: Open up any episode and watch for a short period of time until subtitles disappear.

Expected behavior A clear and concise description of what you expected to happen. Subtitles should follow dialogue between characters and not drop out during some sentences.

Desktop (please complete the following information):

Additional context I have only used the app to watch anime twice and on the first occurrence was during Attack on Titan's final season part 2 episode 10 on version 0.6.0 of the app. I noticed multiple segments where the subtitles would drop off and after some time would reappear. The next time I tried testing it on version 0.6.4 of the app by watching an episode of My dress-up darling episode 1 and paused the episode at the beginning in hopes of letting it download properly, but still experienced a few times where subtitles dropped out again but not as often as on 0.6.0.

ThaUnknown commented 2 years ago

this is a known issue with the parser that occurs when your internet connection can't match that of video bitrate, what ends up happening is the video makes another stream request, ditches the old one which causes a single subtitle cue to get omitted

ThaUnknown commented 2 years ago

I'll attempt to fix this after #103 is resolved

ghost commented 2 years ago

Could reproduce this on [Erai-raws] Jujutsu Kaisen - 06 [1080p HEVC][Multiple Subtitle].mkv 17:10 17:22 local persisted file.

[matroska-subtitles] EBML stream decoding error subtitle-stream.js:49

Uncaught TypeError: Failed to execute 'close' on 'ReadableStreamDefaultController': Cannot close an errored readable stream
    at MessagePort.<anonymous>

(sw.js:57:24)

Registering this here for future reference to check if its fixed or a new bug.

ThaUnknown commented 2 years ago

this happens because the stream is prematurely closed or because it pushed null, it's intentional to prevent ram leaks, but it's possible it happens when not intended, will debug

rubanunes commented 2 years ago

Don't know if it helps but the issue only appears to me when using the next episode function or when skipping the opening. Because if it happens I just restart the app and it's fine

ThaUnknown commented 2 years ago

Don't know if it helps but the issue only appears to me when using the next episode function or when skipping the opening. Because if it happens I just restart the app and it's fine

just a coincidence

ThaUnknown commented 2 years ago

I figured out why this wasn't an issue in my browser version, I cache 1 chunk ahead which forces the parsing of partial subtitle cues, which would otherwise be cut, so the solution for this is to: create a passthrough or even a async iterator, which caches 1-2 chunks ahead and the chunks which are caches would be pulled tru the EBML parser, essentially always caching&parsing 2 chunks ahead, then when a port re-opens after closing/cutting off it will actually be behind what was pulled by the caching iterator and the cues will overlap preventing loss

ThaUnknown commented 2 years ago

I've added some patches in https://github.com/ThaUnknown/miru/commit/dc813fcdf932db722f71c380b376766aa4de754d to mitigate this a bit, but those are still just patches, the underlying issue is not fixed, and I will not attempt to fix it until the IPC re-write because of bugs caused by electrons node integration

ThaUnknown commented 2 years ago

95e8c8e6cb66508a82edc17897e6c3412f98ff4b

ThaUnknown commented 2 years ago

@oelow please try reproducing the issue on 1.0.1, I believe it was fixed however thanks to the HTTP server implementation which closes streams, without me having to patch stream closing by hand

ThaUnknown commented 2 years ago

I can no longer reproduce the issue, except for when seeking onto a cue, but all video players have that issue. I'm gonna mark this as fixed, ping me here if the issue persists https://github.com/ThaUnknown/miru/commit/ac265701179f4eff171fa449bb05ead6bcc91564