Hello everyone,

I was debugging something completely unrelated to Firefox on my Mac when I
saw the following events in my console:

501:com.apple.safarishared.WBSParsecDSession.*autoFillDataUpdate*:FD5887:[
    {name: *DeviceActivityPolicy*, policyWeight: 2.000, response: {*Decision:
Can Proceed*, Score: 0.89}}
 ] sumScores:31.798889, denominator:32.010000, *FinalDecision: Can Proceed,*
Final Score: 0.993405}

501:com.apple.Safari.SafeBrowsing.*BrowsingDatabases.Update*:D8F622:[
    {name: *ChargerPluggedInPolicy*, policyWeight: 20.000, response:
{*Decision:
Must Not Proceed*, Score: 0.00, Rationale: [{/*device/system/isPluggedIn ==
0*}]}}
 ], *FinalDecision: Must Not Proceed*}

What you are looking at is an OS-provided policy engine that can tell an
application if now is a good time to perform a specific task. Specifically
tasks that use a scarce resource like the network, battery or cpu. This is
all about not being that energy hog on a mobile device.

In the above two samples the tasks involve talking to the network; syncing
autofill data with iCloud and keeping a SafeBrowsing database up to date.
The first request is allowed to happen while the second is not. This is
because I removed the charging cable from my macBook and to safe energy,
macOS recommends to not do unnecessary network activity in that case.

This would be wonderful to have in our Android products. But probably also
in Gecko - assuming we have a lot of people using laptops.

For example those products could start asking questions like:

 - Should we vacuum our SQLite databases? (No - the user is actively using
the application and the battery level is low)
 - Should we download the safe browsing database? (No - the device is not
connected to the charger)
 - Should we resize screenshots for top sites? (No  - the device is running
a bit hot currently)
 - Should we sync history and bookmarks? (No - the device is in a
downgraded network state, like GPRS or 3G vs the normal LTE)
 - Should we download the latest Nightly update? (No - disk space is low)

I think if we build a policy engine that lets you describe your intent ("I
want to download an 80 MB file") together with weighted policies
(DeviceActivity, NetworkType, DiskSpace, NetworkType, etc.) we could
improve the scheduling of tasks and be more efficient on battery powered
devices.

What do you think? Is this something we should invest in?

 S.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to