Closed Bug 1775138 Opened 2 years ago Closed 2 years ago

Serialize/snapshot ASRouterTargeting configuration from browsing profiles for use by background task profiles

Categories

(Toolkit :: Background Tasks, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: nalexander, Assigned: nalexander)

References

(Blocks 5 open bugs)

Details

(Whiteboard: [fidedi-notifications])

Attachments

(3 files, 1 obsolete file)

This ticket tracks mirroring ASRouter targeting configuration from browsing profiles to background task profiles (whether ephemeral or persistent). There's no amazing way to achieve this (that I am aware of); I propose to serialize current targeting information as JSON to disk periodically, since the existing system does not track changes to the targeting configuration in a fine-grained manner. See ASRouterTargeting.jsm. This balances freshness with performance -- both when querying the system (which is slow and is currently cached) and when writing to disk. In addition, we'd like to serialize as the browser exits -- but again, this impacts performance.

Summary: Serialize ASRouterTargeting configuration → Serialize ASRouterTargeting configuration from browsing profiles for use by background task profiles
Whiteboard: [fidedi-notifications]

The plan for this ticket is for regular browsing profiles to serialize
their targeting state to JSON on disk. The targeting state will,
ideally, be serialized at start up, periodically during browsing, and
at shutdown. However, everything done here must balance the
performance costs of the (sometimes non-trivial) queries and the cost
of recurring disk I/O.

A background task wishing to target based on browsing profile
configuration may then consume the targeting state serialized by the
default browsing profile, in much the same way that background tasks
read prefs and the legacy telemetry client ID from the default
browsing profile.

But for now, we ignore targeting and just make the existing code
background task-aware for testing.

Depends on D150521

Priority: -- → P2

This commit arranges to write targeting.snapshot.json to the local
profile directory every 30 minutes, and just before shutdown. For
simplicity, it uses the existing JSONFile.jsm implementation.

Summary: Serialize ASRouterTargeting configuration from browsing profiles for use by background task profiles → Serialize/snapshot ASRouterTargeting configuration from browsing profiles for use by background task profiles
Attachment #9284195 - Attachment description: WIP: Bug 1775138 - Part 1: Snapshot Firefox Messaging System targeting configuration periodically. r?barret → Bug 1775138 - Part 1: Snapshot Firefox Messaging System targeting configuration periodically. r?barret

We take a simple approach:

  1. We add a test to verify that all getters succeed in background
    task mode (save for an exclusion list of getters that access
    non-local hosts).
  2. We make certain getters background task-aware: for example,
    because they require the AddonsManager or legacy Telemetry.

This will allow background tasks to access their own targeting as well
as a snapshot of the default profile's targeting.

Depends on D151057

The default browsing profile's targeting snapshot is read using the
standard BackgroundTasksUtils.jsm helpers, which allow setting the
profile location for testing.

The targeting snapshot is provided in the triggering context under
defaultProfile, allowing both the background task profile's
targeting (for things like current Firefox version and currentDate)
and the default browsing profile's targeting (for things like the
snapshot's currentDate and add-ons).

Depends on D151089

Pushed by nalexander@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/71f5e50dc203
Part 1: Snapshot Firefox Messaging System targeting configuration periodically. r=barret
https://hg.mozilla.org/integration/autoland/rev/f6a5a7695418
Part 2: Ensure `ASRouterTargeting.Environment` can be used in background tasks. r=barret
https://hg.mozilla.org/integration/autoland/rev/83349b145d63
Part 3: Consume default profile Firefox Messaging System targeting in background tasks. r=barret
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
Blocks: 1779693
Attachment #9283310 - Attachment is obsolete: true
Regressions: 1788713
Blocks: 1795467
Blocks: 1805242
Blocks: 1832126
Blocks: 1832127
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: