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

Browser deleting FlagPlayer Cache frequently #2

Closed
Seneral opened this issue Jun 16, 2020 · 0 comments
Closed

Browser deleting FlagPlayer Cache frequently #2

Seneral opened this issue Jun 16, 2020 · 0 comments

Comments

@Seneral
Copy link
Owner

Seneral commented Jun 16, 2020

So the browser can at will delete the saved playlist and cache streams at will if the application uses too much data or the device storage is full.
This is still happening to my phone very fequently, even though not a lot of data is used.

I tried to fix that by typical means, e.g. bookmark it and add it to the homescreen, to no avail.

Turns out I overlooked a significant limitation when caching the thumbnail images.
The thumbnails are fetched directly from youtubes servers and then cached. Due to CORS policy, the image data of this is protected, inaccessible by a userscript. When cached, this means the response type is 'opaque'. So while individual thumbnails only make up for around 4kB, Chrome policy dictates that all opaque cached items (in other words, those fetched from other origins) make up at least 7MB in quota usage.
For my test case, just saving a playlist of a thousand videos would add 7GB to the storage quota, even though it is actually only 4MB of data. This resulted in the browser deleting the data very quickly.

There are two possible solutions to this:

  1. Don't cache the thumbnails at all. Since they are so small this would be sad because they add quite a lot to the offline experience. The masses of requests when loading up a 1000-video playlist is also not healthy if not cached.
  2. Route them though the cors server, just like the cached audio stream, to circumvent cors policy. This would only be added for explicitly cached thumbnails, e.g. those of cached playlists, and not other thumbnails. Other thumbnails would not be cached at all anymore. The effect on the cors server would be pretty big. Also I would have to ease the request limit once more to allow users to cache a 1000-video playlist at once.

I'd want to go for 2., but for the short term, I'll probably do 1. until I have the time to adress this properly.

Seneral added a commit that referenced this issue Jun 23, 2020
Removed opaque caching of thumbnails which resulted in 7MB of quota usage per thumbnail - fixes #2
Added explicit caching of thumbnails when saving or updating a playlist
Added warning to cache view for bloated cache when thumbnails have been saved on a previous version
Added option to reload all relevant thumbnails for affected users (well that'd actually be only me)

Fixed unavailable videos not being detected
Added error message to convey cause of error for various known and unknown errors

Reworked database and playlist API to use promises (important for other usages later on)
Seneral added a commit that referenced this issue Sep 22, 2021
Removed opaque caching of thumbnails which resulted in 7MB of quota usage per thumbnail - fixes #2
Added explicit caching of thumbnails when saving or updating a playlist
Added warning to cache view for bloated cache when thumbnails have been saved on a previous version
Added option to reload all relevant thumbnails for affected users (well that'd actually be only me)

Fixed unavailable videos not being detected
Added error message to convey cause of error for various known and unknown errors

Reworked database and playlist API to use promises (important for other usages later on)
Seneral added a commit that referenced this issue Sep 22, 2021
Removed opaque caching of thumbnails which resulted in 7MB of quota usage per thumbnail - fixes #2
Added explicit caching of thumbnails when saving or updating a playlist
Added warning to cache view for bloated cache when thumbnails have been saved on a previous version
Added option to reload all relevant thumbnails for affected users (well that'd actually be only me)

Fixed unavailable videos not being detected
Added error message to convey cause of error for various known and unknown errors

Reworked database and playlist API to use promises (important for other usages later on)
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

1 participant