diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index a23fed97f476..87a8d5fae121 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -157,6 +157,7 @@ const PREF_UPDATE_AUTODOWNLOAD = "app.update.auto"; const EXPERIMENTS_CHANGED_TOPIC = "experiments-changed"; const SEARCH_ENGINE_MODIFIED_TOPIC = "browser-search-engine-modified"; const SEARCH_SERVICE_TOPIC = "browser-search-service"; +const COMPOSITOR_CREATED_TOPIC = "compositor:created"; /** * Get the current browser. @@ -809,12 +810,14 @@ EnvironmentCache.prototype = { // Watch the search engine change and service topics. Services.obs.addObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC, false); Services.obs.addObserver(this, SEARCH_SERVICE_TOPIC, false); + Services.obs.addObserver(this, COMPOSITOR_CREATED_TOPIC, false); }, _removeObservers: function () { // Remove the search engine change and service observers. Services.obs.removeObserver(this, SEARCH_ENGINE_MODIFIED_TOPIC); Services.obs.removeObserver(this, SEARCH_SERVICE_TOPIC); + Services.obs.removeObserver(this, COMPOSITOR_CREATED_TOPIC); }, observe: function (aSubject, aTopic, aData) { @@ -834,6 +837,12 @@ EnvironmentCache.prototype = { // Now that the search engine init is complete, record the default search choice. this._updateSearchEngine(); break; + case COMPOSITOR_CREATED_TOPIC: + // Full graphics information is not available until we have created at + // least one off-main-thread-composited window. Thus we wait for the + // first compositor to be created and then query nsIGfxInfo again. + this._onCompositorCreated(); + break; } }, @@ -896,6 +905,19 @@ EnvironmentCache.prototype = { this._onEnvironmentChange("search-engine-changed", oldEnvironment); }, + /** + * Update the graphics features object. + */ + _onCompositorCreated: function () { + let gfxData = this._currentEnvironment.system.gfx; + try { + let gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); + gfxData.features = gfxInfo.getFeatures(); + } catch (e) { + this._log.error("nsIGfxInfo.getFeatures() caught error", e); + } + }, + /** * Get the build data in object form. * @return Object containing the build data. @@ -1128,6 +1150,7 @@ EnvironmentCache.prototype = { //DWriteVersion: getGfxField("DWriteVersion", null), adapters: [], monitors: [], + features: {}, }; #if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GTK) @@ -1139,6 +1162,13 @@ EnvironmentCache.prototype = { } #endif + try { + let gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); + gfxData.features = gfxInfo.getFeatures(); + } catch (e) { + this._log.error("nsIGfxInfo.getFeatures() caught error", e); + } + // GfxInfo does not yet expose a way to iterate through all the adapters. gfxData.adapters.push(getGfxAdapter("")); gfxData.adapters[0].GPUActive = true; diff --git a/toolkit/components/telemetry/docs/environment.rst b/toolkit/components/telemetry/docs/environment.rst index e4c891fb70c5..ec9e03613f16 100644 --- a/toolkit/components/telemetry/docs/environment.rst +++ b/toolkit/components/telemetry/docs/environment.rst @@ -145,6 +145,28 @@ Structure:: }, ... ], + features: { + compositor: , // Layers backend for compositing (eg "d3d11", "none", "opengl") + + // Each the following features can have one of the following statuses: + // "unused" - This feature has not been requested. + // "unavailable" - Safe Mode or OS restriction prevents use. + // "blocked" - Blocked due to an internal condition such as safe mode. + // "blacklisted" - Blocked due to a blacklist restriction. + // "disabled" - User explicitly disabled this default feature. + // "failed" - This feature was attempted but failed to initialize. + // "available" - User has this feature available. + "d3d11" { // This feature is Windows-only. + status: , + warp: , // Software rendering (WARP) mode was chosen. + textureSharing: // Whether or not texture sharing works. + version: , // The D3D11 device feature level. + }, + "d2d" { // This feature is Windows-only. + status: , + version: , // Either "1.0" or "1.1". + }, + }, }, }, addons: { diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js index 5e0de56e903c..eabb05ceea2b 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js @@ -430,6 +430,9 @@ function checkSystemSection(data) { } } + Assert.equal(typeof gfxData.features, "object"); + Assert.equal(typeof gfxData.features.compositor, "string"); + try { // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing // this test. @@ -439,6 +442,9 @@ function checkSystemSection(data) { Assert.equal(GFX_VENDOR_ID, gfxData.adapters[0].vendorID); Assert.equal(GFX_DEVICE_ID, gfxData.adapters[0].deviceID); } + + let features = gfxInfo.getFeatures(); + Assert.equal(features.compositor, gfxData.features.compositor); } catch (e) {} }