pixeltris / TwitchAdSolutions

8.11k stars 461 forks source link

vaft issues (freezing / paused / playback problems) #164

Open TsukiZero opened 1 year ago

TsukiZero commented 1 year ago

They might be tied to ads, but sometimes the video freeze and the audio keeps going, when this happens the quality changes from whatever it was to 360p for a moment or until the player is reset.

With "Video Swap New" it causes the quality to change completely from whatever to 360p but the frames stops freezing.

MonfGeiger commented 1 year ago

I can confirm this. im currently watching a live LaynaLazar stream right now at the time of this comment, and i can confirm random frame freezes, on top of a video quality issue and a total video freeze

TsukiZero commented 1 year ago

This issue still persists in the new build.

pixeltris commented 1 year ago

Correct. I'm not working on fixes for the freezing issues.

TsukiZero commented 1 year ago

No idea on solutions either?

Zero3K commented 1 year ago

Any updates?

TsukiZero commented 1 year ago

No fix yet, no one looking into it apparently.

izar3 commented 9 months ago

This has something to do with bad connection when ads start. It does not happen if your connection is stable and have low latency

I have tested this while an ad is playing, dropping my connection in and out and it will always swap to source > 360p > source > Freeze

My testing on #222 findReactNode() was broken and lead to incorrect results but if you remove this function in the latest build there is no freezing during ads even if your connection is unstable

so.. is there a way to change the alt player/m3u8 when ads are showing to 720p or source quality or another solution?

pixeltris commented 9 months ago

Under vaft every time the Twitch player requests the m3u8 it requests 3 different m3u8 player types. The first two have source quality. The last doesn't. This is already pretty aggressive at trying to get the source quality. If you'd like to be more aggressive you could add a fourth request.

https://github.com/pixeltris/TwitchAdSolutions/blob/7a8fa9923ca0fac8ed293d396898eea5124c616a/vaft/vaft.user.js#L293-L296

Replace with:

weaverText = await processM3U8(url, responseText, realFetch, 'site');
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
}
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
}

This requests the main 'site' player type twice but the second one will get a new access token which can sometimes get you a clean stream faster. This constant swapping of the active m3u8 is the reason for that player pause/play / findReactNode() stuff to circumvent freezing.

Also see Purple AdBlock which is also pretty aggressive at requesting different player types https://github.com/arthurbolsoni/Purple-adblock/blob/main/serviceWorker/src/modules/stream/interface/stream.enum.ts

If this isn't good enough then you are looking for a proxy solution. See TTV LOL PRO https://github.com/younesaassila/ttv-lol-pro

izar3 commented 9 months ago

https://github.com/pixeltris/TwitchAdSolutions/blob/7a8fa9923ca0fac8ed293d396898eea5124c616a/vaft/vaft.user.js#L293-L296

Replace with:

weaverText = await processM3U8(url, responseText, realFetch, 'site');
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType2);
}
if (weaverText.includes(AdSignifier)) {
    weaverText = await processM3U8(url, responseText, realFetch, PlayerType3);
}

I tested this for 4~ hrs with midrolls every 30-60 mins and this works way better

The only time I have seen it pause/play is at the start of a midroll but it's instant and always finds clean segments at source quality

ty pixeltris

TsukiZero commented 8 months ago

So, the bug is back, that patch does nothing.

guniu commented 2 months ago

I had video buffering issues and decided to look into code (I know nothing about js, just curiosity) and found this part: https://github.com/pixeltris/TwitchAdSolutions/blob/859802410009e3a9bf47a804a502f2dbbf38d150/vaft/vaft-ublock-origin.js#L93-L98 It says "This is used to fix the bug where the video would freeze." but then it 'returns' immediately after doing nothing in result. Just checking if that is intentional or mistake in commenting out that 'if'?

TsukiZero commented 2 months ago

I had video buffering issues and decided to look into code (I know nothing about js, just curiosity) and found this part:

https://github.com/pixeltris/TwitchAdSolutions/blob/859802410009e3a9bf47a804a502f2dbbf38d150/vaft/vaft-ublock-origin.js#L93-L98

It says "This is used to fix the bug where the video would freeze." but then it 'returns' immediately after doing nothing in result. Just checking if that is intentional or mistake in commenting out that 'if'?

uncommenting that causes the player settings to constantly be on screen, closing it only reopens it seconds after.

placchio commented 1 month ago

I also have the loading/buffering issue during ads with vaft. When u start watching a stream it works, but then after a while (sometimes hours, sometimes 40mins, seems like it scales up with the amount of ads played by the streamer) the buffering/loading transition to the lower resolution when skipping the ad increases more and more until it becomes an endless buffering/loading. Only solution at that point is to manually pause/unpause the stream. Also bad is that is that you cant even close the tab and reopen to fix it, you need to restart the browser (i use the ublock vaft script on chrome). But then the issue shows up again after a while. Very awful bug.

TsukiZero commented 1 month ago

both VAFT and Video-Swap-New are now halting COMPLETELY when a midroll starts, not even player reset resumes it, only full refresh does

stevenya97 commented 1 month ago

Let's try to keep this a vaft focused discussion in this issue, and can get to video-swap-new later if this case is reproducible. To be clear, do you have just vaft script enabled/loaded? Using multiple scripts/twitch adblock solutions at once can cause playback to halt consistently. What is your extension/vaft setup? Not seeing that behavior where it requires a full refresh on my end, but maybe I can recreate yours.

TsukiZero commented 1 month ago

Only one of them for sure. It was happening all the time yesterday, had to switch on the VPN to mitigate the issue.

YofarDev commented 2 weeks ago

I also have the same freeze problem with vaft since few weeks.

Here the logs (on Zen browser, a fork of firefox) when it happens :

XHRPOST https://gql.twitch.tv/gql#origin=twilight [HTTP/3 400 162ms]

7:31:44 PM [ERROR] [apollo] Received non-200 response from GraphQL. Error: Received non-200 response from GraphQL. An https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 An https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 promise callback655275/e/this.apolloLinkFetch/An</< https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 apolloLinkFetch https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 y https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 e https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 subscribe https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 S https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 e https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 subscribe https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 bn https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 e https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 subscribe https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 p https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 promise callback25931/p/</< https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 e https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 subscribe https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 complete https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 start https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 t https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 getObservableFromLink https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 getResultsFromLink https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 b https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 fetchQueryByPolicy https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 x https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 fetchConcastWithInfo https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 fetchQuery https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 query https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 query https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 c https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 c https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 l https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 h https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 l https://assets.twitch.tv/assets/core-6fdb799352ac65d44bd2.js:1 re https://assets.twitch.tv/assets/pages.channel.components.channel-shell.components.chat-shell.components.chat-live-b32edffe677229e9cefe.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1 s https://assets.twitch.tv/assets/vendor-feb2465b67ee100970e0.js:1

Object { status: 400 } core-6fdb799352ac65d44bd2.js:1:1722344

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://sentry.io/api/1517394/envelope/?sentry_key=26325509987e418db03e96d12352a731&sentry_version=7&sentry_client=sentry.javascript.browser%2F8.27.0. (Reason: CORS request did not succeed). Status code: (null).