Andrews54757 / FastStream

Stream videos without buffering in the browser. An extension that gives you a better, accessible video player designed for your needs.
https://faststream.online/
Other
443 stars 30 forks source link

[BUG] Download button not actually save the video - Firefox Addon #235

Closed basyirstar closed 2 months ago

basyirstar commented 2 months ago

Describe the bug Download the video button not actually save the video, only message "Save complete!" appear without saving or downloading video.

Version FastStream 1.3.26 on Firefox for Mac

Platform Firefox for Mac

Steps to Reproduce Just download any video from any website.

Andrews54757 commented 2 months ago

That is because your browser is blocking the download. The iframe on the website is likely in sandbox mode, which means it has restricted features. Try using Chrome. You can also copy the source from the sources browser, and load it in a new tab player.

Andrews54757 commented 2 months ago

Fixed

pintassilgo commented 2 months ago

Latest release fixed downloading in default container, but it still doesn't work if you try in a different container. Maybe it's needed to declare contextualIdentities permission in manifest.json?

Andrews54757 commented 2 months ago

Firefox implements blob URL isolation which restricts downloads based on what top level sites it was created on with the intention of reducing trackability. Unfortunately, this feature also unintentionally caused downloads to fail when invoked from sandboxed iframes. This is a bug of Firefox, and it was tracked here. In principle, blob URL isolation should not affect downloads as <a target="_blank"> is equivalent to top level/global navigation (going to a URL in a new tab) in terms of security/privacy.

Strangely enough, while that bug is marked as fixed for regular websites, the issue still persists for extension pages. I don't know exactly why, but it seems to be another bug. I plan on submitting a new report to Mozilla tomorrow. In the meantime, the new FastStream update fixes this issue by utilizing the downloads API from the background script to initiate saving Blob URLs, thereby emulating top level/global navigation which is exempt from the restrictions.

I'm not sure how this works with Firefox's containers system, but I imagine that it isn't bug free either. Containers likely introduce another level of restrictions for downloading Blobs. Since this is an internal mechanism, the contextualIdentities API is unlikely to resolve the issue. I will mention it in my bug report tomorrow.

Andrews54757 commented 2 months ago

A bug report has been filed for Firefox here

After some investigation, I found that the download issue occurs in any frame with a different registrable domain. No sandboxing is required to cause the issue. See the MRE:

https://faststream.online/bugs/firefox-blob-isolation-test

pintassilgo2 commented 2 months ago

Giving that download works in normal container, I still believe this can be fixed by making extension aware of containers.

Look:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/download#cookiestoreid

You should pass cookieStoreId to downloads.download call.

Andrews54757 commented 2 months ago

Just tried that, it doesn't work. https://github.com/Andrews54757/FastStream/commit/eea9a1d1f184ad6ba240817a70f5c87f789579da

Andrews54757 commented 2 months ago

I figured a way to go around it by opening a new tab within the correct container, and requesting a download from there. It is a terrible, terrible way to do it but there is no other option atm. I hope Mozilla fixes Firefox soon.

pintassilgo commented 2 months ago

Thanks, I confirm it's working now.

I can't even notice the temporary background tab, for me it's fine, but I noticed one thing:

When I download a video from a container tab, Firefox displays the download dialog so that I can choose the destination folder.

But when I download from default container, it downloads without asking, even though I have the option "Always ask you where to save files" enaled in Firefox settings.

Do you know why this happens? The behavior for normal tabs is wrong, it should honor my preference hence display the download dialog. It works as expected in container tab and private window, but should be fixed in normal tabs.

Andrews54757 commented 2 months ago

Fixed