Closed Bug 1285921 Opened 8 years ago Closed 8 years ago

setEmptyPrefWatchList() doesn't wait for TelemetryEnvironment to initialize

Categories

(Toolkit :: Telemetry, defect, P1)

defect
Points:
1

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox50 --- affected
firefox51 --- fixed

People

(Reporter: gfritzsche, Assigned: gfritzsche)

Details

(Whiteboard: [measurement:client])

Attachments

(1 file, 1 obsolete file)

After bug 1273889, Preferences.ignore() on unwatched preferences will lead to errors reported in the console.

> This shows many exceptions like this:
> > "CONSOLE_MESSAGE: (info) 1468205679500	Toolkit.Telemetry	TRACE	TelemetryEnvironment::_stopWatchingPrefs"
> > "CONSOLE_MESSAGE: (error) [JavaScript Error: "Attempt to stop observing a preference "app.feedback.baseURL" that's not being observed" {file: "resource://gre/modules/Preferences.jsm" line: 323}]
> > Preferences.ignore@resource://gre/modules/Preferences.jsm:323:5
> > EnvironmentCache.prototype._stopWatchingPrefs@resource://gre/modules/TelemetryEnvironment.jsm:913:9
> 
> These are explained by bug 1273889, which made `Preferences.ignore()` report
> an error on trying to stop watching unwatched prefs.
> That is just error output though and shouldn't make the test fail.

This shows that our test fix for TelemetryEnvironment not watching prefs by default [1] is racey.
If TelemetryEnvironment is still async initializing, it might not have called `_startWatchingPrefs()` yet [2].
In that case, `_watchPreferences()` (called from `testWatchPreferences()`) tries to .ignore() preferences that are not watched yet at [3].

[1] https://dxr.mozilla.org/mozilla-central/rev/23dc78b7b57e9f91798ea44c242a04e112c37db0/toolkit/components/telemetry/tests/unit/head.js#288
[2] https://dxr.mozilla.org/mozilla-central/rev/23dc78b7b57e9f91798ea44c242a04e112c37db0/toolkit/components/telemetry/TelemetryEnvironment.jsm#769
[3] https://dxr.mozilla.org/mozilla-central/rev/23dc78b7b57e9f91798ea44c242a04e112c37db0/toolkit/components/telemetry/TelemetryEnvironment.jsm#852
One solution is to always wait for TelemetryEnvironment to finish initializing.
Comment on attachment 8769649 [details] [diff] [review]
setEmptyPrefWatchList() doesn't wait for TelemetryEnvironment to initialize

Review of attachment 8769649 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good, do we need to remove the other use of |do_test_pending|?

::: toolkit/components/telemetry/tests/unit/test_TelemetryController_idle.js
@@ +20,1 @@
>    do_test_pending();

Should this be removed, along with |do_test_finished| a few lines below?
Attachment #8769649 - Flags: review?(alessio.placitelli) → feedback+
Attachment #8769649 - Attachment is obsolete: true
Attachment #8769660 - Flags: review?(alessio.placitelli) → review+
Whiteboard: [measurement:client]
Pushed by georg.fritzsche@googlemail.com:
https://hg.mozilla.org/integration/fx-team/rev/9dae91a2c31d
setEmptyPrefWatchList() doesn't wait for TelemetryEnvironment to initialize. r=dexter
https://hg.mozilla.org/mozilla-central/rev/9dae91a2c31d
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: