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

[BUG] Firefox edition doesn't delete video cache if a website isn't visited again #244

Closed
pintassilgo opened this issue Sep 13, 2024 · 8 comments

Comments

@pintassilgo
Copy link

I was backing up my Firefox profile when I noticed my profile/storage was giant. The folder firefoxprofile/storage/default/moz-extension+++143e38cf-ad72-4edc-b850-046dfba7ec57 alone, which is FastStream storage folder, is taking 10GB. That was with Firefox closed, so there was nothing being downloaded or anything.

FastStream seems to be failing/missing to delete unused storage.

Firefox Developer Edition 131.0b05.

@pintassilgo pintassilgo changed the title [BUG] Taking way to much storage even when browser is closed [BUG] Taking way too much storage even when browser is closed Sep 13, 2024
@Andrews54757
Copy link
Owner

not sure I can do anything about that beyond what is already done, faststream only uses indexeddb storage on Firefox, where blob to file offloading is not implemented. in case any data is left behind, faststream on firefox will do a scan of all databases in indexeddb to remove stale entries. this is pretty foolproof. the issue likely lies in the fact that some databases may be inaccessible to faststream due to FF's state partitioning - if you watch a video on many different websites, a faststream instance on one website may be unable to discover the databases on another.

Theres many ways to fix this issue, but they require Firefox to implement some changes. I would welcome a new API to disable state partitioning in extension pages. They could also implement better blobs or change their minds about the FileSystem API

@ale5000-git
Copy link

ale5000-git commented Sep 13, 2024

@Andrews54757
Is it possible to add a button inside FastStream settings to manually clear all caches (even not-stale entries), basically to remove everything excluding settings?
(it should include also youtubei.js database and all other things)

@Andrews54757
Copy link
Owner

Andrews54757 commented Sep 14, 2024

You don't have to worry about old caches if you use Chrome, because faststream doesn't need to use manually controlled caches there, it doesn't use any databases except for YoutubeJS, which is handled as a part of the library (faststream only decides if it is enabled). For firefox, a button won't be much better if you never visit the website again since the extension cannot access caches/storage on a website without you navigating there manually and it will automatically remove any caches as soon as you enable faststream on the website anyways.

@ale5000-git
Copy link

ale5000-git commented Sep 14, 2024

I usually empty browser cache often also for privacy, and it would be nice to be able to do it also for your extension (that would probably contain a trace of what the user has done).
Also it would also help for possible bugs in caches, because the code (not yours, but in general) always has bugs.

@Andrews54757
Copy link
Owner

Andrews54757 commented Sep 14, 2024

Like I mentioned, such a button would only clear entries that FastStream has access to, and it already does that automatically. I don't think it would be wise to add a button that doesn't do what it is supposed to do. It's a firefox issue, it is not something FastStream can control right now. Nevertheless, I am actively searching for ways to get around it by analyzing firefox's code. but until then, this is not an issue that can be fixed automatically.

by the way, you can clear any databases associated with faststream (except configuration) by clearing caches/cookies/site-data/etc.. the normal way as provided by Firefox in browser settings. The browser will also (supposedly) evict databases automatically with time if you do nothing.

@Andrews54757
Copy link
Owner

You can check the indexeddb management code for yourself here: https://github.com/Andrews54757/FastStream/blob/main/chrome/player/network/IndexedDBManager.mjs

Note: You can ignore the code relating to localStorage, fs_temp_databases and fs_temp_databases_deleted. They only store the names of databases for browsers that don't implement indexeddb's databases() method which retrieves all accessible indexeddb database names. It used to be the case that Firefox didn't support it, but they have since added it in May 2024. Up till that point Firefox was the only browser that didn't support it.

@Andrews54757 Andrews54757 changed the title [BUG] Taking way too much storage even when browser is closed [BUG] Firefox edition doesn't delete video cache if a website isn't visited again Sep 14, 2024
@Andrews54757
Copy link
Owner

If this issue impacts you severely, try disabling Enhanced Tracking Protection on Firefox if you have it turned on.

@Andrews54757
Copy link
Owner

Andrews54757 commented Sep 15, 2024

Thanks to the help of asuth from Mozilla Chat, I was able to fix this issue using some... tricks. Now all temporary files should be deleted as soon as the session ends.

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants