pixeltris / TwitchAdSolutions

7.21k stars 424 forks source link

scripts prevent frankerfacez from loading on firefox #249

Closed yvawt closed 2 weeks ago

yvawt commented 2 months ago

i've tested both scripts - video-swap-new and vaft in two different userscript managers - violentmonkey and tampermonkey, as well as using ublock origins userresource - and both scripts will prevent frankerfacez from loading when you middle click a stream or right click -> open in new tab - if the firefox setting "When you open a link, image or media in a new tab, switch to it immediately" is disabled - if the setting is enabled frankerfacez loads fine, or if you open in a new window instead of tab it also loads fine. i've tested both scripts and they allow frankerfacez to load fine on edge.

Chway commented 1 month ago

Any news on this? I have a similar issue with video-swap-new + Frankerfacez, with FFZ refusing to load when opened in the background, I can't reproduce it consistently tho. But USUALLY, when in a game section, If I open multiple streams using the middle click to send them in the background, the first tab opened will failed to load FFZ, while it will load fine on the others. It can happen too when opening a stream in the background from the popup of an extension that I have made. Indeed, FFZ seems to load fine without video-swap-new and I have no issue when using Brave. After a quick look, another userscript that I have for Twitch refuse to load when paired with video-swap-new.

The only line that could be interesting in the devtools console is Error: page.tabs[tab.id] is undefined undefined, which seems to appear only when FFZ failed to load. I joined the console output of a tab where FFZ fail to load. fail.txt

sham-pain commented 1 month ago

I always have this issue and never noticed that it was caused by the vaft script. I always have to refresh the page once for FFZ to load if I open a stream in a new ("background") tab.

yvawt commented 1 month ago

Initially I though this was an issue only with the scripts, so I decided to try switching to ttv lol pro, and still I get the same issue. There doesn't seem to be any open issues on their repo so I'm not sure if this is a specific issue to just me or what. Also I should say that without the scripts/ttvlol pro frankerfacez loads fine opening in new tab. I've tried creating a new firefox profile to be sure no other extensions or settings are conflicting and still had the issue. I've tried arkenfox and betterfox user.js and still had the issue. I've tried firefox nightly and some forks, floorp, mercury, and librewolf, and all of them still had the issue. I've tried poking around at some about:config settings and couldn't find a fix. When I check the normal devtools console I wasn't seeing the page.tabs error, so I decided to try firefoxs browser toolbox instead, and if set to multiprocess mode suddenly the issue is gone and any stream I open in a new tab properly loads frankerfacez. If anybody can figure out how or why this fixes it that would be a big help as I'm not sure what's going on.

pixeltris commented 2 weeks ago

This synchronous call causes it:

https://github.com/pixeltris/TwitchAdSolutions/blob/c66faba74ff1a8f5dec29c3716276f54c596fdc9/video-swap-new/video-swap-new.user.js#L126-L131

ttv-lol-pro also does the same synchronous call https://github.com/younesaassila/ttv-lol-pro/blob/e2aed80ff90d933f3a4af80684f8bbb51429400e/src/page/page.ts#L55-L57

I can't tell you why it results in FFZ failing to load. Unfortunately due to the way that code works it has to be a synchronous call. A simple fix is to provide a fixed url but this url would need to be updated frequently:

    function getWasmWorkerUrl(twitchBlobUrl) {
        return 'https://assets.twitch.tv/assets/amazon-ivs-wasmworker.min-cd1fea52c5079942d599.js';
    }
yvawt commented 2 weeks ago

the ffz script runs at document-end, it looks like when opening a stream in a new tab the page is stuck trying to load assets.twitch.tv, so that might be preventing ffz from loading?

would something similar to what https://github.com/besuper/TwitchNoSub does work for this? https://github.com/besuper/TwitchNoSub/commit/ce615e3460ff636d3bf20661345bf6faac331a5a

pixeltris commented 2 weeks ago

Yea that would work. Is that an auto updated mirror or manually updated @besuper?

pixeltris commented 2 weeks ago

Fixed in https://github.com/pixeltris/TwitchAdSolutions/commit/2eefb984c10ba64e9528b8cf4350d5fab653bd3a by moving the synchronous call inside the worker itself.