60 views
Skip to first unread message

Valentin Gosu

unread,
Aug 11, 2022, 8:50:05 AM8/11/22
to dev-platform
Hi everyone,

As Bug 1705676 - Investigate purging HTTP disk cache using backgroundtasks (out-of-process) is getting closer to landing, I wanted to give everyone a heads-up about this change and the reasoning behind it.

We have a non-default setting in the History settings preferences panel where you may choose to "Clear History when Firefox closes" - which sets the privacy.sanitize.sanitizeOnShutdown pref. If the Cache checkbox is also checked that sets the privacy.clearOnShutdown.cache pref to true.
When both of these prefs are true CacheObserver::ClearCacheOnShutdown() will return true, which will cause Firefox to clear the HTTP disk cache during shutdown. This will block shutdown for however long this takes. If the user has a slow disk, or the user is on Windows and something is blocking the deletion of those files, this will trigger a shutdown hang making Firefox crash. This also leads to a bad user experience as trying to start Firefox again during this time will show the "Firefox is already running message". Eventually a crash dump is produced. Bug 1356853 and bug 1682899 are caused by this specific issue.

In order to avoid these shutdown hangs, we have introduced a new mechanism that uses background tasks to delegate the deletion of the cache to a separate process that may outlive Firefox. Even if this process is unexpectedly killed (as may happen during shutdown), we spawn it again after Firefox starts up to clean up any directories that may be left.

The plan is to enable this on Windows Nightly in the next few days to evaluate if this does indeed work as expected. Assuming it doesn't cause any issues, we plan to ship it to beta and release at a later date.

Please let me know if you have any concerns. Many thanks to Nick Alexander who supported this effort with a lot of reviews and improvements to backgroundtasks.

Thanks,
Valentin

Paul Zühlcke

unread,
Aug 11, 2022, 9:13:46 AM8/11/22
to Valentin Gosu, dev-platform
This is awesome! Thanks for working on it.
What happens if the disk cache clearing hasn't finished when user starts Firefox again? Will they still be able to use the cache?

--
You received this message because you are subscribed to the Google Groups "dev-pl...@mozilla.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dev-platform...@mozilla.org.
To view this discussion on the web visit https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/CACQYfiKjNJVMMkPZy%2BF9AXiO1fJ4ieLhRYgwrkwwPRAe3STDWQ%40mail.gmail.com.

Valentin Gosu

unread,
Aug 11, 2022, 9:22:52 AM8/11/22
to Paul Zühlcke, dev-platform
On Thu, 11 Aug 2022 at 15:13, Paul Zühlcke <p...@mozilla.com> wrote:
This is awesome! Thanks for working on it.
What happens if the disk cache clearing hasn't finished when user starts Firefox again? Will they still be able to use the cache?

Good question. The cache folder is renamed, prior to deletion, so we can be sure the background task has exclusive access to it. A new instance would start with a completely new cache folder, even if the background task hasn't finished deleting the old one yet.

PS. Sorry for forgetting the subject in my previous email 🙂

Sean Rose

unread,
Aug 12, 2022, 2:34:55 PM8/12/22
to Valentin Gosu, Paul Zühlcke, dev-platform
If "something is blocking the deletion of those files", wouldn't that also block renaming the cache folder?

Sean Rose
(he/him && Senior Data Engineer && Mozilla Corporation)
(sr...@mozilla.com || Slack @srose || Matrix @srose)


Valentin Gosu

unread,
Aug 15, 2022, 2:49:35 AM8/15/22
to Sean Rose, Paul Zühlcke, dev-platform
On Fri, 12 Aug 2022 at 20:34, Sean Rose <sr...@mozilla.com> wrote:
If "something is blocking the deletion of those files", wouldn't that also block renaming the cache folder?

Usually what's "blocking" the deletion is a slow disk. A rename operation is just one operation, so it should complete much faster than removing thousands of files.
Reply all
Reply to author
Forward
0 new messages