1 /* vim: se cin sw=2 ts=2 et : */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "mozilla/ArrayUtils.h"
10 #include "GfxInfoBase.h"
12 #include <mutex> // std::call_once
14 #include "GfxDriverInfo.h"
15 #include "js/Array.h" // JS::GetArrayLength, JS::NewArrayObject
17 #include "nsCOMArray.h"
19 #include "nsUnicharUtils.h"
20 #include "nsVersionComparator.h"
21 #include "mozilla/Services.h"
22 #include "mozilla/Observer.h"
23 #include "nsIObserver.h"
24 #include "nsIObserverService.h"
25 #include "nsIScreenManager.h"
27 #include "nsXULAppAPI.h"
28 #include "nsIXULAppInfo.h"
29 #include "mozilla/ClearOnShutdown.h"
30 #include "mozilla/Preferences.h"
31 #include "mozilla/StaticPrefs_gfx.h"
32 #include "mozilla/gfx/2D.h"
33 #include "mozilla/gfx/GPUProcessManager.h"
34 #include "mozilla/gfx/Logging.h"
35 #include "mozilla/gfx/gfxVars.h"
36 #include "mozilla/layers/PaintThread.h"
38 #include "gfxPlatform.h"
39 #include "gfxConfig.h"
40 #include "DriverCrashGuard.h"
42 using namespace mozilla::widget
;
43 using namespace mozilla
;
44 using mozilla::MutexAutoLock
;
46 nsTArray
<GfxDriverInfo
>* GfxInfoBase::sDriverInfo
;
47 StaticAutoPtr
<nsTArray
<gfx::GfxInfoFeatureStatus
>> GfxInfoBase::sFeatureStatus
;
48 bool GfxInfoBase::sDriverInfoObserverInitialized
;
49 bool GfxInfoBase::sShutdownOccurred
;
51 // Call this when setting sFeatureStatus to a non-null pointer to
52 // ensure destruction even if the GfxInfo component is never instantiated.
53 static void InitFeatureStatus(nsTArray
<gfx::GfxInfoFeatureStatus
>* aPtr
) {
54 static std::once_flag sOnce
;
55 std::call_once(sOnce
, [] { ClearOnShutdown(&GfxInfoBase::sFeatureStatus
); });
56 GfxInfoBase::sFeatureStatus
= aPtr
;
59 // Observes for shutdown so that the child GfxDriverInfo list is freed.
60 class ShutdownObserver
: public nsIObserver
{
61 virtual ~ShutdownObserver() = default;
64 ShutdownObserver() = default;
68 NS_IMETHOD
Observe(nsISupports
* subject
, const char* aTopic
,
69 const char16_t
* aData
) override
{
70 MOZ_ASSERT(strcmp(aTopic
, NS_XPCOM_SHUTDOWN_OBSERVER_ID
) == 0);
72 delete GfxInfoBase::sDriverInfo
;
73 GfxInfoBase::sDriverInfo
= nullptr;
75 for (auto& deviceFamily
: GfxDriverInfo::sDeviceFamilies
) {
77 deviceFamily
= nullptr;
80 for (auto& desktop
: GfxDriverInfo::sDesktopEnvironment
) {
85 for (auto& windowProtocol
: GfxDriverInfo::sWindowProtocol
) {
86 delete windowProtocol
;
87 windowProtocol
= nullptr;
90 for (auto& deviceVendor
: GfxDriverInfo::sDeviceVendors
) {
92 deviceVendor
= nullptr;
95 for (auto& driverVendor
: GfxDriverInfo::sDriverVendors
) {
97 driverVendor
= nullptr;
100 GfxInfoBase::sShutdownOccurred
= true;
106 NS_IMPL_ISUPPORTS(ShutdownObserver
, nsIObserver
)
108 static void InitGfxDriverInfoShutdownObserver() {
109 if (GfxInfoBase::sDriverInfoObserverInitialized
) return;
111 GfxInfoBase::sDriverInfoObserverInitialized
= true;
113 nsCOMPtr
<nsIObserverService
> observerService
= services::GetObserverService();
114 if (!observerService
) {
115 NS_WARNING("Could not get observer service!");
119 ShutdownObserver
* obs
= new ShutdownObserver();
120 observerService
->AddObserver(obs
, NS_XPCOM_SHUTDOWN_OBSERVER_ID
, false);
123 using namespace mozilla::widget
;
124 using namespace mozilla::gfx
;
125 using namespace mozilla
;
127 NS_IMPL_ISUPPORTS(GfxInfoBase
, nsIGfxInfo
, nsIObserver
,
128 nsISupportsWeakReference
)
130 #define BLOCKLIST_PREF_BRANCH "gfx.blacklist."
131 #define SUGGESTED_VERSION_PREF BLOCKLIST_PREF_BRANCH "suggested-driver-version"
133 static const char* GetPrefNameForFeature(int32_t aFeature
) {
134 const char* name
= nullptr;
136 case nsIGfxInfo::FEATURE_DIRECT2D
:
137 name
= BLOCKLIST_PREF_BRANCH
"direct2d";
139 case nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS
:
140 name
= BLOCKLIST_PREF_BRANCH
"layers.direct3d9";
142 case nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS
:
143 name
= BLOCKLIST_PREF_BRANCH
"layers.direct3d10";
145 case nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS
:
146 name
= BLOCKLIST_PREF_BRANCH
"layers.direct3d10-1";
148 case nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS
:
149 name
= BLOCKLIST_PREF_BRANCH
"layers.direct3d11";
151 case nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE
:
152 name
= BLOCKLIST_PREF_BRANCH
"direct3d11angle";
154 case nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING
:
155 name
= BLOCKLIST_PREF_BRANCH
"hardwarevideodecoding";
157 case nsIGfxInfo::FEATURE_OPENGL_LAYERS
:
158 name
= BLOCKLIST_PREF_BRANCH
"layers.opengl";
160 case nsIGfxInfo::FEATURE_WEBGL_OPENGL
:
161 name
= BLOCKLIST_PREF_BRANCH
"webgl.opengl";
163 case nsIGfxInfo::FEATURE_WEBGL_ANGLE
:
164 name
= BLOCKLIST_PREF_BRANCH
"webgl.angle";
166 case nsIGfxInfo::FEATURE_WEBGL_MSAA
:
167 name
= BLOCKLIST_PREF_BRANCH
"webgl.msaa";
169 case nsIGfxInfo::FEATURE_STAGEFRIGHT
:
170 name
= BLOCKLIST_PREF_BRANCH
"stagefright";
172 case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264
:
173 name
= BLOCKLIST_PREF_BRANCH
"webrtc.hw.acceleration.h264";
175 case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE
:
176 name
= BLOCKLIST_PREF_BRANCH
"webrtc.hw.acceleration.encode";
178 case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE
:
179 name
= BLOCKLIST_PREF_BRANCH
"webrtc.hw.acceleration.decode";
181 case nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION
:
182 name
= BLOCKLIST_PREF_BRANCH
"canvas2d.acceleration";
184 case nsIGfxInfo::FEATURE_DX_INTEROP2
:
185 name
= BLOCKLIST_PREF_BRANCH
"dx.interop2";
187 case nsIGfxInfo::FEATURE_GPU_PROCESS
:
188 name
= BLOCKLIST_PREF_BRANCH
"gpu.process";
190 case nsIGfxInfo::FEATURE_WEBGL2
:
191 name
= BLOCKLIST_PREF_BRANCH
"webgl2";
193 case nsIGfxInfo::FEATURE_ADVANCED_LAYERS
:
194 name
= BLOCKLIST_PREF_BRANCH
"layers.advanced";
196 case nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX
:
197 name
= BLOCKLIST_PREF_BRANCH
"d3d11.keyed.mutex";
199 case nsIGfxInfo::FEATURE_WEBRENDER
:
200 name
= BLOCKLIST_PREF_BRANCH
"webrender";
202 case nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR
:
203 name
= BLOCKLIST_PREF_BRANCH
"webrender.compositor";
205 case nsIGfxInfo::FEATURE_DX_NV12
:
206 name
= BLOCKLIST_PREF_BRANCH
"dx.nv12";
208 case nsIGfxInfo::FEATURE_DX_P010
:
209 name
= BLOCKLIST_PREF_BRANCH
"dx.p010";
211 case nsIGfxInfo::FEATURE_DX_P016
:
212 name
= BLOCKLIST_PREF_BRANCH
"dx.p016";
214 case nsIGfxInfo::FEATURE_VP8_HW_DECODE
:
215 case nsIGfxInfo::FEATURE_VP9_HW_DECODE
:
216 // We don't provide prefs for these features as these are
217 // not handling downloadable blocklist.
219 case nsIGfxInfo::FEATURE_GL_SWIZZLE
:
220 name
= BLOCKLIST_PREF_BRANCH
"gl.swizzle";
222 case nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS
:
223 name
= BLOCKLIST_PREF_BRANCH
"webrender.scissored_cache_clears";
226 MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!");
233 // Returns the value of the pref for the relevant feature in aValue.
234 // If the pref doesn't exist, aValue is not touched, and returns false.
235 static bool GetPrefValueForFeature(int32_t aFeature
, int32_t& aValue
,
236 nsACString
& aFailureId
) {
237 const char* prefname
= GetPrefNameForFeature(aFeature
);
238 if (!prefname
) return false;
240 aValue
= nsIGfxInfo::FEATURE_STATUS_UNKNOWN
;
241 if (!NS_SUCCEEDED(Preferences::GetInt(prefname
, &aValue
))) {
245 nsCString
failureprefname(prefname
);
246 failureprefname
+= ".failureid";
247 nsAutoCString failureValue
;
248 nsresult rv
= Preferences::GetCString(failureprefname
.get(), failureValue
);
249 if (NS_SUCCEEDED(rv
)) {
250 aFailureId
= failureValue
.get();
252 aFailureId
= "FEATURE_FAILURE_BLOCKLIST_PREF";
258 static void SetPrefValueForFeature(int32_t aFeature
, int32_t aValue
,
259 const nsACString
& aFailureId
) {
260 const char* prefname
= GetPrefNameForFeature(aFeature
);
261 if (!prefname
) return;
262 if (XRE_IsParentProcess()) {
263 GfxInfoBase::sFeatureStatus
= nullptr;
266 Preferences::SetInt(prefname
, aValue
);
267 if (!aFailureId
.IsEmpty()) {
268 nsCString
failureprefname(prefname
);
269 failureprefname
+= ".failureid";
270 Preferences::SetCString(failureprefname
.get(), aFailureId
);
274 static void RemovePrefForFeature(int32_t aFeature
) {
275 const char* prefname
= GetPrefNameForFeature(aFeature
);
276 if (!prefname
) return;
278 if (XRE_IsParentProcess()) {
279 GfxInfoBase::sFeatureStatus
= nullptr;
281 Preferences::ClearUser(prefname
);
284 static bool GetPrefValueForDriverVersion(nsCString
& aVersion
) {
286 Preferences::GetCString(SUGGESTED_VERSION_PREF
, aVersion
));
289 static void SetPrefValueForDriverVersion(const nsAString
& aVersion
) {
290 Preferences::SetString(SUGGESTED_VERSION_PREF
, aVersion
);
293 static void RemovePrefForDriverVersion() {
294 Preferences::ClearUser(SUGGESTED_VERSION_PREF
);
297 static OperatingSystem
BlocklistOSToOperatingSystem(const nsAString
& os
) {
298 if (os
.EqualsLiteral("WINNT 6.1"))
299 return OperatingSystem::Windows7
;
300 else if (os
.EqualsLiteral("WINNT 6.2"))
301 return OperatingSystem::Windows8
;
302 else if (os
.EqualsLiteral("WINNT 6.3"))
303 return OperatingSystem::Windows8_1
;
304 else if (os
.EqualsLiteral("WINNT 10.0"))
305 return OperatingSystem::Windows10
;
306 else if (os
.EqualsLiteral("Linux"))
307 return OperatingSystem::Linux
;
308 else if (os
.EqualsLiteral("Darwin 9"))
309 return OperatingSystem::OSX10_5
;
310 else if (os
.EqualsLiteral("Darwin 10"))
311 return OperatingSystem::OSX10_6
;
312 else if (os
.EqualsLiteral("Darwin 11"))
313 return OperatingSystem::OSX10_7
;
314 else if (os
.EqualsLiteral("Darwin 12"))
315 return OperatingSystem::OSX10_8
;
316 else if (os
.EqualsLiteral("Darwin 13"))
317 return OperatingSystem::OSX10_9
;
318 else if (os
.EqualsLiteral("Darwin 14"))
319 return OperatingSystem::OSX10_10
;
320 else if (os
.EqualsLiteral("Darwin 15"))
321 return OperatingSystem::OSX10_11
;
322 else if (os
.EqualsLiteral("Darwin 16"))
323 return OperatingSystem::OSX10_12
;
324 else if (os
.EqualsLiteral("Darwin 17"))
325 return OperatingSystem::OSX10_13
;
326 else if (os
.EqualsLiteral("Darwin 18"))
327 return OperatingSystem::OSX10_14
;
328 else if (os
.EqualsLiteral("Darwin 19"))
329 return OperatingSystem::OSX10_15
;
330 else if (os
.EqualsLiteral("Darwin 20"))
331 return OperatingSystem::OSX10_16
;
332 else if (os
.EqualsLiteral("Android"))
333 return OperatingSystem::Android
;
334 // For historical reasons, "All" in blocklist means "All Windows"
335 else if (os
.EqualsLiteral("All"))
336 return OperatingSystem::Windows
;
338 return OperatingSystem::Unknown
;
341 static GfxDeviceFamily
* BlocklistDevicesToDeviceFamily(
342 nsTArray
<nsCString
>& devices
) {
343 if (devices
.Length() == 0) return nullptr;
345 // For each device, get its device ID, and return a freshly-allocated
346 // GfxDeviceFamily with the contents of that array.
347 GfxDeviceFamily
* deviceIds
= new GfxDeviceFamily
;
349 for (uint32_t i
= 0; i
< devices
.Length(); ++i
) {
350 // We make sure we don't add any "empty" device entries to the array, so
351 // we don't need to check if devices[i] is empty.
352 deviceIds
->Append(NS_ConvertUTF8toUTF16(devices
[i
]));
358 static int32_t BlocklistFeatureToGfxFeature(const nsAString
& aFeature
) {
359 MOZ_ASSERT(!aFeature
.IsEmpty());
360 if (aFeature
.EqualsLiteral("DIRECT2D"))
361 return nsIGfxInfo::FEATURE_DIRECT2D
;
362 else if (aFeature
.EqualsLiteral("DIRECT3D_9_LAYERS"))
363 return nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS
;
364 else if (aFeature
.EqualsLiteral("DIRECT3D_10_LAYERS"))
365 return nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS
;
366 else if (aFeature
.EqualsLiteral("DIRECT3D_10_1_LAYERS"))
367 return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS
;
368 else if (aFeature
.EqualsLiteral("DIRECT3D_11_LAYERS"))
369 return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS
;
370 else if (aFeature
.EqualsLiteral("DIRECT3D_11_ANGLE"))
371 return nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE
;
372 else if (aFeature
.EqualsLiteral("HARDWARE_VIDEO_DECODING"))
373 return nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING
;
374 else if (aFeature
.EqualsLiteral("OPENGL_LAYERS"))
375 return nsIGfxInfo::FEATURE_OPENGL_LAYERS
;
376 else if (aFeature
.EqualsLiteral("WEBGL_OPENGL"))
377 return nsIGfxInfo::FEATURE_WEBGL_OPENGL
;
378 else if (aFeature
.EqualsLiteral("WEBGL_ANGLE"))
379 return nsIGfxInfo::FEATURE_WEBGL_ANGLE
;
380 else if (aFeature
.EqualsLiteral("WEBGL_MSAA"))
381 return nsIGfxInfo::FEATURE_WEBGL_MSAA
;
382 else if (aFeature
.EqualsLiteral("STAGEFRIGHT"))
383 return nsIGfxInfo::FEATURE_STAGEFRIGHT
;
384 else if (aFeature
.EqualsLiteral("WEBRTC_HW_ACCELERATION_ENCODE"))
385 return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE
;
386 else if (aFeature
.EqualsLiteral("WEBRTC_HW_ACCELERATION_DECODE"))
387 return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE
;
388 else if (aFeature
.EqualsLiteral("WEBRTC_HW_ACCELERATION_H264"))
389 return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264
;
390 else if (aFeature
.EqualsLiteral("CANVAS2D_ACCELERATION"))
391 return nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION
;
392 else if (aFeature
.EqualsLiteral("DX_INTEROP2"))
393 return nsIGfxInfo::FEATURE_DX_INTEROP2
;
394 else if (aFeature
.EqualsLiteral("GPU_PROCESS"))
395 return nsIGfxInfo::FEATURE_GPU_PROCESS
;
396 else if (aFeature
.EqualsLiteral("WEBGL2"))
397 return nsIGfxInfo::FEATURE_WEBGL2
;
398 else if (aFeature
.EqualsLiteral("ADVANCED_LAYERS"))
399 return nsIGfxInfo::FEATURE_ADVANCED_LAYERS
;
400 else if (aFeature
.EqualsLiteral("D3D11_KEYED_MUTEX"))
401 return nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX
;
402 else if (aFeature
.EqualsLiteral("WEBRENDER"))
403 return nsIGfxInfo::FEATURE_WEBRENDER
;
404 else if (aFeature
.EqualsLiteral("WEBRENDER_COMPOSITOR"))
405 return nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR
;
406 else if (aFeature
.EqualsLiteral("DX_NV12"))
407 return nsIGfxInfo::FEATURE_DX_NV12
;
408 // We do not support FEATURE_VP8_HW_DECODE and FEATURE_VP9_HW_DECODE
409 // in downloadable blocklist.
410 else if (aFeature
.EqualsLiteral("GL_SWIZZLE"))
411 return nsIGfxInfo::FEATURE_GL_SWIZZLE
;
412 else if (aFeature
.EqualsLiteral("WEBRENDER_SCISSORED_CACHE_CLEARS"))
413 return nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS
;
415 // If we don't recognize the feature, it may be new, and something
416 // this version doesn't understand. So, nothing to do. This is
417 // different from feature not being specified at all, in which case
418 // this method should not get called and we should continue with the
419 // "all features" blocklisting.
423 static int32_t BlocklistFeatureStatusToGfxFeatureStatus(
424 const nsAString
& aStatus
) {
425 if (aStatus
.EqualsLiteral("STATUS_OK"))
426 return nsIGfxInfo::FEATURE_STATUS_OK
;
427 else if (aStatus
.EqualsLiteral("BLOCKED_DRIVER_VERSION"))
428 return nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION
;
429 else if (aStatus
.EqualsLiteral("BLOCKED_DEVICE"))
430 return nsIGfxInfo::FEATURE_BLOCKED_DEVICE
;
431 else if (aStatus
.EqualsLiteral("DISCOURAGED"))
432 return nsIGfxInfo::FEATURE_DISCOURAGED
;
433 else if (aStatus
.EqualsLiteral("BLOCKED_OS_VERSION"))
434 return nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION
;
435 else if (aStatus
.EqualsLiteral("DENIED"))
436 return nsIGfxInfo::FEATURE_DENIED
;
437 else if (aStatus
.EqualsLiteral("ALLOW_QUALIFIED"))
438 return nsIGfxInfo::FEATURE_ALLOW_QUALIFIED
;
439 else if (aStatus
.EqualsLiteral("ALLOW_ALWAYS"))
440 return nsIGfxInfo::FEATURE_ALLOW_ALWAYS
;
442 // Do not allow it to set STATUS_UNKNOWN. Also, we are not
443 // expecting the "mismatch" status showing up here.
445 return nsIGfxInfo::FEATURE_STATUS_OK
;
448 static VersionComparisonOp
BlocklistComparatorToComparisonOp(
449 const nsAString
& op
) {
450 if (op
.EqualsLiteral("LESS_THAN"))
451 return DRIVER_LESS_THAN
;
452 else if (op
.EqualsLiteral("BUILD_ID_LESS_THAN"))
453 return DRIVER_BUILD_ID_LESS_THAN
;
454 else if (op
.EqualsLiteral("LESS_THAN_OR_EQUAL"))
455 return DRIVER_LESS_THAN_OR_EQUAL
;
456 else if (op
.EqualsLiteral("BUILD_ID_LESS_THAN_OR_EQUAL"))
457 return DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL
;
458 else if (op
.EqualsLiteral("GREATER_THAN"))
459 return DRIVER_GREATER_THAN
;
460 else if (op
.EqualsLiteral("GREATER_THAN_OR_EQUAL"))
461 return DRIVER_GREATER_THAN_OR_EQUAL
;
462 else if (op
.EqualsLiteral("EQUAL"))
464 else if (op
.EqualsLiteral("NOT_EQUAL"))
465 return DRIVER_NOT_EQUAL
;
466 else if (op
.EqualsLiteral("BETWEEN_EXCLUSIVE"))
467 return DRIVER_BETWEEN_EXCLUSIVE
;
468 else if (op
.EqualsLiteral("BETWEEN_INCLUSIVE"))
469 return DRIVER_BETWEEN_INCLUSIVE
;
470 else if (op
.EqualsLiteral("BETWEEN_INCLUSIVE_START"))
471 return DRIVER_BETWEEN_INCLUSIVE_START
;
473 return DRIVER_COMPARISON_IGNORED
;
477 Deserialize Blocklist entries from string.
479 os:WINNT 6.0\tvendor:0x8086\tdevices:0x2582,0x2782\tfeature:DIRECT3D_10_LAYERS\tfeatureStatus:BLOCKED_DRIVER_VERSION\tdriverVersion:8.52.322.2202\tdriverVersionComparator:LESS_THAN_OR_EQUAL
481 static bool BlocklistEntryToDriverInfo(const nsACString
& aBlocklistEntry
,
482 GfxDriverInfo
& aDriverInfo
) {
483 // If we get an application version to be zero, something is not working
484 // and we are not going to bother checking the blocklist versions.
485 // See TestGfxWidgets.cpp for how version comparison works.
486 // <versionRange minVersion="42.0a1" maxVersion="45.0"></versionRange>
487 static mozilla::Version
zeroV("0");
488 static mozilla::Version
appV(GfxInfoBase::GetApplicationVersion().get());
490 gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false))
491 << "Invalid application version "
492 << GfxInfoBase::GetApplicationVersion().get();
495 aDriverInfo
.mRuleId
= "FEATURE_FAILURE_DL_BLOCKLIST_NO_ID"_ns
;
497 for (const auto& keyValue
: aBlocklistEntry
.Split('\t')) {
498 nsTArray
<nsCString
> splitted
;
499 ParseString(keyValue
, ':', splitted
);
500 if (splitted
.Length() != 2) {
501 // If we don't recognize the input data, we do not want to proceed.
502 gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
503 << "Unrecognized data " << nsCString(keyValue
).get();
506 const nsCString
& key
= splitted
[0];
507 const nsCString
& value
= splitted
[1];
508 NS_ConvertUTF8toUTF16
dataValue(value
);
510 if (value
.Length() == 0) {
511 // Safety check for empty values.
512 gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
513 << "Empty value for " << key
.get();
517 if (key
.EqualsLiteral("blockID")) {
518 nsCString blockIdStr
= "FEATURE_FAILURE_DL_BLOCKLIST_"_ns
+ value
;
519 aDriverInfo
.mRuleId
= blockIdStr
.get();
520 } else if (key
.EqualsLiteral("os")) {
521 aDriverInfo
.mOperatingSystem
= BlocklistOSToOperatingSystem(dataValue
);
522 } else if (key
.EqualsLiteral("osversion")) {
523 aDriverInfo
.mOperatingSystemVersion
= strtoul(value
.get(), nullptr, 10);
524 } else if (key
.EqualsLiteral("desktopEnvironment")) {
525 aDriverInfo
.mDesktopEnvironment
= dataValue
;
526 } else if (key
.EqualsLiteral("windowProtocol")) {
527 aDriverInfo
.mWindowProtocol
= dataValue
;
528 } else if (key
.EqualsLiteral("vendor")) {
529 aDriverInfo
.mAdapterVendor
= dataValue
;
530 } else if (key
.EqualsLiteral("driverVendor")) {
531 aDriverInfo
.mDriverVendor
= dataValue
;
532 } else if (key
.EqualsLiteral("feature")) {
533 aDriverInfo
.mFeature
= BlocklistFeatureToGfxFeature(dataValue
);
534 if (aDriverInfo
.mFeature
< 0) {
535 // If we don't recognize the feature, we do not want to proceed.
536 gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
537 << "Unrecognized feature " << value
.get();
540 } else if (key
.EqualsLiteral("featureStatus")) {
541 aDriverInfo
.mFeatureStatus
=
542 BlocklistFeatureStatusToGfxFeatureStatus(dataValue
);
543 } else if (key
.EqualsLiteral("driverVersion")) {
545 if (ParseDriverVersion(dataValue
, &version
))
546 aDriverInfo
.mDriverVersion
= version
;
547 } else if (key
.EqualsLiteral("driverVersionMax")) {
549 if (ParseDriverVersion(dataValue
, &version
))
550 aDriverInfo
.mDriverVersionMax
= version
;
551 } else if (key
.EqualsLiteral("driverVersionComparator")) {
552 aDriverInfo
.mComparisonOp
= BlocklistComparatorToComparisonOp(dataValue
);
553 } else if (key
.EqualsLiteral("model")) {
554 aDriverInfo
.mModel
= dataValue
;
555 } else if (key
.EqualsLiteral("product")) {
556 aDriverInfo
.mProduct
= dataValue
;
557 } else if (key
.EqualsLiteral("manufacturer")) {
558 aDriverInfo
.mManufacturer
= dataValue
;
559 } else if (key
.EqualsLiteral("hardware")) {
560 aDriverInfo
.mHardware
= dataValue
;
561 } else if (key
.EqualsLiteral("versionRange")) {
562 nsTArray
<nsCString
> versionRange
;
563 ParseString(value
, ',', versionRange
);
564 if (versionRange
.Length() != 2) {
565 gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
566 << "Unrecognized versionRange " << value
.get();
569 const nsCString
& minValue
= versionRange
[0];
570 const nsCString
& maxValue
= versionRange
[1];
572 mozilla::Version
minV(minValue
.get());
573 mozilla::Version
maxV(maxValue
.get());
575 if (minV
> zeroV
&& !(appV
>= minV
)) {
576 // The version of the application is less than the minimal version
577 // this blocklist entry applies to, so we can just ignore it by
578 // returning false and letting the caller deal with it.
581 if (maxV
> zeroV
&& !(appV
<= maxV
)) {
582 // The version of the application is more than the maximal version
583 // this blocklist entry applies to, so we can just ignore it by
584 // returning false and letting the caller deal with it.
587 } else if (key
.EqualsLiteral("devices")) {
588 nsTArray
<nsCString
> devices
;
589 ParseString(value
, ',', devices
);
590 GfxDeviceFamily
* deviceIds
= BlocklistDevicesToDeviceFamily(devices
);
592 // Get GfxDriverInfo to adopt the devices array we created.
593 aDriverInfo
.mDeleteDevices
= true;
594 aDriverInfo
.mDevices
= deviceIds
;
597 // We explicitly ignore unknown elements.
603 static void BlocklistEntriesToDriverInfo(
604 const nsTSubstringSplitter
<char>& aBlocklistEntries
,
605 nsTArray
<GfxDriverInfo
>& aDriverInfo
) {
608 std::distance(aBlocklistEntries
.begin(), aBlocklistEntries
.end());
609 aDriverInfo
.SetLength(n
);
611 for (uint32_t i
= 0; i
< n
; ++i
) {
612 const nsDependentCSubstring
& blocklistEntry
= aBlocklistEntries
.Get(i
);
614 if (BlocklistEntryToDriverInfo(blocklistEntry
, di
)) {
616 // Prevent di falling out of scope from destroying the devices.
617 di
.mDeleteDevices
= false;
623 GfxInfoBase::Observe(nsISupports
* aSubject
, const char* aTopic
,
624 const char16_t
* aData
) {
625 if (strcmp(aTopic
, "blocklist-data-gfxItems") == 0) {
626 nsTArray
<GfxDriverInfo
> driverInfo
;
627 NS_ConvertUTF16toUTF8
utf8Data(aData
);
628 BlocklistEntriesToDriverInfo(utf8Data
.Split('\n'), driverInfo
);
629 EvaluateDownloadedBlocklist(driverInfo
);
635 GfxInfoBase::GfxInfoBase() : mScreenPixels(INT64_MAX
), mMutex("GfxInfoBase") {}
637 GfxInfoBase::~GfxInfoBase() = default;
639 nsresult
GfxInfoBase::Init() {
640 InitGfxDriverInfoShutdownObserver();
642 nsCOMPtr
<nsIObserverService
> os
= mozilla::services::GetObserverService();
644 os
->AddObserver(this, "blocklist-data-gfxItems", true);
650 void GfxInfoBase::GetData() {
651 if (mScreenPixels
!= INT64_MAX
) {
652 // Already initialized.
656 nsCOMPtr
<nsIScreenManager
> manager
=
657 do_GetService("@mozilla.org/gfx/screenmanager;1");
659 MOZ_ASSERT_UNREACHABLE("failed to get nsIScreenManager");
663 manager
->GetTotalScreenPixels(&mScreenPixels
);
667 GfxInfoBase::GetFeatureStatus(int32_t aFeature
, nsACString
& aFailureId
,
669 // Ignore the gfx.blocklist.all pref on release and beta.
670 #if defined(RELEASE_OR_BETA)
671 int32_t blocklistAll
= 0;
673 int32_t blocklistAll
= StaticPrefs::gfx_blocklist_all_AtStartup();
675 if (blocklistAll
> 0) {
676 gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false))
677 << "Forcing blocklisting all features";
678 *aStatus
= FEATURE_BLOCKED_DEVICE
;
679 aFailureId
= "FEATURE_FAILURE_BLOCK_ALL";
681 } else if (blocklistAll
< 0) {
682 gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false))
683 << "Ignoring any feature blocklisting.";
684 *aStatus
= FEATURE_STATUS_OK
;
688 if (GetPrefValueForFeature(aFeature
, *aStatus
, aFailureId
)) {
692 if (XRE_IsContentProcess() || XRE_IsGPUProcess()) {
693 // Use the cached data received from the parent process.
694 MOZ_ASSERT(sFeatureStatus
);
695 bool success
= false;
696 for (const auto& fs
: *sFeatureStatus
) {
697 if (fs
.feature() == aFeature
) {
698 aFailureId
= fs
.failureId();
699 *aStatus
= fs
.status();
704 return success
? NS_OK
: NS_ERROR_FAILURE
;
708 nsTArray
<GfxDriverInfo
> driverInfo
;
710 GetFeatureStatusImpl(aFeature
, aStatus
, version
, driverInfo
, aFailureId
);
714 nsTArray
<gfx::GfxInfoFeatureStatus
> GfxInfoBase::GetAllFeatures() {
715 MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
716 if (!sFeatureStatus
) {
717 InitFeatureStatus(new nsTArray
<gfx::GfxInfoFeatureStatus
>());
718 for (int32_t i
= 1; i
<= nsIGfxInfo::FEATURE_MAX_VALUE
; ++i
) {
720 nsAutoCString failureId
;
721 GetFeatureStatus(i
, failureId
, &status
);
722 gfx::GfxInfoFeatureStatus gfxFeatureStatus
;
723 gfxFeatureStatus
.feature() = i
;
724 gfxFeatureStatus
.status() = status
;
725 gfxFeatureStatus
.failureId() = failureId
;
726 sFeatureStatus
->AppendElement(gfxFeatureStatus
);
730 nsTArray
<gfx::GfxInfoFeatureStatus
> features
;
731 for (const auto& status
: *sFeatureStatus
) {
732 gfx::GfxInfoFeatureStatus copy
= status
;
733 features
.AppendElement(copy
);
738 inline bool MatchingAllowStatus(int32_t aStatus
) {
740 case nsIGfxInfo::FEATURE_ALLOW_ALWAYS
:
741 case nsIGfxInfo::FEATURE_ALLOW_QUALIFIED
:
748 // Matching OS go somewhat beyond the simple equality check because of the
749 // "All Windows" and "All OS X" variations.
751 // aBlockedOS is describing the system(s) we are trying to block.
752 // aSystemOS is describing the system we are running on.
754 // aSystemOS should not be "Windows" or "OSX" - it should be set to
755 // a particular version instead.
756 // However, it is valid for aBlockedOS to be one of those generic values,
757 // as we could be blocking all of the versions.
758 inline bool MatchingOperatingSystems(OperatingSystem aBlockedOS
,
759 OperatingSystem aSystemOS
,
760 uint32_t aSystemOSBuild
) {
761 MOZ_ASSERT(aSystemOS
!= OperatingSystem::Windows
&&
762 aSystemOS
!= OperatingSystem::OSX
);
764 // If the block entry OS is unknown, it doesn't match
765 if (aBlockedOS
== OperatingSystem::Unknown
) {
770 if (aBlockedOS
== OperatingSystem::Windows
) {
771 // We do want even "unknown" aSystemOS to fall under "all windows"
775 constexpr uint32_t kMinWin10BuildNumber
= 18362;
776 if (aBlockedOS
== OperatingSystem::RecentWindows10
&&
777 aSystemOS
== OperatingSystem::Windows10
) {
778 // For allowlist purposes, we sometimes want to restrict to only recent
779 // versions of Windows 10. This is a bit of a kludge but easier than adding
780 // complicated blocklist infrastructure for build ID comparisons like driver
782 return aSystemOSBuild
>= kMinWin10BuildNumber
;
785 if (aBlockedOS
== OperatingSystem::NotRecentWindows10
) {
786 if (aSystemOS
== OperatingSystem::Windows10
) {
787 return aSystemOSBuild
< kMinWin10BuildNumber
;
794 #if defined(XP_MACOSX)
795 if (aBlockedOS
== OperatingSystem::OSX
) {
796 // We do want even "unknown" aSystemOS to fall under "all OS X"
801 return aSystemOS
== aBlockedOS
;
804 inline bool MatchingBattery(BatteryStatus aBatteryStatus
, bool aHasBattery
) {
805 switch (aBatteryStatus
) {
806 case BatteryStatus::All
:
808 case BatteryStatus::None
:
810 case BatteryStatus::Present
:
814 MOZ_ASSERT_UNREACHABLE("bad battery status");
818 inline bool MatchingScreenSize(ScreenSizeStatus aScreenStatus
,
819 int64_t aScreenPixels
) {
820 constexpr int64_t kMaxSmallPixels
= 2304000; // 1920x1200
821 constexpr int64_t kMaxMediumPixels
= 4953600; // 3440x1440
823 switch (aScreenStatus
) {
824 case ScreenSizeStatus::All
:
826 case ScreenSizeStatus::Small
:
827 return aScreenPixels
<= kMaxSmallPixels
;
828 case ScreenSizeStatus::SmallAndMedium
:
829 return aScreenPixels
<= kMaxMediumPixels
;
830 case ScreenSizeStatus::Medium
:
831 return aScreenPixels
> kMaxSmallPixels
&&
832 aScreenPixels
<= kMaxMediumPixels
;
833 case ScreenSizeStatus::MediumAndLarge
:
834 return aScreenPixels
> kMaxSmallPixels
;
835 case ScreenSizeStatus::Large
:
836 return aScreenPixels
> kMaxMediumPixels
;
839 MOZ_ASSERT_UNREACHABLE("bad screen status");
843 int32_t GfxInfoBase::FindBlocklistedDeviceInList(
844 const nsTArray
<GfxDriverInfo
>& info
, nsAString
& aSuggestedVersion
,
845 int32_t aFeature
, nsACString
& aFailureId
, OperatingSystem os
,
847 int32_t status
= nsIGfxInfo::FEATURE_STATUS_UNKNOWN
;
849 // Some properties are not available on all platforms.
850 nsAutoString desktopEnvironment
;
851 nsresult rv
= GetDesktopEnvironment(desktopEnvironment
);
852 if (NS_FAILED(rv
) && rv
!= NS_ERROR_NOT_IMPLEMENTED
) {
856 nsAutoString windowProtocol
;
857 rv
= GetWindowProtocol(windowProtocol
);
858 if (NS_FAILED(rv
) && rv
!= NS_ERROR_NOT_IMPLEMENTED
) {
862 bool hasBattery
= false;
863 rv
= GetHasBattery(&hasBattery
);
864 if (NS_FAILED(rv
) && rv
!= NS_ERROR_NOT_IMPLEMENTED
) {
868 uint32_t osBuild
= OperatingSystemBuild();
870 // Get the adapters once then reuse below
871 nsAutoString adapterVendorID
[2];
872 nsAutoString adapterDeviceID
[2];
873 nsAutoString adapterDriverVendor
[2];
874 nsAutoString adapterDriverVersionString
[2];
875 bool adapterInfoFailed
[2];
877 adapterInfoFailed
[0] =
878 (NS_FAILED(GetAdapterVendorID(adapterVendorID
[0])) ||
879 NS_FAILED(GetAdapterDeviceID(adapterDeviceID
[0])) ||
880 NS_FAILED(GetAdapterDriverVendor(adapterDriverVendor
[0])) ||
881 NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString
[0])));
882 adapterInfoFailed
[1] =
883 (NS_FAILED(GetAdapterVendorID2(adapterVendorID
[1])) ||
884 NS_FAILED(GetAdapterDeviceID2(adapterDeviceID
[1])) ||
885 NS_FAILED(GetAdapterDriverVendor2(adapterDriverVendor
[1])) ||
886 NS_FAILED(GetAdapterDriverVersion2(adapterDriverVersionString
[1])));
887 // No point in going on if we don't have adapter info
888 if (adapterInfoFailed
[0] && adapterInfoFailed
[1]) {
892 #if defined(XP_WIN) || defined(ANDROID) || defined(MOZ_X11)
893 uint64_t driverVersion
[2] = {0, 0};
894 if (!adapterInfoFailed
[0]) {
895 ParseDriverVersion(adapterDriverVersionString
[0], &driverVersion
[0]);
897 if (!adapterInfoFailed
[1]) {
898 ParseDriverVersion(adapterDriverVersionString
[1], &driverVersion
[1]);
903 for (; i
< info
.Length(); i
++) {
904 // If the status is FEATURE_ALLOW_*, then it is for the allowlist, not
905 // blocklisting. Only consider entries for our search mode.
906 if (MatchingAllowStatus(info
[i
].mFeatureStatus
) != aForAllowing
) {
910 // If we don't have the info for this GPU, no need to check further.
911 // It is unclear that we would ever have a mixture of 1st and 2nd
912 // GPU, but leaving the code in for that possibility for now.
913 // (Actually, currently mGpu2 will never be true, so this can
914 // be optimized out.)
915 uint32_t infoIndex
= info
[i
].mGpu2
? 1 : 0;
916 if (adapterInfoFailed
[infoIndex
]) {
920 // Do the operating system check first, no point in getting the driver
921 // info if we won't need to use it.
922 if (!MatchingOperatingSystems(info
[i
].mOperatingSystem
, os
, osBuild
)) {
926 if (info
[i
].mOperatingSystemVersion
&&
927 info
[i
].mOperatingSystemVersion
!= OperatingSystemVersion()) {
931 if (!MatchingBattery(info
[i
].mBattery
, hasBattery
)) {
935 if (!MatchingScreenSize(info
[i
].mScreen
, mScreenPixels
)) {
939 if (!DoesDesktopEnvironmentMatch(info
[i
].mDesktopEnvironment
,
940 desktopEnvironment
)) {
944 if (!DoesWindowProtocolMatch(info
[i
].mWindowProtocol
, windowProtocol
)) {
948 if (!DoesVendorMatch(info
[i
].mAdapterVendor
, adapterVendorID
[infoIndex
])) {
952 if (!DoesDriverVendorMatch(info
[i
].mDriverVendor
,
953 adapterDriverVendor
[infoIndex
])) {
957 if (info
[i
].mDevices
&& !info
[i
].mDevices
->IsEmpty()) {
958 nsresult rv
= info
[i
].mDevices
->Contains(adapterDeviceID
[infoIndex
]);
959 if (rv
== NS_ERROR_NOT_AVAILABLE
) {
964 // Failed to search, allowlist should not match, blocklist should match
965 // for safety reasons
975 if (!info
[i
].mHardware
.IsEmpty() && !info
[i
].mHardware
.Equals(Hardware())) {
978 if (!info
[i
].mModel
.IsEmpty() && !info
[i
].mModel
.Equals(Model())) {
981 if (!info
[i
].mProduct
.IsEmpty() && !info
[i
].mProduct
.Equals(Product())) {
984 if (!info
[i
].mManufacturer
.IsEmpty() &&
985 !info
[i
].mManufacturer
.Equals(Manufacturer())) {
989 #if defined(XP_WIN) || defined(ANDROID) || defined(MOZ_X11)
990 switch (info
[i
].mComparisonOp
) {
991 case DRIVER_LESS_THAN
:
992 match
= driverVersion
[infoIndex
] < info
[i
].mDriverVersion
;
994 case DRIVER_BUILD_ID_LESS_THAN
:
995 match
= (driverVersion
[infoIndex
] & 0xFFFF) < info
[i
].mDriverVersion
;
997 case DRIVER_LESS_THAN_OR_EQUAL
:
998 match
= driverVersion
[infoIndex
] <= info
[i
].mDriverVersion
;
1000 case DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL
:
1001 match
= (driverVersion
[infoIndex
] & 0xFFFF) <= info
[i
].mDriverVersion
;
1003 case DRIVER_GREATER_THAN
:
1004 match
= driverVersion
[infoIndex
] > info
[i
].mDriverVersion
;
1006 case DRIVER_GREATER_THAN_OR_EQUAL
:
1007 match
= driverVersion
[infoIndex
] >= info
[i
].mDriverVersion
;
1010 match
= driverVersion
[infoIndex
] == info
[i
].mDriverVersion
;
1012 case DRIVER_NOT_EQUAL
:
1013 match
= driverVersion
[infoIndex
] != info
[i
].mDriverVersion
;
1015 case DRIVER_BETWEEN_EXCLUSIVE
:
1016 match
= driverVersion
[infoIndex
] > info
[i
].mDriverVersion
&&
1017 driverVersion
[infoIndex
] < info
[i
].mDriverVersionMax
;
1019 case DRIVER_BETWEEN_INCLUSIVE
:
1020 match
= driverVersion
[infoIndex
] >= info
[i
].mDriverVersion
&&
1021 driverVersion
[infoIndex
] <= info
[i
].mDriverVersionMax
;
1023 case DRIVER_BETWEEN_INCLUSIVE_START
:
1024 match
= driverVersion
[infoIndex
] >= info
[i
].mDriverVersion
&&
1025 driverVersion
[infoIndex
] < info
[i
].mDriverVersionMax
;
1027 case DRIVER_COMPARISON_IGNORED
:
1028 // We don't have a comparison op, so we match everything.
1032 NS_WARNING("Bogus op in GfxDriverInfo");
1036 // We don't care what driver version it was. We only check OS version and if
1037 // the device matches.
1041 if (match
|| info
[i
].mDriverVersion
== GfxDriverInfo::allDriverVersions
) {
1042 if (info
[i
].mFeature
== GfxDriverInfo::allFeatures
||
1043 info
[i
].mFeature
== aFeature
) {
1044 status
= info
[i
].mFeatureStatus
;
1045 if (!info
[i
].mRuleId
.IsEmpty()) {
1046 aFailureId
= info
[i
].mRuleId
.get();
1048 aFailureId
= "FEATURE_FAILURE_DL_BLOCKLIST_NO_ID";
1056 // As a very special case, we block D2D on machines with an NVidia 310M GPU
1057 // as either the primary or secondary adapter. D2D is also blocked when the
1058 // NV 310M is the primary adapter (using the standard blocklisting mechanism).
1059 // If the primary GPU already matched something in the blocklist then we
1060 // ignore this special rule. See bug 1008759.
1061 if (status
== nsIGfxInfo::FEATURE_STATUS_UNKNOWN
&&
1062 (aFeature
== nsIGfxInfo::FEATURE_DIRECT2D
)) {
1063 if (!adapterInfoFailed
[1]) {
1064 nsAString
& nvVendorID
=
1065 (nsAString
&)GfxDriverInfo::GetDeviceVendor(DeviceVendor::NVIDIA
);
1066 const nsString nv310mDeviceId
= u
"0x0A70"_ns
;
1067 if (nvVendorID
.Equals(adapterVendorID
[1],
1068 nsCaseInsensitiveStringComparator
) &&
1069 nv310mDeviceId
.Equals(adapterDeviceID
[1],
1070 nsCaseInsensitiveStringComparator
)) {
1071 status
= nsIGfxInfo::FEATURE_BLOCKED_DEVICE
;
1072 aFailureId
= "FEATURE_FAILURE_D2D_NV310M_BLOCK";
1077 // Depends on Windows driver versioning. We don't pass a GfxDriverInfo object
1078 // back to the Windows handler, so we must handle this here.
1079 if (status
== FEATURE_BLOCKED_DRIVER_VERSION
) {
1080 if (info
[i
].mSuggestedVersion
) {
1081 aSuggestedVersion
.AppendPrintf("%s", info
[i
].mSuggestedVersion
);
1082 } else if (info
[i
].mComparisonOp
== DRIVER_LESS_THAN
&&
1083 info
[i
].mDriverVersion
!= GfxDriverInfo::allDriverVersions
) {
1084 aSuggestedVersion
.AppendPrintf(
1085 "%lld.%lld.%lld.%lld",
1086 (info
[i
].mDriverVersion
& 0xffff000000000000) >> 48,
1087 (info
[i
].mDriverVersion
& 0x0000ffff00000000) >> 32,
1088 (info
[i
].mDriverVersion
& 0x00000000ffff0000) >> 16,
1089 (info
[i
].mDriverVersion
& 0x000000000000ffff));
1097 void GfxInfoBase::SetFeatureStatus(nsTArray
<gfx::GfxInfoFeatureStatus
>&& aFS
) {
1098 MOZ_ASSERT(!sFeatureStatus
);
1099 InitFeatureStatus(new nsTArray
<gfx::GfxInfoFeatureStatus
>(std::move(aFS
)));
1102 bool GfxInfoBase::DoesDesktopEnvironmentMatch(
1103 const nsAString
& aBlocklistDesktop
, const nsAString
& aDesktopEnv
) {
1104 return aBlocklistDesktop
.Equals(aDesktopEnv
,
1105 nsCaseInsensitiveStringComparator
) ||
1106 aBlocklistDesktop
.Equals(
1107 GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::All
),
1108 nsCaseInsensitiveStringComparator
);
1111 bool GfxInfoBase::DoesWindowProtocolMatch(
1112 const nsAString
& aBlocklistWindowProtocol
,
1113 const nsAString
& aWindowProtocol
) {
1114 return aBlocklistWindowProtocol
.Equals(aWindowProtocol
,
1115 nsCaseInsensitiveStringComparator
) ||
1116 aBlocklistWindowProtocol
.Equals(
1117 GfxDriverInfo::GetWindowProtocol(WindowProtocol::All
),
1118 nsCaseInsensitiveStringComparator
);
1121 bool GfxInfoBase::DoesVendorMatch(const nsAString
& aBlocklistVendor
,
1122 const nsAString
& aAdapterVendor
) {
1123 return aBlocklistVendor
.Equals(aAdapterVendor
,
1124 nsCaseInsensitiveStringComparator
) ||
1125 aBlocklistVendor
.Equals(
1126 GfxDriverInfo::GetDeviceVendor(DeviceVendor::All
),
1127 nsCaseInsensitiveStringComparator
);
1130 bool GfxInfoBase::DoesDriverVendorMatch(const nsAString
& aBlocklistVendor
,
1131 const nsAString
& aDriverVendor
) {
1132 return aBlocklistVendor
.Equals(aDriverVendor
,
1133 nsCaseInsensitiveStringComparator
) ||
1134 aBlocklistVendor
.Equals(
1135 GfxDriverInfo::GetDriverVendor(DriverVendor::All
),
1136 nsCaseInsensitiveStringComparator
);
1139 bool GfxInfoBase::IsFeatureAllowlisted(int32_t aFeature
) const {
1140 return aFeature
== nsIGfxInfo::FEATURE_WEBRENDER
;
1143 nsresult
GfxInfoBase::GetFeatureStatusImpl(
1144 int32_t aFeature
, int32_t* aStatus
, nsAString
& aSuggestedVersion
,
1145 const nsTArray
<GfxDriverInfo
>& aDriverInfo
, nsACString
& aFailureId
,
1146 OperatingSystem
* aOS
/* = nullptr */) {
1147 if (aFeature
<= 0) {
1148 gfxWarning() << "Invalid feature <= 0";
1152 if (*aStatus
!= nsIGfxInfo::FEATURE_STATUS_UNKNOWN
) {
1153 // Terminate now with the status determined by the derived type (OS-specific
1158 if (sShutdownOccurred
) {
1159 // This is futile; we've already commenced shutdown and our blocklists have
1160 // been deleted. We may want to look into resurrecting the blocklist instead
1161 // but for now, just don't even go there.
1165 // Ensure any additional initialization required is complete.
1168 // If an operating system was provided by the derived GetFeatureStatusImpl,
1169 // grab it here. Otherwise, the OS is unknown.
1170 OperatingSystem os
= (aOS
? *aOS
: OperatingSystem::Unknown
);
1172 nsAutoString adapterVendorID
;
1173 nsAutoString adapterDeviceID
;
1174 nsAutoString adapterDriverVersionString
;
1175 if (NS_FAILED(GetAdapterVendorID(adapterVendorID
)) ||
1176 NS_FAILED(GetAdapterDeviceID(adapterDeviceID
)) ||
1177 NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString
))) {
1178 aFailureId
= "FEATURE_FAILURE_CANT_RESOLVE_ADAPTER";
1179 *aStatus
= FEATURE_BLOCKED_DEVICE
;
1183 // Check if the device is blocked from the downloaded blocklist. If not, check
1184 // the static list after that. This order is used so that we can later escape
1185 // out of static blocks (i.e. if we were wrong or something was patched, we
1186 // can back out our static block without doing a release).
1188 if (aDriverInfo
.Length()) {
1190 FindBlocklistedDeviceInList(aDriverInfo
, aSuggestedVersion
, aFeature
,
1191 aFailureId
, os
, /* aForAllowing */ false);
1194 sDriverInfo
= new nsTArray
<GfxDriverInfo
>();
1196 status
= FindBlocklistedDeviceInList(GetGfxDriverInfo(), aSuggestedVersion
,
1197 aFeature
, aFailureId
, os
,
1198 /* aForAllowing */ false);
1201 if (status
== nsIGfxInfo::FEATURE_STATUS_UNKNOWN
) {
1202 if (IsFeatureAllowlisted(aFeature
)) {
1203 // This feature is actually using the allowlist; that means after we pass
1204 // the blocklist to prevent us explicitly from getting the feature, we now
1205 // need to check the allowlist to ensure we are allowed to get it in the
1207 if (aDriverInfo
.Length()) {
1208 status
= FindBlocklistedDeviceInList(aDriverInfo
, aSuggestedVersion
,
1209 aFeature
, aFailureId
, os
,
1210 /* aForAllowing */ true);
1212 status
= FindBlocklistedDeviceInList(
1213 GetGfxDriverInfo(), aSuggestedVersion
, aFeature
, aFailureId
, os
,
1214 /* aForAllowing */ true);
1217 if (status
== nsIGfxInfo::FEATURE_STATUS_UNKNOWN
) {
1218 status
= nsIGfxInfo::FEATURE_DENIED
;
1221 // It's now done being processed. It's safe to set the status to
1223 status
= nsIGfxInfo::FEATURE_STATUS_OK
;
1232 GfxInfoBase::GetFeatureSuggestedDriverVersion(int32_t aFeature
,
1233 nsAString
& aVersion
) {
1235 if (GetPrefValueForDriverVersion(version
)) {
1236 aVersion
= NS_ConvertASCIItoUTF16(version
);
1241 nsCString discardFailureId
;
1242 nsTArray
<GfxDriverInfo
> driverInfo
;
1243 return GetFeatureStatusImpl(aFeature
, &status
, aVersion
, driverInfo
,
1247 void GfxInfoBase::EvaluateDownloadedBlocklist(
1248 nsTArray
<GfxDriverInfo
>& aDriverInfo
) {
1249 int32_t features
[] = {nsIGfxInfo::FEATURE_DIRECT2D
,
1250 nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS
,
1251 nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS
,
1252 nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS
,
1253 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS
,
1254 nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE
,
1255 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING
,
1256 nsIGfxInfo::FEATURE_OPENGL_LAYERS
,
1257 nsIGfxInfo::FEATURE_WEBGL_OPENGL
,
1258 nsIGfxInfo::FEATURE_WEBGL_ANGLE
,
1259 nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE
,
1260 nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE
,
1261 nsIGfxInfo::FEATURE_WEBGL_MSAA
,
1262 nsIGfxInfo::FEATURE_STAGEFRIGHT
,
1263 nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264
,
1264 nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION
,
1265 nsIGfxInfo::FEATURE_VP8_HW_DECODE
,
1266 nsIGfxInfo::FEATURE_VP9_HW_DECODE
,
1267 nsIGfxInfo::FEATURE_DX_INTEROP2
,
1268 nsIGfxInfo::FEATURE_GPU_PROCESS
,
1269 nsIGfxInfo::FEATURE_WEBGL2
,
1270 nsIGfxInfo::FEATURE_ADVANCED_LAYERS
,
1271 nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX
,
1272 nsIGfxInfo::FEATURE_WEBRENDER
,
1273 nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR
,
1274 nsIGfxInfo::FEATURE_DX_NV12
,
1275 nsIGfxInfo::FEATURE_DX_P010
,
1276 nsIGfxInfo::FEATURE_DX_P016
,
1277 nsIGfxInfo::FEATURE_GL_SWIZZLE
,
1280 // For every feature we know about, we evaluate whether this blocklist has a
1281 // non-STATUS_OK status. If it does, we set the pref we evaluate in
1282 // GetFeatureStatus above, so we don't need to hold on to this blocklist
1283 // anywhere permanent.
1285 while (features
[i
]) {
1287 nsCString failureId
;
1288 nsAutoString suggestedVersion
;
1289 if (NS_SUCCEEDED(GetFeatureStatusImpl(
1290 features
[i
], &status
, suggestedVersion
, aDriverInfo
, failureId
))) {
1293 case nsIGfxInfo::FEATURE_STATUS_OK
:
1294 RemovePrefForFeature(features
[i
]);
1297 case nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION
:
1298 if (!suggestedVersion
.IsEmpty()) {
1299 SetPrefValueForDriverVersion(suggestedVersion
);
1301 RemovePrefForDriverVersion();
1305 case nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION
:
1306 case nsIGfxInfo::FEATURE_BLOCKED_DEVICE
:
1307 case nsIGfxInfo::FEATURE_DISCOURAGED
:
1308 case nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION
:
1309 SetPrefValueForFeature(features
[i
], status
, failureId
);
1318 NS_IMETHODIMP_(void)
1319 GfxInfoBase::LogFailure(const nsACString
& failure
) {
1320 // gfxCriticalError has a mutex lock of its own, so we may not actually
1321 // need this lock. ::GetFailures() accesses the data but the LogForwarder
1322 // will not return the copy of the logs unless it can get the same lock
1323 // that gfxCriticalError uses. Still, that is so much of an implementation
1324 // detail that it's nicer to just add an extra lock here and in
1326 MutexAutoLock
lock(mMutex
);
1328 // By default, gfxCriticalError asserts; make it not assert in this case.
1329 gfxCriticalError(CriticalLog::DefaultOptions(false))
1330 << "(LF) " << failure
.BeginReading();
1333 NS_IMETHODIMP
GfxInfoBase::GetFailures(nsTArray
<int32_t>& indices
,
1334 nsTArray
<nsCString
>& failures
) {
1335 MutexAutoLock
lock(mMutex
);
1337 LogForwarder
* logForwarder
= Factory::GetLogForwarder();
1338 if (!logForwarder
) {
1339 return NS_ERROR_UNEXPECTED
;
1342 // There are two string copies in this method, starting with this one. We are
1343 // assuming this is not a big deal, as the size of the array should be small
1344 // and the strings in it should be small as well (the error messages in the
1345 // code.) The second copy happens with the AppendElement() calls.
1346 // Technically, we don't need the mutex lock after the StringVectorCopy()
1348 LoggingRecord loggedStrings
= logForwarder
->LoggingRecordCopy();
1349 LoggingRecord::const_iterator it
;
1350 for (it
= loggedStrings
.begin(); it
!= loggedStrings
.end(); ++it
) {
1351 failures
.AppendElement(
1352 nsDependentCSubstring(Get
<1>(*it
).c_str(), Get
<1>(*it
).size()));
1353 indices
.AppendElement(Get
<0>(*it
));
1359 nsTArray
<GfxInfoCollectorBase
*>* sCollectors
;
1361 static void InitCollectors() {
1362 if (!sCollectors
) sCollectors
= new nsTArray
<GfxInfoCollectorBase
*>;
1365 nsresult
GfxInfoBase::GetInfo(JSContext
* aCx
,
1366 JS::MutableHandle
<JS::Value
> aResult
) {
1368 InfoObject
obj(aCx
);
1370 for (uint32_t i
= 0; i
< sCollectors
->Length(); i
++) {
1371 (*sCollectors
)[i
]->GetInfo(obj
);
1374 // Some example property definitions
1375 // obj.DefineProperty("wordCacheSize", gfxTextRunWordCache::Count());
1376 // obj.DefineProperty("renderer", mRendererIDsString);
1377 // obj.DefineProperty("five", 5);
1380 return NS_ERROR_FAILURE
;
1383 aResult
.setObject(*obj
.mObj
);
1387 nsAutoCString gBaseAppVersion
;
1389 const nsCString
& GfxInfoBase::GetApplicationVersion() {
1390 static bool versionInitialized
= false;
1391 if (!versionInitialized
) {
1392 // If we fail to get the version, we will not try again.
1393 versionInitialized
= true;
1395 // Get the version from xpcom/system/nsIXULAppInfo.idl
1396 nsCOMPtr
<nsIXULAppInfo
> app
= do_GetService("@mozilla.org/xre/app-info;1");
1398 app
->GetVersion(gBaseAppVersion
);
1401 return gBaseAppVersion
;
1404 void GfxInfoBase::AddCollector(GfxInfoCollectorBase
* collector
) {
1406 sCollectors
->AppendElement(collector
);
1409 void GfxInfoBase::RemoveCollector(GfxInfoCollectorBase
* collector
) {
1411 for (uint32_t i
= 0; i
< sCollectors
->Length(); i
++) {
1412 if ((*sCollectors
)[i
] == collector
) {
1413 sCollectors
->RemoveElementAt(i
);
1417 if (sCollectors
->IsEmpty()) {
1419 sCollectors
= nullptr;
1423 nsresult
GfxInfoBase::FindMonitors(JSContext
* aCx
, JS::HandleObject aOutArray
) {
1424 // If we have no platform specific implementation for detecting monitors, we
1425 // can just get the screen size from gfxPlatform as the best guess.
1426 if (!gfxPlatform::Initialized()) {
1430 // If the screen size is empty, we are probably in xpcshell.
1431 gfx::IntSize screenSize
= gfxPlatform::GetPlatform()->GetScreenSize();
1433 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1435 JS::Rooted
<JS::Value
> screenWidth(aCx
, JS::Int32Value(screenSize
.width
));
1436 JS_SetProperty(aCx
, obj
, "screenWidth", screenWidth
);
1438 JS::Rooted
<JS::Value
> screenHeight(aCx
, JS::Int32Value(screenSize
.height
));
1439 JS_SetProperty(aCx
, obj
, "screenHeight", screenHeight
);
1441 JS::Rooted
<JS::Value
> element(aCx
, JS::ObjectValue(*obj
));
1442 JS_SetElement(aCx
, aOutArray
, 0, element
);
1448 GfxInfoBase::GetMonitors(JSContext
* aCx
, JS::MutableHandleValue aResult
) {
1449 JS::Rooted
<JSObject
*> array(aCx
, JS::NewArrayObject(aCx
, 0));
1451 nsresult rv
= FindMonitors(aCx
, array
);
1452 if (NS_FAILED(rv
)) {
1456 aResult
.setObject(*array
);
1460 static inline bool SetJSPropertyString(JSContext
* aCx
,
1461 JS::Handle
<JSObject
*> aObj
,
1462 const char* aProp
, const char* aString
) {
1463 JS::Rooted
<JSString
*> str(aCx
, JS_NewStringCopyZ(aCx
, aString
));
1468 JS::Rooted
<JS::Value
> val(aCx
, JS::StringValue(str
));
1469 return JS_SetProperty(aCx
, aObj
, aProp
, val
);
1472 template <typename T
>
1473 static inline bool AppendJSElement(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
,
1476 if (!JS::GetArrayLength(aCx
, aObj
, &index
)) {
1479 return JS_SetElement(aCx
, aObj
, index
, aValue
);
1482 nsresult
GfxInfoBase::GetFeatures(JSContext
* aCx
,
1483 JS::MutableHandle
<JS::Value
> aOut
) {
1484 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1486 return NS_ERROR_OUT_OF_MEMORY
;
1488 aOut
.setObject(*obj
);
1490 layers::LayersBackend backend
=
1491 gfxPlatform::Initialized()
1492 ? gfxPlatform::GetPlatform()->GetCompositorBackend()
1493 : layers::LayersBackend::LAYERS_NONE
;
1494 const char* backendName
= layers::GetLayersBackendName(backend
);
1495 SetJSPropertyString(aCx
, obj
, "compositor", backendName
);
1497 // If graphics isn't initialized yet, just stop now.
1498 if (!gfxPlatform::Initialized()) {
1502 DescribeFeatures(aCx
, obj
);
1506 nsresult
GfxInfoBase::GetFeatureLog(JSContext
* aCx
,
1507 JS::MutableHandle
<JS::Value
> aOut
) {
1508 JS::Rooted
<JSObject
*> containerObj(aCx
, JS_NewPlainObject(aCx
));
1509 if (!containerObj
) {
1510 return NS_ERROR_OUT_OF_MEMORY
;
1512 aOut
.setObject(*containerObj
);
1514 JS::Rooted
<JSObject
*> featureArray(aCx
, JS::NewArrayObject(aCx
, 0));
1515 if (!featureArray
) {
1516 return NS_ERROR_OUT_OF_MEMORY
;
1519 // Collect features.
1520 gfxConfig::ForEachFeature([&](const char* aName
, const char* aDescription
,
1521 FeatureState
& aFeature
) -> void {
1522 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1526 if (!SetJSPropertyString(aCx
, obj
, "name", aName
) ||
1527 !SetJSPropertyString(aCx
, obj
, "description", aDescription
) ||
1528 !SetJSPropertyString(aCx
, obj
, "status",
1529 FeatureStatusToString(aFeature
.GetValue()))) {
1533 JS::Rooted
<JS::Value
> log(aCx
);
1534 if (!BuildFeatureStateLog(aCx
, aFeature
, &log
)) {
1537 if (!JS_SetProperty(aCx
, obj
, "log", log
)) {
1541 if (!AppendJSElement(aCx
, featureArray
, obj
)) {
1546 JS::Rooted
<JSObject
*> fallbackArray(aCx
, JS::NewArrayObject(aCx
, 0));
1547 if (!fallbackArray
) {
1548 return NS_ERROR_OUT_OF_MEMORY
;
1551 // Collect fallbacks.
1552 gfxConfig::ForEachFallback(
1553 [&](const char* aName
, const char* aMessage
) -> void {
1554 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1559 if (!SetJSPropertyString(aCx
, obj
, "name", aName
) ||
1560 !SetJSPropertyString(aCx
, obj
, "message", aMessage
)) {
1564 if (!AppendJSElement(aCx
, fallbackArray
, obj
)) {
1569 JS::Rooted
<JS::Value
> val(aCx
);
1571 val
= JS::ObjectValue(*featureArray
);
1572 JS_SetProperty(aCx
, containerObj
, "features", val
);
1574 val
= JS::ObjectValue(*fallbackArray
);
1575 JS_SetProperty(aCx
, containerObj
, "fallbacks", val
);
1580 bool GfxInfoBase::BuildFeatureStateLog(JSContext
* aCx
,
1581 const FeatureState
& aFeature
,
1582 JS::MutableHandle
<JS::Value
> aOut
) {
1583 JS::Rooted
<JSObject
*> log(aCx
, JS::NewArrayObject(aCx
, 0));
1587 aOut
.setObject(*log
);
1589 aFeature
.ForEachStatusChange([&](const char* aType
, FeatureStatus aStatus
,
1590 const char* aMessage
) -> void {
1591 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1596 if (!SetJSPropertyString(aCx
, obj
, "type", aType
) ||
1597 !SetJSPropertyString(aCx
, obj
, "status",
1598 FeatureStatusToString(aStatus
)) ||
1599 (aMessage
&& !SetJSPropertyString(aCx
, obj
, "message", aMessage
))) {
1603 if (!AppendJSElement(aCx
, log
, obj
)) {
1611 void GfxInfoBase::DescribeFeatures(JSContext
* aCx
, JS::Handle
<JSObject
*> aObj
) {
1612 JS::Rooted
<JSObject
*> obj(aCx
);
1614 gfx::FeatureState
& hwCompositing
=
1615 gfxConfig::GetFeature(gfx::Feature::HW_COMPOSITING
);
1616 InitFeatureObject(aCx
, aObj
, "hwCompositing", hwCompositing
, &obj
);
1618 gfx::FeatureState
& gpuProcess
=
1619 gfxConfig::GetFeature(gfx::Feature::GPU_PROCESS
);
1620 InitFeatureObject(aCx
, aObj
, "gpuProcess", gpuProcess
, &obj
);
1622 gfx::FeatureState
& wrQualified
=
1623 gfxConfig::GetFeature(gfx::Feature::WEBRENDER_QUALIFIED
);
1624 InitFeatureObject(aCx
, aObj
, "wrQualified", wrQualified
, &obj
);
1626 gfx::FeatureState
& webrender
= gfxConfig::GetFeature(gfx::Feature::WEBRENDER
);
1627 InitFeatureObject(aCx
, aObj
, "webrender", webrender
, &obj
);
1629 gfx::FeatureState
& wrCompositor
=
1630 gfxConfig::GetFeature(gfx::Feature::WEBRENDER_COMPOSITOR
);
1631 InitFeatureObject(aCx
, aObj
, "wrCompositor", wrCompositor
, &obj
);
1633 gfx::FeatureState
& openglCompositing
=
1634 gfxConfig::GetFeature(gfx::Feature::OPENGL_COMPOSITING
);
1635 InitFeatureObject(aCx
, aObj
, "openglCompositing", openglCompositing
, &obj
);
1637 // Only include AL if the platform attempted to use it.
1638 gfx::FeatureState
& advancedLayers
=
1639 gfxConfig::GetFeature(gfx::Feature::ADVANCED_LAYERS
);
1640 if (advancedLayers
.GetValue() != FeatureStatus::Unused
) {
1641 InitFeatureObject(aCx
, aObj
, "advancedLayers", advancedLayers
, &obj
);
1643 if (gfxConfig::UseFallback(Fallback::NO_CONSTANT_BUFFER_OFFSETTING
)) {
1644 JS::Rooted
<JS::Value
> trueVal(aCx
, JS::BooleanValue(true));
1645 JS_SetProperty(aCx
, obj
, "noConstantBufferOffsetting", trueVal
);
1650 bool GfxInfoBase::InitFeatureObject(JSContext
* aCx
,
1651 JS::Handle
<JSObject
*> aContainer
,
1653 mozilla::gfx::FeatureState
& aFeatureState
,
1654 JS::MutableHandle
<JSObject
*> aOutObj
) {
1655 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1661 auto value
= aFeatureState
.GetValue();
1663 case FeatureStatus::Blocklisted
:
1664 case FeatureStatus::Disabled
:
1665 case FeatureStatus::Unavailable
:
1666 case FeatureStatus::UnavailableNoAngle
:
1667 case FeatureStatus::Blocked
:
1668 status
.AppendPrintf("%s:%s", FeatureStatusToString(value
),
1669 aFeatureState
.GetFailureId().get());
1672 status
.Append(FeatureStatusToString(value
));
1676 JS::Rooted
<JSString
*> str(aCx
, JS_NewStringCopyZ(aCx
, status
.get()));
1677 JS::Rooted
<JS::Value
> val(aCx
, JS::StringValue(str
));
1678 JS_SetProperty(aCx
, obj
, "status", val
);
1680 // Add the feature object to the container.
1682 JS::Rooted
<JS::Value
> val(aCx
, JS::ObjectValue(*obj
));
1683 JS_SetProperty(aCx
, aContainer
, aName
, val
);
1690 nsresult
GfxInfoBase::GetActiveCrashGuards(JSContext
* aCx
,
1691 JS::MutableHandle
<JS::Value
> aOut
) {
1692 JS::Rooted
<JSObject
*> array(aCx
, JS::NewArrayObject(aCx
, 0));
1694 return NS_ERROR_OUT_OF_MEMORY
;
1696 aOut
.setObject(*array
);
1698 DriverCrashGuard::ForEachActiveCrashGuard(
1699 [&](const char* aName
, const char* aPrefName
) -> void {
1700 JS::Rooted
<JSObject
*> obj(aCx
, JS_NewPlainObject(aCx
));
1704 if (!SetJSPropertyString(aCx
, obj
, "type", aName
)) {
1707 if (!SetJSPropertyString(aCx
, obj
, "prefName", aPrefName
)) {
1710 if (!AppendJSElement(aCx
, array
, obj
)) {
1719 GfxInfoBase::GetWebRenderEnabled(bool* aWebRenderEnabled
) {
1720 *aWebRenderEnabled
= gfxVars::UseWebRender();
1725 GfxInfoBase::GetUsesTiling(bool* aUsesTiling
) {
1726 *aUsesTiling
= gfxPlatform::GetPlatform()->UsesTiling();
1731 GfxInfoBase::GetContentUsesTiling(bool* aUsesTiling
) {
1732 *aUsesTiling
= gfxPlatform::GetPlatform()->ContentUsesTiling();
1737 GfxInfoBase::GetOffMainThreadPaintEnabled(bool* aOffMainThreadPaintEnabled
) {
1738 *aOffMainThreadPaintEnabled
= gfxConfig::IsEnabled(gfx::Feature::OMTP
);
1743 GfxInfoBase::GetOffMainThreadPaintWorkerCount(
1744 int32_t* aOffMainThreadPaintWorkerCount
) {
1745 if (gfxConfig::IsEnabled(gfx::Feature::OMTP
)) {
1746 *aOffMainThreadPaintWorkerCount
=
1747 layers::PaintThread::CalculatePaintWorkerCount();
1749 *aOffMainThreadPaintWorkerCount
= 0;
1755 GfxInfoBase::GetTargetFrameRate(uint32_t* aTargetFrameRate
) {
1756 *aTargetFrameRate
= gfxPlatform::TargetFrameRate();
1761 GfxInfoBase::GetIsHeadless(bool* aIsHeadless
) {
1762 *aIsHeadless
= gfxPlatform::IsHeadless();
1767 GfxInfoBase::GetContentBackend(nsAString
& aContentBackend
) {
1768 BackendType backend
= gfxPlatform::GetPlatform()->GetDefaultContentBackend();
1772 case BackendType::DIRECT2D1_1
: {
1773 outStr
.AppendPrintf("Direct2D 1.1");
1776 case BackendType::SKIA
: {
1777 outStr
.AppendPrintf("Skia");
1780 case BackendType::CAIRO
: {
1781 outStr
.AppendPrintf("Cairo");
1785 return NS_ERROR_FAILURE
;
1788 aContentBackend
.Assign(outStr
);
1793 GfxInfoBase::GetUsingGPUProcess(bool* aOutValue
) {
1794 GPUProcessManager
* gpu
= GPUProcessManager::Get();
1796 // Not supported in content processes.
1797 return NS_ERROR_FAILURE
;
1800 *aOutValue
= !!gpu
->GetGPUChild();
1805 GfxInfoBase::ControlGPUProcessForXPCShell(bool aEnable
, bool* _retval
) {
1806 gfxPlatform::GetPlatform();
1808 GPUProcessManager
* gpm
= GPUProcessManager::Get();
1810 if (!gfxConfig::IsEnabled(gfx::Feature::GPU_PROCESS
)) {
1811 gfxConfig::UserForceEnable(gfx::Feature::GPU_PROCESS
, "xpcshell-test");
1813 gpm
->LaunchGPUProcess();
1814 gpm
->EnsureGPUReady();
1816 gfxConfig::UserDisable(gfx::Feature::GPU_PROCESS
, "xpcshell-test");
1824 GfxInfoCollectorBase::GfxInfoCollectorBase() {
1825 GfxInfoBase::AddCollector(this);
1828 GfxInfoCollectorBase::~GfxInfoCollectorBase() {
1829 GfxInfoBase::RemoveCollector(this);