gecko-dev/toolkit/mozapps
Nick Alexander 6ff82016a0 Bug 1804757 - Avoid shutdown crashes writing `targeting.snapshot.json`. r=barret
This commit trades away consistency in order to reduce code execution.
Hopefully this avoids executing code that is likely not "shutdown
safe" and is inadvertently restarting services or otherwise hanging
when run during shutdown.

The trade off is that the written targeting snapshot may now be
incomplete (which was always the case in the face of runtime errors,
e.g., corrupt a database) or internally inconsistent (which is
probably new).  For example, weekly usage could be populated but most
frecent sites could be empty, contradicting the usage.  This trade-off
is accepted: occassionally targeting the user "in the
past" (generally, with data captured 30 minutes ago) is preferable to
relatively frequent shutdown crashes.

I would have liked to have checked for `shuttingDown` in
[CachedTargetingGetter](https://searchfox.org/mozilla-central/rev/abf6758ed833c203f84703aa2e3e3d317571b1e9/browser/components/newtab/lib/ASRouterTargeting.jsm#152),
but doing so might throw exceptions (or inject `null` values) where
they were not anticipated, which carries risks that I couldn't easily
mitigate.

If the measure implemented here is ineffective, we'll likely need to
restrict the set of targeting data collected, but I hope to avoid
that, since it reduces the flexibility of the background messaging
targeting significantly, and we may want the agility provided by rich
targeting at an unknown time in the future.

Differential Revision: https://phabricator.services.mozilla.com/D165916
2023-01-10 21:22:46 +00:00
..
defaultagent
downloads Bug 1803010 - Fix one xpcshell test. 2022-11-29 17:06:49 +01:00
extensions Bug 1809438 - Skip test_colorways_builtin_theme_upgrades.js for Thunderbird. r=rpl 2023-01-10 15:44:46 +00:00
handling Bug 1792138: Show the extension's name in permission prompts for opening external links. r=ckerschb,robwu,fluent-reviewers,pbz,flod 2023-01-07 17:53:19 +00:00
installer Bug 1801836 - Remove no longer necessary 'from __future__' imports. r=linter-reviewers,glandium,webdriver-reviewers,perftest-reviewers,geckoview-reviewers,jld,ahal,owlish,afinder DONTBUILD 2022-12-23 22:45:46 +00:00
notificationserver Bug 1795974 - Allow Firefox to focus itself when a Windows native notification is clicked. r=nalexander,nika 2023-01-06 18:36:23 +00:00
preferences Bug 1803756 - Automatically replace Cu.reportError with console.error (preferences). r=mconley 2022-12-06 02:26:51 +00:00
update Bug 1804757 - Avoid shutdown crashes writing `targeting.snapshot.json`. r=barret 2023-01-10 21:22:46 +00:00