2011-01-20 04:30:12 +03:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
#include "GfxInfoBase.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2020-08-08 00:38:18 +03:00
|
|
|
#include <mutex> // std::call_once
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "GfxDriverInfo.h"
|
2019-12-11 09:17:44 +03:00
|
|
|
#include "js/Array.h" // JS::GetArrayLength, JS::NewArrayObject
|
2011-01-20 04:30:15 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "nsCOMArray.h"
|
2011-01-20 04:30:15 +03:00
|
|
|
#include "nsString.h"
|
2012-02-21 23:49:06 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
2015-05-15 17:42:10 +03:00
|
|
|
#include "nsVersionComparator.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "mozilla/Services.h"
|
2011-12-15 09:02:59 +04:00
|
|
|
#include "mozilla/Observer.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIObserverService.h"
|
2020-02-13 18:51:32 +03:00
|
|
|
#include "nsIScreenManager.h"
|
2011-01-20 04:33:51 +03:00
|
|
|
#include "nsTArray.h"
|
2014-01-11 05:09:20 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2015-05-15 17:42:10 +03:00
|
|
|
#include "nsIXULAppInfo.h"
|
2020-08-08 00:38:18 +03:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2011-05-23 18:54:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_gfx.h"
|
2015-01-14 05:19:25 +03:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2016-11-15 02:02:02 +03:00
|
|
|
#include "mozilla/gfx/GPUProcessManager.h"
|
2015-01-14 05:19:25 +03:00
|
|
|
#include "mozilla/gfx/Logging.h"
|
2017-03-22 22:20:00 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2018-01-24 00:52:13 +03:00
|
|
|
#include "mozilla/layers/PaintThread.h"
|
2019-05-26 17:31:53 +03:00
|
|
|
|
2015-07-20 00:50:35 +03:00
|
|
|
#include "gfxPlatform.h"
|
2016-04-29 07:52:56 +03:00
|
|
|
#include "gfxConfig.h"
|
2016-05-10 21:49:16 +03:00
|
|
|
#include "DriverCrashGuard.h"
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
using namespace mozilla::widget;
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2013-02-25 18:07:16 +04:00
|
|
|
using mozilla::MutexAutoLock;
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2018-05-14 18:16:50 +03:00
|
|
|
nsTArray<GfxDriverInfo>* GfxInfoBase::sDriverInfo;
|
2020-08-08 00:38:18 +03:00
|
|
|
StaticAutoPtr<nsTArray<gfx::GfxInfoFeatureStatus>> GfxInfoBase::sFeatureStatus;
|
2018-05-14 18:16:50 +03:00
|
|
|
bool GfxInfoBase::sDriverInfoObserverInitialized;
|
|
|
|
bool GfxInfoBase::sShutdownOccurred;
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2020-08-08 00:38:18 +03:00
|
|
|
// Call this when setting sFeatureStatus to a non-null pointer to
|
|
|
|
// ensure destruction even if the GfxInfo component is never instantiated.
|
|
|
|
static void InitFeatureStatus(nsTArray<gfx::GfxInfoFeatureStatus>* aPtr) {
|
|
|
|
static std::once_flag sOnce;
|
|
|
|
std::call_once(sOnce, [] { ClearOnShutdown(&GfxInfoBase::sFeatureStatus); });
|
|
|
|
GfxInfoBase::sFeatureStatus = aPtr;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
// Observes for shutdown so that the child GfxDriverInfo list is freed.
|
|
|
|
class ShutdownObserver : public nsIObserver {
|
2020-03-16 13:56:57 +03:00
|
|
|
virtual ~ShutdownObserver() = default;
|
2014-06-24 20:36:44 +04:00
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
public:
|
2020-03-16 13:56:57 +03:00
|
|
|
ShutdownObserver() = default;
|
2011-12-15 09:02:59 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD Observe(nsISupports* subject, const char* aTopic,
|
2015-03-21 19:28:04 +03:00
|
|
|
const char16_t* aData) override {
|
2011-12-15 09:02:59 +04:00
|
|
|
MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0);
|
2011-12-15 09:03:01 +04:00
|
|
|
|
2018-05-14 18:16:50 +03:00
|
|
|
delete GfxInfoBase::sDriverInfo;
|
|
|
|
GfxInfoBase::sDriverInfo = nullptr;
|
2011-12-15 09:03:01 +04:00
|
|
|
|
2020-02-13 18:51:40 +03:00
|
|
|
for (auto& deviceFamily : GfxDriverInfo::sDeviceFamilies) {
|
|
|
|
delete deviceFamily;
|
|
|
|
deviceFamily = nullptr;
|
2018-05-09 00:37:25 +03:00
|
|
|
}
|
2011-12-15 09:03:01 +04:00
|
|
|
|
2020-02-13 18:51:40 +03:00
|
|
|
for (auto& desktop : GfxDriverInfo::sDesktopEnvironment) {
|
|
|
|
delete desktop;
|
|
|
|
desktop = nullptr;
|
2020-02-10 17:21:30 +03:00
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:40 +03:00
|
|
|
for (auto& windowProtocol : GfxDriverInfo::sWindowProtocol) {
|
|
|
|
delete windowProtocol;
|
|
|
|
windowProtocol = nullptr;
|
2020-02-10 17:21:30 +03:00
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:40 +03:00
|
|
|
for (auto& deviceVendor : GfxDriverInfo::sDeviceVendors) {
|
|
|
|
delete deviceVendor;
|
|
|
|
deviceVendor = nullptr;
|
2018-05-09 00:37:25 +03:00
|
|
|
}
|
2011-12-15 09:03:01 +04:00
|
|
|
|
2020-02-13 18:51:40 +03:00
|
|
|
for (auto& driverVendor : GfxDriverInfo::sDriverVendors) {
|
|
|
|
delete driverVendor;
|
|
|
|
driverVendor = nullptr;
|
2019-04-30 23:29:18 +03:00
|
|
|
}
|
|
|
|
|
2018-05-14 18:16:50 +03:00
|
|
|
GfxInfoBase::sShutdownOccurred = true;
|
2016-10-27 18:04:50 +03:00
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ShutdownObserver, nsIObserver)
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2019-02-17 12:18:01 +03:00
|
|
|
static void InitGfxDriverInfoShutdownObserver() {
|
2018-05-14 18:16:50 +03:00
|
|
|
if (GfxInfoBase::sDriverInfoObserverInitialized) return;
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2018-05-14 18:16:50 +03:00
|
|
|
GfxInfoBase::sDriverInfoObserverInitialized = true;
|
2011-12-15 09:02:59 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
|
|
|
|
if (!observerService) {
|
|
|
|
NS_WARNING("Could not get observer service!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShutdownObserver* obs = new ShutdownObserver();
|
|
|
|
observerService->AddObserver(obs, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
using namespace mozilla::widget;
|
2015-01-14 05:19:25 +03:00
|
|
|
using namespace mozilla::gfx;
|
2011-05-23 18:54:03 +04:00
|
|
|
using namespace mozilla;
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(GfxInfoBase, nsIGfxInfo, nsIObserver,
|
|
|
|
nsISupportsWeakReference)
|
2011-01-20 04:30:12 +03:00
|
|
|
|
2020-06-23 18:14:04 +03:00
|
|
|
#define BLOCKLIST_PREF_BRANCH "gfx.blacklist."
|
|
|
|
#define SUGGESTED_VERSION_PREF BLOCKLIST_PREF_BRANCH "suggested-driver-version"
|
2011-01-20 04:30:15 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static const char* GetPrefNameForFeature(int32_t aFeature) {
|
2012-07-30 18:20:58 +04:00
|
|
|
const char* name = nullptr;
|
2011-01-20 04:30:15 +03:00
|
|
|
switch (aFeature) {
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT2D:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "direct2d";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "layers.direct3d9";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "layers.direct3d10";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "layers.direct3d10-1";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
2014-05-16 20:16:21 +04:00
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "layers.direct3d11";
|
2014-05-16 20:16:21 +04:00
|
|
|
break;
|
2015-04-10 23:17:27 +03:00
|
|
|
case nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "direct3d11angle";
|
2015-04-10 23:17:27 +03:00
|
|
|
break;
|
2015-04-01 06:06:56 +03:00
|
|
|
case nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "hardwarevideodecoding";
|
2015-01-26 03:34:28 +03:00
|
|
|
break;
|
2011-01-20 04:30:15 +03:00
|
|
|
case nsIGfxInfo::FEATURE_OPENGL_LAYERS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "layers.opengl";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_WEBGL_OPENGL:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webgl.opengl";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_WEBGL_ANGLE:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webgl.angle";
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
2020-09-28 01:18:23 +03:00
|
|
|
case nsIGfxInfo::UNUSED_FEATURE_WEBGL_MSAA:
|
2020-09-25 09:33:40 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webgl.msaa";
|
|
|
|
break;
|
2012-11-02 01:13:10 +04:00
|
|
|
case nsIGfxInfo::FEATURE_STAGEFRIGHT:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "stagefright";
|
2012-11-02 01:13:10 +04:00
|
|
|
break;
|
2019-10-08 20:15:44 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrtc.hw.acceleration.h264";
|
2015-05-15 17:42:10 +03:00
|
|
|
break;
|
2015-07-24 22:45:55 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrtc.hw.acceleration.encode";
|
2015-07-24 22:45:55 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrtc.hw.acceleration.decode";
|
2015-07-24 22:45:55 +03:00
|
|
|
break;
|
2016-02-19 16:39:00 +03:00
|
|
|
case nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "canvas2d.acceleration";
|
2016-02-27 05:57:15 +03:00
|
|
|
break;
|
2017-11-21 21:13:10 +03:00
|
|
|
case nsIGfxInfo::FEATURE_DX_INTEROP2:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "dx.interop2";
|
2017-11-21 21:13:10 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_GPU_PROCESS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "gpu.process";
|
2017-11-21 21:13:10 +03:00
|
|
|
break;
|
2017-03-02 23:48:06 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBGL2:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webgl2";
|
2017-03-02 23:48:06 +03:00
|
|
|
break;
|
2017-06-24 00:23:13 +03:00
|
|
|
case nsIGfxInfo::FEATURE_ADVANCED_LAYERS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "layers.advanced";
|
2017-06-24 00:23:13 +03:00
|
|
|
break;
|
2017-07-25 21:02:36 +03:00
|
|
|
case nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "d3d11.keyed.mutex";
|
2017-07-25 21:02:36 +03:00
|
|
|
break;
|
2018-05-03 13:02:00 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRENDER:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrender";
|
2018-05-03 13:02:00 +03:00
|
|
|
break;
|
2019-12-10 22:16:13 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrender.compositor";
|
2019-12-10 22:16:13 +03:00
|
|
|
break;
|
2018-05-17 06:07:20 +03:00
|
|
|
case nsIGfxInfo::FEATURE_DX_NV12:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "dx.nv12";
|
2018-05-17 06:07:20 +03:00
|
|
|
break;
|
2018-10-11 10:32:35 +03:00
|
|
|
case nsIGfxInfo::FEATURE_DX_P010:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "dx.p010";
|
2018-10-11 10:32:35 +03:00
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_DX_P016:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "dx.p016";
|
2018-10-11 10:32:35 +03:00
|
|
|
break;
|
2016-03-21 22:19:13 +03:00
|
|
|
case nsIGfxInfo::FEATURE_VP8_HW_DECODE:
|
|
|
|
case nsIGfxInfo::FEATURE_VP9_HW_DECODE:
|
2017-11-21 21:13:10 +03:00
|
|
|
// We don't provide prefs for these features as these are
|
|
|
|
// not handling downloadable blocklist.
|
2016-03-21 22:19:13 +03:00
|
|
|
break;
|
2019-08-09 21:57:35 +03:00
|
|
|
case nsIGfxInfo::FEATURE_GL_SWIZZLE:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "gl.swizzle";
|
2019-08-09 21:57:35 +03:00
|
|
|
break;
|
2020-06-09 00:05:03 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS:
|
2020-06-23 18:14:04 +03:00
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrender.scissored_cache_clears";
|
2020-06-09 00:05:03 +03:00
|
|
|
break;
|
2020-10-01 11:14:12 +03:00
|
|
|
case nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS:
|
|
|
|
name = BLOCKLIST_PREF_BRANCH "webgl.allow-oop";
|
|
|
|
break;
|
|
|
|
case nsIGfxInfo::FEATURE_THREADSAFE_GL:
|
|
|
|
name = BLOCKLIST_PREF_BRANCH "gl.threadsafe";
|
|
|
|
break;
|
2020-11-11 02:36:43 +03:00
|
|
|
case nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE:
|
|
|
|
name = BLOCKLIST_PREF_BRANCH "webrender.software";
|
|
|
|
break;
|
2011-01-20 04:30:15 +03:00
|
|
|
default:
|
2016-02-27 05:57:15 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Unexpected nsIGfxInfo feature?!");
|
2011-01-20 04:30:15 +03:00
|
|
|
break;
|
2016-01-22 18:58:49 +03:00
|
|
|
}
|
2011-01-20 04:30:15 +03:00
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the value of the pref for the relevant feature in aValue.
|
|
|
|
// If the pref doesn't exist, aValue is not touched, and returns false.
|
2016-04-14 00:12:47 +03:00
|
|
|
static bool GetPrefValueForFeature(int32_t aFeature, int32_t& aValue,
|
|
|
|
nsACString& aFailureId) {
|
2011-01-20 04:30:15 +03:00
|
|
|
const char* prefname = GetPrefNameForFeature(aFeature);
|
|
|
|
if (!prefname) return false;
|
|
|
|
|
2015-05-28 18:54:07 +03:00
|
|
|
aValue = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
|
2016-04-14 00:12:47 +03:00
|
|
|
if (!NS_SUCCEEDED(Preferences::GetInt(prefname, &aValue))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString failureprefname(prefname);
|
|
|
|
failureprefname += ".failureid";
|
2017-07-31 07:28:48 +03:00
|
|
|
nsAutoCString failureValue;
|
|
|
|
nsresult rv = Preferences::GetCString(failureprefname.get(), failureValue);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2016-04-14 00:12:47 +03:00
|
|
|
aFailureId = failureValue.get();
|
|
|
|
} else {
|
2020-06-23 18:23:11 +03:00
|
|
|
aFailureId = "FEATURE_FAILURE_BLOCKLIST_PREF";
|
2016-04-14 00:12:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 00:12:47 +03:00
|
|
|
static void SetPrefValueForFeature(int32_t aFeature, int32_t aValue,
|
|
|
|
const nsACString& aFailureId) {
|
2011-01-20 04:30:15 +03:00
|
|
|
const char* prefname = GetPrefNameForFeature(aFeature);
|
|
|
|
if (!prefname) return;
|
2019-11-09 05:21:18 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
GfxInfoBase::sFeatureStatus = nullptr;
|
|
|
|
}
|
2011-01-20 04:30:15 +03:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
Preferences::SetInt(prefname, aValue);
|
2016-04-14 00:12:47 +03:00
|
|
|
if (!aFailureId.IsEmpty()) {
|
|
|
|
nsCString failureprefname(prefname);
|
|
|
|
failureprefname += ".failureid";
|
|
|
|
Preferences::SetCString(failureprefname.get(), aFailureId);
|
|
|
|
}
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static void RemovePrefForFeature(int32_t aFeature) {
|
2011-01-20 04:30:15 +03:00
|
|
|
const char* prefname = GetPrefNameForFeature(aFeature);
|
|
|
|
if (!prefname) return;
|
|
|
|
|
2019-11-09 05:21:18 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
GfxInfoBase::sFeatureStatus = nullptr;
|
|
|
|
}
|
2011-05-23 18:54:03 +04:00
|
|
|
Preferences::ClearUser(prefname);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
static bool GetPrefValueForDriverVersion(nsCString& aVersion) {
|
2011-05-27 08:53:03 +04:00
|
|
|
return NS_SUCCEEDED(
|
|
|
|
Preferences::GetCString(SUGGESTED_VERSION_PREF, aVersion));
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
2011-05-27 08:53:03 +04:00
|
|
|
static void SetPrefValueForDriverVersion(const nsAString& aVersion) {
|
|
|
|
Preferences::SetString(SUGGESTED_VERSION_PREF, aVersion);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void RemovePrefForDriverVersion() {
|
2011-05-23 18:54:03 +04:00
|
|
|
Preferences::ClearUser(SUGGESTED_VERSION_PREF);
|
2011-01-20 04:30:15 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
static OperatingSystem BlocklistOSToOperatingSystem(const nsAString& os) {
|
2020-11-27 17:04:09 +03:00
|
|
|
if (os.EqualsLiteral("WINNT 6.1")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Windows7;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("WINNT 6.2")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Windows8;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("WINNT 6.3")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Windows8_1;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("WINNT 10.0")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Windows10;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Linux")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Linux;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 9")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_5;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 10")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_6;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 11")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_7;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 12")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_8;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 13")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_9;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 14")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_10;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 15")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::OSX10_11;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 16")) {
|
2016-07-05 00:25:25 +03:00
|
|
|
return OperatingSystem::OSX10_12;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 17")) {
|
2017-09-28 17:21:10 +03:00
|
|
|
return OperatingSystem::OSX10_13;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 18")) {
|
2019-10-09 00:09:58 +03:00
|
|
|
return OperatingSystem::OSX10_14;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 19")) {
|
2019-10-09 00:09:58 +03:00
|
|
|
return OperatingSystem::OSX10_15;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin 20")) {
|
2020-11-19 20:34:25 +03:00
|
|
|
return OperatingSystem::OSX11_0;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Android")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Android;
|
2020-12-16 04:43:18 +03:00
|
|
|
// For historical reasons, "All" in blocklist means "All Windows"
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("All")) {
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Windows;
|
2020-11-27 17:04:09 +03:00
|
|
|
} else if (os.EqualsLiteral("Darwin")) {
|
|
|
|
return OperatingSystem::OSX;
|
|
|
|
}
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2016-06-03 23:13:08 +03:00
|
|
|
return OperatingSystem::Unknown;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
static GfxDeviceFamily* BlocklistDevicesToDeviceFamily(
|
2016-05-04 17:12:19 +03:00
|
|
|
nsTArray<nsCString>& devices) {
|
|
|
|
if (devices.Length() == 0) return nullptr;
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2016-05-04 17:12:19 +03:00
|
|
|
// For each device, get its device ID, and return a freshly-allocated
|
2011-12-15 09:03:01 +04:00
|
|
|
// GfxDeviceFamily with the contents of that array.
|
|
|
|
GfxDeviceFamily* deviceIds = new GfxDeviceFamily;
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2016-05-04 17:12:19 +03:00
|
|
|
for (uint32_t i = 0; i < devices.Length(); ++i) {
|
|
|
|
// We make sure we don't add any "empty" device entries to the array, so
|
|
|
|
// we don't need to check if devices[i] is empty.
|
2020-02-13 18:51:40 +03:00
|
|
|
deviceIds->Append(NS_ConvertUTF8toUTF16(devices[i]));
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
return deviceIds;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
static int32_t BlocklistFeatureToGfxFeature(const nsAString& aFeature) {
|
2015-05-15 17:42:11 +03:00
|
|
|
MOZ_ASSERT(!aFeature.IsEmpty());
|
2014-05-22 07:48:50 +04:00
|
|
|
if (aFeature.EqualsLiteral("DIRECT2D"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT2D;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_9_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_10_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_10_1_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_11_LAYERS"))
|
2014-05-16 20:16:21 +04:00
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS;
|
2015-04-10 23:17:27 +03:00
|
|
|
else if (aFeature.EqualsLiteral("DIRECT3D_11_ANGLE"))
|
|
|
|
return nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE;
|
2015-04-01 06:06:56 +03:00
|
|
|
else if (aFeature.EqualsLiteral("HARDWARE_VIDEO_DECODING"))
|
|
|
|
return nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("OPENGL_LAYERS"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_OPENGL_LAYERS;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL_OPENGL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_WEBGL_OPENGL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL_ANGLE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_WEBGL_ANGLE;
|
2020-09-25 09:33:40 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL_MSAA"))
|
2020-09-28 01:18:23 +03:00
|
|
|
return nsIGfxInfo::UNUSED_FEATURE_WEBGL_MSAA;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aFeature.EqualsLiteral("STAGEFRIGHT"))
|
2012-11-02 01:13:10 +04:00
|
|
|
return nsIGfxInfo::FEATURE_STAGEFRIGHT;
|
2015-07-24 22:45:55 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION_ENCODE"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE;
|
|
|
|
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION_DECODE"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE;
|
2019-10-08 20:15:44 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION_H264"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264;
|
2016-02-19 16:39:00 +03:00
|
|
|
else if (aFeature.EqualsLiteral("CANVAS2D_ACCELERATION"))
|
|
|
|
return nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION;
|
2017-11-21 21:13:10 +03:00
|
|
|
else if (aFeature.EqualsLiteral("DX_INTEROP2"))
|
|
|
|
return nsIGfxInfo::FEATURE_DX_INTEROP2;
|
|
|
|
else if (aFeature.EqualsLiteral("GPU_PROCESS"))
|
|
|
|
return nsIGfxInfo::FEATURE_GPU_PROCESS;
|
2017-03-02 23:48:06 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBGL2"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBGL2;
|
2017-07-14 21:13:54 +03:00
|
|
|
else if (aFeature.EqualsLiteral("ADVANCED_LAYERS"))
|
|
|
|
return nsIGfxInfo::FEATURE_ADVANCED_LAYERS;
|
2017-07-25 21:02:36 +03:00
|
|
|
else if (aFeature.EqualsLiteral("D3D11_KEYED_MUTEX"))
|
|
|
|
return nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX;
|
2018-05-03 13:02:00 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRENDER"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRENDER;
|
2019-12-10 22:16:13 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRENDER_COMPOSITOR"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR;
|
2018-05-17 06:07:20 +03:00
|
|
|
else if (aFeature.EqualsLiteral("DX_NV12"))
|
|
|
|
return nsIGfxInfo::FEATURE_DX_NV12;
|
2017-11-21 21:13:10 +03:00
|
|
|
// We do not support FEATURE_VP8_HW_DECODE and FEATURE_VP9_HW_DECODE
|
|
|
|
// in downloadable blocklist.
|
2019-08-09 21:57:35 +03:00
|
|
|
else if (aFeature.EqualsLiteral("GL_SWIZZLE"))
|
|
|
|
return nsIGfxInfo::FEATURE_GL_SWIZZLE;
|
2020-06-09 00:05:03 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRENDER_SCISSORED_CACHE_CLEARS"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS;
|
2020-10-01 11:14:12 +03:00
|
|
|
else if (aFeature.EqualsLiteral("ALLOW_WEBGL_OUT_OF_PROCESS"))
|
|
|
|
return nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS;
|
|
|
|
else if (aFeature.EqualsLiteral("THREADSAFE_GL"))
|
|
|
|
return nsIGfxInfo::FEATURE_THREADSAFE_GL;
|
2020-11-11 02:36:43 +03:00
|
|
|
else if (aFeature.EqualsLiteral("WEBRENDER_SOFTWARE"))
|
|
|
|
return nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE;
|
2015-05-15 17:42:11 +03:00
|
|
|
|
|
|
|
// If we don't recognize the feature, it may be new, and something
|
|
|
|
// this version doesn't understand. So, nothing to do. This is
|
|
|
|
// different from feature not being specified at all, in which case
|
|
|
|
// this method should not get called and we should continue with the
|
|
|
|
// "all features" blocklisting.
|
|
|
|
return -1;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
static int32_t BlocklistFeatureStatusToGfxFeatureStatus(
|
2011-01-20 04:33:51 +03:00
|
|
|
const nsAString& aStatus) {
|
2014-07-02 01:44:09 +04:00
|
|
|
if (aStatus.EqualsLiteral("STATUS_OK"))
|
|
|
|
return nsIGfxInfo::FEATURE_STATUS_OK;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("BLOCKED_DRIVER_VERSION"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("BLOCKED_DEVICE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("DISCOURAGED"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_DISCOURAGED;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (aStatus.EqualsLiteral("BLOCKED_OS_VERSION"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
|
2020-02-13 19:06:41 +03:00
|
|
|
else if (aStatus.EqualsLiteral("DENIED"))
|
|
|
|
return nsIGfxInfo::FEATURE_DENIED;
|
|
|
|
else if (aStatus.EqualsLiteral("ALLOW_QUALIFIED"))
|
|
|
|
return nsIGfxInfo::FEATURE_ALLOW_QUALIFIED;
|
|
|
|
else if (aStatus.EqualsLiteral("ALLOW_ALWAYS"))
|
|
|
|
return nsIGfxInfo::FEATURE_ALLOW_ALWAYS;
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2015-05-15 20:43:38 +03:00
|
|
|
// Do not allow it to set STATUS_UNKNOWN. Also, we are not
|
|
|
|
// expecting the "mismatch" status showing up here.
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2014-07-02 01:44:09 +04:00
|
|
|
return nsIGfxInfo::FEATURE_STATUS_OK;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
static VersionComparisonOp BlocklistComparatorToComparisonOp(
|
2011-01-20 04:33:51 +03:00
|
|
|
const nsAString& op) {
|
2014-05-22 07:48:50 +04:00
|
|
|
if (op.EqualsLiteral("LESS_THAN"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_LESS_THAN;
|
2016-08-31 20:59:00 +03:00
|
|
|
else if (op.EqualsLiteral("BUILD_ID_LESS_THAN"))
|
|
|
|
return DRIVER_BUILD_ID_LESS_THAN;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("LESS_THAN_OR_EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_LESS_THAN_OR_EQUAL;
|
2016-08-31 20:59:00 +03:00
|
|
|
else if (op.EqualsLiteral("BUILD_ID_LESS_THAN_OR_EQUAL"))
|
|
|
|
return DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("GREATER_THAN"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_GREATER_THAN;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("GREATER_THAN_OR_EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_GREATER_THAN_OR_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("NOT_EQUAL"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_NOT_EQUAL;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("BETWEEN_EXCLUSIVE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_BETWEEN_EXCLUSIVE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("BETWEEN_INCLUSIVE"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_BETWEEN_INCLUSIVE;
|
2014-05-22 07:48:50 +04:00
|
|
|
else if (op.EqualsLiteral("BETWEEN_INCLUSIVE_START"))
|
2011-01-20 04:33:51 +03:00
|
|
|
return DRIVER_BETWEEN_INCLUSIVE_START;
|
|
|
|
|
2012-05-04 23:33:59 +04:00
|
|
|
return DRIVER_COMPARISON_IGNORED;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2020-06-23 18:20:33 +03:00
|
|
|
Deserialize Blocklist entries from string.
|
2016-05-04 17:12:19 +03:00
|
|
|
e.g:
|
|
|
|
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
|
2011-01-20 04:33:51 +03:00
|
|
|
*/
|
2020-09-02 20:04:51 +03:00
|
|
|
static bool BlocklistEntryToDriverInfo(const nsACString& aBlocklistEntry,
|
2011-01-20 04:33:51 +03:00
|
|
|
GfxDriverInfo& aDriverInfo) {
|
2015-05-15 17:42:10 +03:00
|
|
|
// If we get an application version to be zero, something is not working
|
|
|
|
// and we are not going to bother checking the blocklist versions.
|
|
|
|
// See TestGfxWidgets.cpp for how version comparison works.
|
|
|
|
// <versionRange minVersion="42.0a1" maxVersion="45.0"></versionRange>
|
|
|
|
static mozilla::Version zeroV("0");
|
|
|
|
static mozilla::Version appV(GfxInfoBase::GetApplicationVersion().get());
|
|
|
|
if (appV <= zeroV) {
|
|
|
|
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false))
|
|
|
|
<< "Invalid application version "
|
|
|
|
<< GfxInfoBase::GetApplicationVersion().get();
|
2016-05-04 17:12:19 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:23:11 +03:00
|
|
|
aDriverInfo.mRuleId = "FEATURE_FAILURE_DL_BLOCKLIST_NO_ID"_ns;
|
2016-05-04 17:12:19 +03:00
|
|
|
|
2020-09-02 19:58:33 +03:00
|
|
|
for (const auto& keyValue : aBlocklistEntry.Split('\t')) {
|
2016-05-04 17:12:19 +03:00
|
|
|
nsTArray<nsCString> splitted;
|
|
|
|
ParseString(keyValue, ':', splitted);
|
|
|
|
if (splitted.Length() != 2) {
|
|
|
|
// If we don't recognize the input data, we do not want to proceed.
|
|
|
|
gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
|
2020-09-02 19:58:33 +03:00
|
|
|
<< "Unrecognized data " << nsCString(keyValue).get();
|
2016-05-04 17:12:19 +03:00
|
|
|
return false;
|
|
|
|
}
|
2020-09-02 19:58:10 +03:00
|
|
|
const nsCString& key = splitted[0];
|
|
|
|
const nsCString& value = splitted[1];
|
2016-05-04 17:12:19 +03:00
|
|
|
NS_ConvertUTF8toUTF16 dataValue(value);
|
|
|
|
|
|
|
|
if (value.Length() == 0) {
|
|
|
|
// Safety check for empty values.
|
|
|
|
gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
|
|
|
|
<< "Empty value for " << key.get();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key.EqualsLiteral("blockID")) {
|
2020-06-23 18:23:11 +03:00
|
|
|
nsCString blockIdStr = "FEATURE_FAILURE_DL_BLOCKLIST_"_ns + value;
|
2016-05-04 17:12:19 +03:00
|
|
|
aDriverInfo.mRuleId = blockIdStr.get();
|
|
|
|
} else if (key.EqualsLiteral("os")) {
|
2020-06-23 18:20:33 +03:00
|
|
|
aDriverInfo.mOperatingSystem = BlocklistOSToOperatingSystem(dataValue);
|
2016-05-04 17:12:19 +03:00
|
|
|
} else if (key.EqualsLiteral("osversion")) {
|
|
|
|
aDriverInfo.mOperatingSystemVersion = strtoul(value.get(), nullptr, 10);
|
2020-02-10 17:21:30 +03:00
|
|
|
} else if (key.EqualsLiteral("desktopEnvironment")) {
|
|
|
|
aDriverInfo.mDesktopEnvironment = dataValue;
|
|
|
|
} else if (key.EqualsLiteral("windowProtocol")) {
|
|
|
|
aDriverInfo.mWindowProtocol = dataValue;
|
2016-05-04 17:12:19 +03:00
|
|
|
} else if (key.EqualsLiteral("vendor")) {
|
|
|
|
aDriverInfo.mAdapterVendor = dataValue;
|
2019-04-30 23:29:18 +03:00
|
|
|
} else if (key.EqualsLiteral("driverVendor")) {
|
|
|
|
aDriverInfo.mDriverVendor = dataValue;
|
2016-05-04 17:12:19 +03:00
|
|
|
} else if (key.EqualsLiteral("feature")) {
|
2020-06-23 18:20:33 +03:00
|
|
|
aDriverInfo.mFeature = BlocklistFeatureToGfxFeature(dataValue);
|
2016-05-04 17:12:19 +03:00
|
|
|
if (aDriverInfo.mFeature < 0) {
|
|
|
|
// If we don't recognize the feature, we do not want to proceed.
|
|
|
|
gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
|
|
|
|
<< "Unrecognized feature " << value.get();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (key.EqualsLiteral("featureStatus")) {
|
|
|
|
aDriverInfo.mFeatureStatus =
|
2020-06-23 18:20:33 +03:00
|
|
|
BlocklistFeatureStatusToGfxFeatureStatus(dataValue);
|
2016-05-04 17:12:19 +03:00
|
|
|
} else if (key.EqualsLiteral("driverVersion")) {
|
|
|
|
uint64_t version;
|
|
|
|
if (ParseDriverVersion(dataValue, &version))
|
|
|
|
aDriverInfo.mDriverVersion = version;
|
|
|
|
} else if (key.EqualsLiteral("driverVersionMax")) {
|
|
|
|
uint64_t version;
|
|
|
|
if (ParseDriverVersion(dataValue, &version))
|
|
|
|
aDriverInfo.mDriverVersionMax = version;
|
|
|
|
} else if (key.EqualsLiteral("driverVersionComparator")) {
|
2020-06-23 18:20:33 +03:00
|
|
|
aDriverInfo.mComparisonOp = BlocklistComparatorToComparisonOp(dataValue);
|
2016-05-04 17:12:19 +03:00
|
|
|
} else if (key.EqualsLiteral("model")) {
|
|
|
|
aDriverInfo.mModel = dataValue;
|
|
|
|
} else if (key.EqualsLiteral("product")) {
|
|
|
|
aDriverInfo.mProduct = dataValue;
|
|
|
|
} else if (key.EqualsLiteral("manufacturer")) {
|
|
|
|
aDriverInfo.mManufacturer = dataValue;
|
|
|
|
} else if (key.EqualsLiteral("hardware")) {
|
|
|
|
aDriverInfo.mHardware = dataValue;
|
|
|
|
} else if (key.EqualsLiteral("versionRange")) {
|
|
|
|
nsTArray<nsCString> versionRange;
|
|
|
|
ParseString(value, ',', versionRange);
|
|
|
|
if (versionRange.Length() != 2) {
|
|
|
|
gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
|
|
|
|
<< "Unrecognized versionRange " << value.get();
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-02 19:58:10 +03:00
|
|
|
const nsCString& minValue = versionRange[0];
|
|
|
|
const nsCString& maxValue = versionRange[1];
|
2016-05-04 17:12:19 +03:00
|
|
|
|
|
|
|
mozilla::Version minV(minValue.get());
|
|
|
|
mozilla::Version maxV(maxValue.get());
|
|
|
|
|
|
|
|
if (minV > zeroV && !(appV >= minV)) {
|
2015-05-15 17:42:10 +03:00
|
|
|
// The version of the application is less than the minimal version
|
|
|
|
// this blocklist entry applies to, so we can just ignore it by
|
|
|
|
// returning false and letting the caller deal with it.
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-04 17:12:19 +03:00
|
|
|
if (maxV > zeroV && !(appV <= maxV)) {
|
2015-05-15 17:42:10 +03:00
|
|
|
// The version of the application is more than the maximal version
|
|
|
|
// this blocklist entry applies to, so we can just ignore it by
|
|
|
|
// returning false and letting the caller deal with it.
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-04 17:12:19 +03:00
|
|
|
} else if (key.EqualsLiteral("devices")) {
|
|
|
|
nsTArray<nsCString> devices;
|
|
|
|
ParseString(value, ',', devices);
|
2020-06-23 18:20:33 +03:00
|
|
|
GfxDeviceFamily* deviceIds = BlocklistDevicesToDeviceFamily(devices);
|
2016-05-04 17:12:19 +03:00
|
|
|
if (deviceIds) {
|
|
|
|
// Get GfxDriverInfo to adopt the devices array we created.
|
|
|
|
aDriverInfo.mDeleteDevices = true;
|
|
|
|
aDriverInfo.mDevices = deviceIds;
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-04 17:12:19 +03:00
|
|
|
// We explicitly ignore unknown elements.
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::Observe(nsISupports* aSubject, const char* aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aData) {
|
2011-01-20 04:33:51 +03:00
|
|
|
if (strcmp(aTopic, "blocklist-data-gfxItems") == 0) {
|
2016-05-04 17:12:19 +03:00
|
|
|
nsTArray<GfxDriverInfo> driverInfo;
|
2020-09-02 20:04:51 +03:00
|
|
|
NS_ConvertUTF16toUTF8 utf8Data(aData);
|
2020-12-17 15:36:47 +03:00
|
|
|
|
|
|
|
for (const auto& blocklistEntry : utf8Data.Split('\n')) {
|
|
|
|
GfxDriverInfo di;
|
|
|
|
if (BlocklistEntryToDriverInfo(blocklistEntry, di)) {
|
|
|
|
// XXX Changing this to driverInfo.AppendElement(di) causes leaks.
|
|
|
|
// Probably some non-standard semantics of the copy/move operations?
|
|
|
|
*driverInfo.AppendElement() = di;
|
|
|
|
// Prevent di falling out of scope from destroying the devices.
|
|
|
|
di.mDeleteDevices = false;
|
|
|
|
} else {
|
|
|
|
driverInfo.AppendElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
EvaluateDownloadedBlocklist(driverInfo);
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
GfxInfoBase::GfxInfoBase() : mScreenPixels(INT64_MAX), mMutex("GfxInfoBase") {}
|
2011-01-20 04:33:51 +03:00
|
|
|
|
2020-03-16 13:56:57 +03:00
|
|
|
GfxInfoBase::~GfxInfoBase() = default;
|
2011-01-20 04:33:51 +03:00
|
|
|
|
|
|
|
nsresult GfxInfoBase::Init() {
|
2011-12-15 09:03:01 +04:00
|
|
|
InitGfxDriverInfoShutdownObserver();
|
|
|
|
|
2011-01-20 04:33:51 +03:00
|
|
|
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
|
|
|
if (os) {
|
2011-10-17 18:59:28 +04:00
|
|
|
os->AddObserver(this, "blocklist-data-gfxItems", true);
|
2011-01-20 04:33:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
void GfxInfoBase::GetData() {
|
|
|
|
if (mScreenPixels != INT64_MAX) {
|
|
|
|
// Already initialized.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScreenManager> manager =
|
|
|
|
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
|
|
|
if (!manager) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("failed to get nsIScreenManager");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
manager->GetTotalScreenPixels(&mScreenPixels);
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
NS_IMETHODIMP
|
2016-04-14 00:12:47 +03:00
|
|
|
GfxInfoBase::GetFeatureStatus(int32_t aFeature, nsACString& aFailureId,
|
|
|
|
int32_t* aStatus) {
|
2019-07-11 01:32:19 +03:00
|
|
|
// Ignore the gfx.blocklist.all pref on release and beta.
|
|
|
|
#if defined(RELEASE_OR_BETA)
|
|
|
|
int32_t blocklistAll = 0;
|
|
|
|
#else
|
2019-07-22 05:10:14 +03:00
|
|
|
int32_t blocklistAll = StaticPrefs::gfx_blocklist_all_AtStartup();
|
2019-07-11 01:32:19 +03:00
|
|
|
#endif
|
2015-05-28 18:54:07 +03:00
|
|
|
if (blocklistAll > 0) {
|
|
|
|
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false))
|
|
|
|
<< "Forcing blocklisting all features";
|
|
|
|
*aStatus = FEATURE_BLOCKED_DEVICE;
|
2016-04-14 00:12:47 +03:00
|
|
|
aFailureId = "FEATURE_FAILURE_BLOCK_ALL";
|
2015-05-28 18:54:07 +03:00
|
|
|
return NS_OK;
|
|
|
|
} else if (blocklistAll < 0) {
|
|
|
|
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false))
|
|
|
|
<< "Ignoring any feature blocklisting.";
|
|
|
|
*aStatus = FEATURE_STATUS_OK;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-14 00:12:47 +03:00
|
|
|
if (GetPrefValueForFeature(aFeature, *aStatus, aFailureId)) {
|
2011-01-20 04:30:15 +03:00
|
|
|
return NS_OK;
|
2016-04-14 00:12:47 +03:00
|
|
|
}
|
2011-01-20 04:30:15 +03:00
|
|
|
|
2020-08-08 00:31:53 +03:00
|
|
|
if (XRE_IsContentProcess() || XRE_IsGPUProcess()) {
|
2017-01-17 07:05:46 +03:00
|
|
|
// Use the cached data received from the parent process.
|
2018-05-14 18:16:50 +03:00
|
|
|
MOZ_ASSERT(sFeatureStatus);
|
2017-01-17 07:05:46 +03:00
|
|
|
bool success = false;
|
2018-05-14 18:16:50 +03:00
|
|
|
for (const auto& fs : *sFeatureStatus) {
|
2017-01-17 07:05:46 +03:00
|
|
|
if (fs.feature() == aFeature) {
|
|
|
|
aFailureId = fs.failureId();
|
|
|
|
*aStatus = fs.status();
|
|
|
|
success = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success ? NS_OK : NS_ERROR_FAILURE;
|
2014-01-11 05:09:20 +04:00
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
nsString version;
|
2011-12-15 09:02:59 +04:00
|
|
|
nsTArray<GfxDriverInfo> driverInfo;
|
2016-04-14 00:12:47 +03:00
|
|
|
nsresult rv =
|
|
|
|
GetFeatureStatusImpl(aFeature, aStatus, version, driverInfo, aFailureId);
|
|
|
|
return rv;
|
2011-01-20 04:30:12 +03:00
|
|
|
}
|
|
|
|
|
2020-08-08 00:31:53 +03:00
|
|
|
nsTArray<gfx::GfxInfoFeatureStatus> GfxInfoBase::GetAllFeatures() {
|
2019-11-09 05:21:18 +03:00
|
|
|
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
|
|
|
|
if (!sFeatureStatus) {
|
2020-08-08 00:38:18 +03:00
|
|
|
InitFeatureStatus(new nsTArray<gfx::GfxInfoFeatureStatus>());
|
2019-11-09 05:21:18 +03:00
|
|
|
for (int32_t i = 1; i <= nsIGfxInfo::FEATURE_MAX_VALUE; ++i) {
|
|
|
|
int32_t status = 0;
|
|
|
|
nsAutoCString failureId;
|
|
|
|
GetFeatureStatus(i, failureId, &status);
|
2020-08-08 00:31:48 +03:00
|
|
|
gfx::GfxInfoFeatureStatus gfxFeatureStatus;
|
2019-11-09 05:21:18 +03:00
|
|
|
gfxFeatureStatus.feature() = i;
|
|
|
|
gfxFeatureStatus.status() = status;
|
|
|
|
gfxFeatureStatus.failureId() = failureId;
|
|
|
|
sFeatureStatus->AppendElement(gfxFeatureStatus);
|
|
|
|
}
|
|
|
|
}
|
2020-08-08 00:31:53 +03:00
|
|
|
|
|
|
|
nsTArray<gfx::GfxInfoFeatureStatus> features;
|
2019-11-09 05:21:18 +03:00
|
|
|
for (const auto& status : *sFeatureStatus) {
|
2020-08-08 00:31:48 +03:00
|
|
|
gfx::GfxInfoFeatureStatus copy = status;
|
2020-08-08 00:31:53 +03:00
|
|
|
features.AppendElement(copy);
|
2019-11-09 05:21:18 +03:00
|
|
|
}
|
2020-08-08 00:31:53 +03:00
|
|
|
return features;
|
2019-11-09 05:21:18 +03:00
|
|
|
}
|
|
|
|
|
2020-02-13 19:06:41 +03:00
|
|
|
inline bool MatchingAllowStatus(int32_t aStatus) {
|
|
|
|
switch (aStatus) {
|
|
|
|
case nsIGfxInfo::FEATURE_ALLOW_ALWAYS:
|
|
|
|
case nsIGfxInfo::FEATURE_ALLOW_QUALIFIED:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 23:13:08 +03:00
|
|
|
// Matching OS go somewhat beyond the simple equality check because of the
|
|
|
|
// "All Windows" and "All OS X" variations.
|
|
|
|
//
|
|
|
|
// aBlockedOS is describing the system(s) we are trying to block.
|
|
|
|
// aSystemOS is describing the system we are running on.
|
|
|
|
//
|
|
|
|
// aSystemOS should not be "Windows" or "OSX" - it should be set to
|
|
|
|
// a particular version instead.
|
|
|
|
// However, it is valid for aBlockedOS to be one of those generic values,
|
|
|
|
// as we could be blocking all of the versions.
|
|
|
|
inline bool MatchingOperatingSystems(OperatingSystem aBlockedOS,
|
2020-02-13 18:51:32 +03:00
|
|
|
OperatingSystem aSystemOS,
|
|
|
|
uint32_t aSystemOSBuild) {
|
2016-06-03 23:13:08 +03:00
|
|
|
MOZ_ASSERT(aSystemOS != OperatingSystem::Windows &&
|
|
|
|
aSystemOS != OperatingSystem::OSX);
|
|
|
|
|
|
|
|
// If the block entry OS is unknown, it doesn't match
|
|
|
|
if (aBlockedOS == OperatingSystem::Unknown) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
if (aBlockedOS == OperatingSystem::Windows) {
|
|
|
|
// We do want even "unknown" aSystemOS to fall under "all windows"
|
|
|
|
return true;
|
|
|
|
}
|
2020-02-13 18:51:32 +03:00
|
|
|
|
|
|
|
constexpr uint32_t kMinWin10BuildNumber = 18362;
|
2020-03-25 17:12:56 +03:00
|
|
|
if (aBlockedOS == OperatingSystem::RecentWindows10 &&
|
2020-02-13 18:51:32 +03:00
|
|
|
aSystemOS == OperatingSystem::Windows10) {
|
|
|
|
// For allowlist purposes, we sometimes want to restrict to only recent
|
|
|
|
// versions of Windows 10. This is a bit of a kludge but easier than adding
|
|
|
|
// complicated blocklist infrastructure for build ID comparisons like driver
|
|
|
|
// versions.
|
|
|
|
return aSystemOSBuild >= kMinWin10BuildNumber;
|
|
|
|
}
|
2020-03-13 18:43:46 +03:00
|
|
|
|
|
|
|
if (aBlockedOS == OperatingSystem::NotRecentWindows10) {
|
|
|
|
if (aSystemOS == OperatingSystem::Windows10) {
|
|
|
|
return aSystemOSBuild < kMinWin10BuildNumber;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-06-03 23:13:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
if (aBlockedOS == OperatingSystem::OSX) {
|
|
|
|
// We do want even "unknown" aSystemOS to fall under "all OS X"
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return aSystemOS == aBlockedOS;
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
inline bool MatchingBattery(BatteryStatus aBatteryStatus, bool aHasBattery) {
|
|
|
|
switch (aBatteryStatus) {
|
|
|
|
case BatteryStatus::All:
|
|
|
|
return true;
|
|
|
|
case BatteryStatus::None:
|
|
|
|
return !aHasBattery;
|
|
|
|
case BatteryStatus::Present:
|
|
|
|
return aHasBattery;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT_UNREACHABLE("bad battery status");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool MatchingScreenSize(ScreenSizeStatus aScreenStatus,
|
|
|
|
int64_t aScreenPixels) {
|
|
|
|
constexpr int64_t kMaxSmallPixels = 2304000; // 1920x1200
|
|
|
|
constexpr int64_t kMaxMediumPixels = 4953600; // 3440x1440
|
|
|
|
|
|
|
|
switch (aScreenStatus) {
|
|
|
|
case ScreenSizeStatus::All:
|
|
|
|
return true;
|
|
|
|
case ScreenSizeStatus::Small:
|
|
|
|
return aScreenPixels <= kMaxSmallPixels;
|
|
|
|
case ScreenSizeStatus::SmallAndMedium:
|
|
|
|
return aScreenPixels <= kMaxMediumPixels;
|
|
|
|
case ScreenSizeStatus::Medium:
|
|
|
|
return aScreenPixels > kMaxSmallPixels &&
|
|
|
|
aScreenPixels <= kMaxMediumPixels;
|
|
|
|
case ScreenSizeStatus::MediumAndLarge:
|
|
|
|
return aScreenPixels > kMaxSmallPixels;
|
|
|
|
case ScreenSizeStatus::Large:
|
|
|
|
return aScreenPixels > kMaxMediumPixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT_UNREACHABLE("bad screen status");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
int32_t GfxInfoBase::FindBlocklistedDeviceInList(
|
|
|
|
const nsTArray<GfxDriverInfo>& info, nsAString& aSuggestedVersion,
|
2020-02-13 19:06:41 +03:00
|
|
|
int32_t aFeature, nsACString& aFailureId, OperatingSystem os,
|
|
|
|
bool aForAllowing) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
|
2011-11-03 18:50:40 +04:00
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
// Some properties are not available on all platforms.
|
2020-02-10 17:21:30 +03:00
|
|
|
nsAutoString desktopEnvironment;
|
|
|
|
nsresult rv = GetDesktopEnvironment(desktopEnvironment);
|
|
|
|
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_IMPLEMENTED) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString windowProtocol;
|
|
|
|
rv = GetWindowProtocol(windowProtocol);
|
|
|
|
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_IMPLEMENTED) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
bool hasBattery = false;
|
|
|
|
rv = GetHasBattery(&hasBattery);
|
|
|
|
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_IMPLEMENTED) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-25 17:12:56 +03:00
|
|
|
uint32_t osBuild = OperatingSystemBuild();
|
2020-02-13 18:51:32 +03:00
|
|
|
|
2016-12-20 19:43:45 +03:00
|
|
|
// Get the adapters once then reuse below
|
|
|
|
nsAutoString adapterVendorID[2];
|
|
|
|
nsAutoString adapterDeviceID[2];
|
2019-04-30 23:29:18 +03:00
|
|
|
nsAutoString adapterDriverVendor[2];
|
2016-12-20 19:43:45 +03:00
|
|
|
nsAutoString adapterDriverVersionString[2];
|
|
|
|
bool adapterInfoFailed[2];
|
|
|
|
|
|
|
|
adapterInfoFailed[0] =
|
|
|
|
(NS_FAILED(GetAdapterVendorID(adapterVendorID[0])) ||
|
|
|
|
NS_FAILED(GetAdapterDeviceID(adapterDeviceID[0])) ||
|
2019-04-30 23:29:18 +03:00
|
|
|
NS_FAILED(GetAdapterDriverVendor(adapterDriverVendor[0])) ||
|
2016-12-20 19:43:45 +03:00
|
|
|
NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString[0])));
|
|
|
|
adapterInfoFailed[1] =
|
|
|
|
(NS_FAILED(GetAdapterVendorID2(adapterVendorID[1])) ||
|
|
|
|
NS_FAILED(GetAdapterDeviceID2(adapterDeviceID[1])) ||
|
2019-04-30 23:29:18 +03:00
|
|
|
NS_FAILED(GetAdapterDriverVendor2(adapterDriverVendor[1])) ||
|
2016-12-20 19:43:45 +03:00
|
|
|
NS_FAILED(GetAdapterDriverVersion2(adapterDriverVersionString[1])));
|
|
|
|
// No point in going on if we don't have adapter info
|
|
|
|
if (adapterInfoFailed[0] && adapterInfoFailed[1]) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:36:08 +03:00
|
|
|
#if defined(XP_WIN) || defined(ANDROID) || defined(MOZ_X11)
|
2016-12-20 19:43:45 +03:00
|
|
|
uint64_t driverVersion[2] = {0, 0};
|
|
|
|
if (!adapterInfoFailed[0]) {
|
|
|
|
ParseDriverVersion(adapterDriverVersionString[0], &driverVersion[0]);
|
|
|
|
}
|
|
|
|
if (!adapterInfoFailed[1]) {
|
|
|
|
ParseDriverVersion(adapterDriverVersionString[1], &driverVersion[1]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 22:37:00 +03:00
|
|
|
uint32_t i = 0;
|
|
|
|
for (; i < info.Length(); i++) {
|
2020-02-13 19:06:41 +03:00
|
|
|
// If the status is FEATURE_ALLOW_*, then it is for the allowlist, not
|
|
|
|
// blocklisting. Only consider entries for our search mode.
|
|
|
|
if (MatchingAllowStatus(info[i].mFeatureStatus) != aForAllowing) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-12-20 19:43:45 +03:00
|
|
|
// If we don't have the info for this GPU, no need to check further.
|
|
|
|
// It is unclear that we would ever have a mixture of 1st and 2nd
|
|
|
|
// GPU, but leaving the code in for that possibility for now.
|
|
|
|
// (Actually, currently mGpu2 will never be true, so this can
|
|
|
|
// be optimized out.)
|
|
|
|
uint32_t infoIndex = info[i].mGpu2 ? 1 : 0;
|
|
|
|
if (adapterInfoFailed[infoIndex]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-05-15 17:42:10 +03:00
|
|
|
// Do the operating system check first, no point in getting the driver
|
2016-06-03 23:13:08 +03:00
|
|
|
// info if we won't need to use it.
|
2020-02-13 18:51:32 +03:00
|
|
|
if (!MatchingOperatingSystems(info[i].mOperatingSystem, os, osBuild)) {
|
2015-05-15 17:42:10 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info[i].mOperatingSystemVersion &&
|
|
|
|
info[i].mOperatingSystemVersion != OperatingSystemVersion()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
if (!MatchingBattery(info[i].mBattery, hasBattery)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!MatchingScreenSize(info[i].mScreen, mScreenPixels)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-02-10 17:21:30 +03:00
|
|
|
if (!DoesDesktopEnvironmentMatch(info[i].mDesktopEnvironment,
|
|
|
|
desktopEnvironment)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DoesWindowProtocolMatch(info[i].mWindowProtocol, windowProtocol)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:36:08 +03:00
|
|
|
if (!DoesVendorMatch(info[i].mAdapterVendor, adapterVendorID[infoIndex])) {
|
2011-11-03 18:50:40 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-04-30 23:29:18 +03:00
|
|
|
if (!DoesDriverVendorMatch(info[i].mDriverVendor,
|
|
|
|
adapterDriverVendor[infoIndex])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-02-14 01:39:10 +03:00
|
|
|
if (info[i].mDevices && !info[i].mDevices->IsEmpty()) {
|
2020-02-13 18:51:40 +03:00
|
|
|
nsresult rv = info[i].mDevices->Contains(adapterDeviceID[infoIndex]);
|
|
|
|
if (rv == NS_ERROR_NOT_AVAILABLE) {
|
|
|
|
// Not found
|
2020-02-13 15:35:26 +03:00
|
|
|
continue;
|
2020-02-12 01:36:41 +03:00
|
|
|
}
|
2020-02-13 18:51:40 +03:00
|
|
|
if (rv != NS_OK) {
|
|
|
|
// Failed to search, allowlist should not match, blocklist should match
|
|
|
|
// for safety reasons
|
|
|
|
if (aForAllowing) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-11-03 18:50:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool match = false;
|
|
|
|
|
2012-11-02 01:13:10 +04:00
|
|
|
if (!info[i].mHardware.IsEmpty() && !info[i].mHardware.Equals(Hardware())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!info[i].mModel.IsEmpty() && !info[i].mModel.Equals(Model())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!info[i].mProduct.IsEmpty() && !info[i].mProduct.Equals(Product())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!info[i].mManufacturer.IsEmpty() &&
|
|
|
|
!info[i].mManufacturer.Equals(Manufacturer())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:36:08 +03:00
|
|
|
#if defined(XP_WIN) || defined(ANDROID) || defined(MOZ_X11)
|
2011-12-15 09:02:59 +04:00
|
|
|
switch (info[i].mComparisonOp) {
|
2011-11-03 18:50:40 +04:00
|
|
|
case DRIVER_LESS_THAN:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] < info[i].mDriverVersion;
|
2016-08-08 09:35:00 +03:00
|
|
|
break;
|
|
|
|
case DRIVER_BUILD_ID_LESS_THAN:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = (driverVersion[infoIndex] & 0xFFFF) < info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_LESS_THAN_OR_EQUAL:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] <= info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
2016-08-31 20:59:00 +03:00
|
|
|
case DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = (driverVersion[infoIndex] & 0xFFFF) <= info[i].mDriverVersion;
|
2016-08-31 20:59:00 +03:00
|
|
|
break;
|
2011-11-03 18:50:40 +04:00
|
|
|
case DRIVER_GREATER_THAN:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] > info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_GREATER_THAN_OR_EQUAL:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] >= info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_EQUAL:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] == info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_NOT_EQUAL:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] != info[i].mDriverVersion;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_BETWEEN_EXCLUSIVE:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] > info[i].mDriverVersion &&
|
|
|
|
driverVersion[infoIndex] < info[i].mDriverVersionMax;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_BETWEEN_INCLUSIVE:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] >= info[i].mDriverVersion &&
|
|
|
|
driverVersion[infoIndex] <= info[i].mDriverVersionMax;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
case DRIVER_BETWEEN_INCLUSIVE_START:
|
2016-12-20 19:43:45 +03:00
|
|
|
match = driverVersion[infoIndex] >= info[i].mDriverVersion &&
|
|
|
|
driverVersion[infoIndex] < info[i].mDriverVersionMax;
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
2012-05-04 23:33:59 +04:00
|
|
|
case DRIVER_COMPARISON_IGNORED:
|
|
|
|
// We don't have a comparison op, so we match everything.
|
|
|
|
match = true;
|
|
|
|
break;
|
2011-11-03 18:50:40 +04:00
|
|
|
default:
|
|
|
|
NS_WARNING("Bogus op in GfxDriverInfo");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
// We don't care what driver version it was. We only check OS version and if
|
|
|
|
// the device matches.
|
|
|
|
match = true;
|
|
|
|
#endif
|
|
|
|
|
2011-12-15 09:03:03 +04:00
|
|
|
if (match || info[i].mDriverVersion == GfxDriverInfo::allDriverVersions) {
|
2020-12-17 00:32:28 +03:00
|
|
|
if ((info[i].mFeature == GfxDriverInfo::allFeatures &&
|
|
|
|
aFeature != nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE) ||
|
2011-12-15 09:02:59 +04:00
|
|
|
info[i].mFeature == aFeature) {
|
|
|
|
status = info[i].mFeatureStatus;
|
2016-04-14 00:12:47 +03:00
|
|
|
if (!info[i].mRuleId.IsEmpty()) {
|
|
|
|
aFailureId = info[i].mRuleId.get();
|
|
|
|
} else {
|
2020-06-23 18:23:11 +03:00
|
|
|
aFailureId = "FEATURE_FAILURE_DL_BLOCKLIST_NO_ID";
|
2016-04-14 00:12:47 +03:00
|
|
|
}
|
2011-11-03 18:50:40 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 08:25:13 +04:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
// As a very special case, we block D2D on machines with an NVidia 310M GPU
|
|
|
|
// as either the primary or secondary adapter. D2D is also blocked when the
|
|
|
|
// NV 310M is the primary adapter (using the standard blocklisting mechanism).
|
|
|
|
// If the primary GPU already matched something in the blocklist then we
|
|
|
|
// ignore this special rule. See bug 1008759.
|
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN &&
|
|
|
|
(aFeature == nsIGfxInfo::FEATURE_DIRECT2D)) {
|
2016-12-20 19:43:45 +03:00
|
|
|
if (!adapterInfoFailed[1]) {
|
2014-08-13 08:25:13 +04:00
|
|
|
nsAString& nvVendorID =
|
2020-02-14 01:39:10 +03:00
|
|
|
(nsAString&)GfxDriverInfo::GetDeviceVendor(DeviceVendor::NVIDIA);
|
2014-08-13 08:25:13 +04:00
|
|
|
const nsString nv310mDeviceId = u"0x0A70"_ns;
|
2016-12-20 19:43:45 +03:00
|
|
|
if (nvVendorID.Equals(adapterVendorID[1],
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator) &&
|
2016-12-20 19:43:45 +03:00
|
|
|
nv310mDeviceId.Equals(adapterDeviceID[1],
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator)) {
|
2014-08-13 08:25:13 +04:00
|
|
|
status = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
|
2016-04-14 00:12:47 +03:00
|
|
|
aFailureId = "FEATURE_FAILURE_D2D_NV310M_BLOCK";
|
2014-08-13 08:25:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-03 18:50:40 +04:00
|
|
|
// Depends on Windows driver versioning. We don't pass a GfxDriverInfo object
|
|
|
|
// back to the Windows handler, so we must handle this here.
|
|
|
|
if (status == FEATURE_BLOCKED_DRIVER_VERSION) {
|
2011-12-15 09:02:59 +04:00
|
|
|
if (info[i].mSuggestedVersion) {
|
|
|
|
aSuggestedVersion.AppendPrintf("%s", info[i].mSuggestedVersion);
|
|
|
|
} else if (info[i].mComparisonOp == DRIVER_LESS_THAN &&
|
|
|
|
info[i].mDriverVersion != GfxDriverInfo::allDriverVersions) {
|
|
|
|
aSuggestedVersion.AppendPrintf(
|
|
|
|
"%lld.%lld.%lld.%lld",
|
|
|
|
(info[i].mDriverVersion & 0xffff000000000000) >> 48,
|
|
|
|
(info[i].mDriverVersion & 0x0000ffff00000000) >> 32,
|
|
|
|
(info[i].mDriverVersion & 0x00000000ffff0000) >> 16,
|
|
|
|
(info[i].mDriverVersion & 0x000000000000ffff));
|
2011-11-03 18:50:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2020-08-08 00:31:53 +03:00
|
|
|
void GfxInfoBase::SetFeatureStatus(nsTArray<gfx::GfxInfoFeatureStatus>&& aFS) {
|
2018-05-14 18:16:50 +03:00
|
|
|
MOZ_ASSERT(!sFeatureStatus);
|
2020-08-08 00:31:53 +03:00
|
|
|
InitFeatureStatus(new nsTArray<gfx::GfxInfoFeatureStatus>(std::move(aFS)));
|
2017-01-17 07:05:46 +03:00
|
|
|
}
|
|
|
|
|
2020-02-10 17:21:30 +03:00
|
|
|
bool GfxInfoBase::DoesDesktopEnvironmentMatch(
|
|
|
|
const nsAString& aBlocklistDesktop, const nsAString& aDesktopEnv) {
|
|
|
|
return aBlocklistDesktop.Equals(aDesktopEnv,
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator) ||
|
2020-02-10 17:21:30 +03:00
|
|
|
aBlocklistDesktop.Equals(
|
2020-02-14 01:39:10 +03:00
|
|
|
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::All),
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator);
|
2020-02-10 17:21:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GfxInfoBase::DoesWindowProtocolMatch(
|
|
|
|
const nsAString& aBlocklistWindowProtocol,
|
|
|
|
const nsAString& aWindowProtocol) {
|
|
|
|
return aBlocklistWindowProtocol.Equals(aWindowProtocol,
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator) ||
|
2020-02-10 17:21:30 +03:00
|
|
|
aBlocklistWindowProtocol.Equals(
|
2020-02-14 01:39:10 +03:00
|
|
|
GfxDriverInfo::GetWindowProtocol(WindowProtocol::All),
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator);
|
2020-02-10 17:21:30 +03:00
|
|
|
}
|
|
|
|
|
2019-02-08 22:36:08 +03:00
|
|
|
bool GfxInfoBase::DoesVendorMatch(const nsAString& aBlocklistVendor,
|
|
|
|
const nsAString& aAdapterVendor) {
|
|
|
|
return aBlocklistVendor.Equals(aAdapterVendor,
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator) ||
|
2020-02-14 01:39:10 +03:00
|
|
|
aBlocklistVendor.Equals(
|
|
|
|
GfxDriverInfo::GetDeviceVendor(DeviceVendor::All),
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator);
|
2019-02-08 22:36:08 +03:00
|
|
|
}
|
|
|
|
|
2019-04-30 23:29:18 +03:00
|
|
|
bool GfxInfoBase::DoesDriverVendorMatch(const nsAString& aBlocklistVendor,
|
|
|
|
const nsAString& aDriverVendor) {
|
|
|
|
return aBlocklistVendor.Equals(aDriverVendor,
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator) ||
|
2019-04-30 23:29:18 +03:00
|
|
|
aBlocklistVendor.Equals(
|
2020-02-14 01:39:10 +03:00
|
|
|
GfxDriverInfo::GetDriverVendor(DriverVendor::All),
|
2020-05-27 21:11:12 +03:00
|
|
|
nsCaseInsensitiveStringComparator);
|
2019-04-30 23:29:18 +03:00
|
|
|
}
|
|
|
|
|
2020-02-18 16:56:10 +03:00
|
|
|
bool GfxInfoBase::IsFeatureAllowlisted(int32_t aFeature) const {
|
2020-11-11 02:36:43 +03:00
|
|
|
return aFeature == nsIGfxInfo::FEATURE_WEBRENDER ||
|
|
|
|
aFeature == nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE;
|
2020-02-18 16:56:10 +03:00
|
|
|
}
|
2020-02-13 19:06:41 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult GfxInfoBase::GetFeatureStatusImpl(
|
2011-12-15 09:02:59 +04:00
|
|
|
int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedVersion,
|
|
|
|
const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId,
|
2012-07-30 18:20:58 +04:00
|
|
|
OperatingSystem* aOS /* = nullptr */) {
|
2015-05-15 19:55:53 +03:00
|
|
|
if (aFeature <= 0) {
|
|
|
|
gfxWarning() << "Invalid feature <= 0";
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
if (*aStatus != nsIGfxInfo::FEATURE_STATUS_UNKNOWN) {
|
|
|
|
// Terminate now with the status determined by the derived type (OS-specific
|
|
|
|
// code).
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-05-14 18:16:50 +03:00
|
|
|
if (sShutdownOccurred) {
|
2016-10-27 18:04:50 +03:00
|
|
|
// This is futile; we've already commenced shutdown and our blocklists have
|
|
|
|
// been deleted. We may want to look into resurrecting the blocklist instead
|
|
|
|
// but for now, just don't even go there.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-02-13 18:51:32 +03:00
|
|
|
// Ensure any additional initialization required is complete.
|
|
|
|
GetData();
|
|
|
|
|
2011-12-15 09:02:59 +04:00
|
|
|
// If an operating system was provided by the derived GetFeatureStatusImpl,
|
|
|
|
// grab it here. Otherwise, the OS is unknown.
|
2016-06-03 23:13:08 +03:00
|
|
|
OperatingSystem os = (aOS ? *aOS : OperatingSystem::Unknown);
|
2011-12-15 09:02:59 +04:00
|
|
|
|
2011-12-15 09:03:01 +04:00
|
|
|
nsAutoString adapterVendorID;
|
|
|
|
nsAutoString adapterDeviceID;
|
2011-12-15 09:02:59 +04:00
|
|
|
nsAutoString adapterDriverVersionString;
|
2011-12-15 09:03:01 +04:00
|
|
|
if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) ||
|
|
|
|
NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) ||
|
2011-12-15 09:02:59 +04:00
|
|
|
NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) {
|
2016-04-14 00:12:47 +03:00
|
|
|
aFailureId = "FEATURE_FAILURE_CANT_RESOLVE_ADAPTER";
|
2016-05-12 00:08:49 +03:00
|
|
|
*aStatus = FEATURE_BLOCKED_DEVICE;
|
2011-12-15 09:02:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the device is blocked from the downloaded blocklist. If not, check
|
|
|
|
// the static list after that. This order is used so that we can later escape
|
|
|
|
// out of static blocks (i.e. if we were wrong or something was patched, we
|
|
|
|
// can back out our static block without doing a release).
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status;
|
2011-12-15 09:03:01 +04:00
|
|
|
if (aDriverInfo.Length()) {
|
2020-02-13 19:06:41 +03:00
|
|
|
status =
|
|
|
|
FindBlocklistedDeviceInList(aDriverInfo, aSuggestedVersion, aFeature,
|
|
|
|
aFailureId, os, /* aForAllowing */ false);
|
2011-12-15 09:03:01 +04:00
|
|
|
} else {
|
2018-05-14 18:16:50 +03:00
|
|
|
if (!sDriverInfo) {
|
|
|
|
sDriverInfo = new nsTArray<GfxDriverInfo>();
|
2011-12-15 09:03:01 +04:00
|
|
|
}
|
2016-04-14 00:12:47 +03:00
|
|
|
status = FindBlocklistedDeviceInList(GetGfxDriverInfo(), aSuggestedVersion,
|
2020-02-13 19:06:41 +03:00
|
|
|
aFeature, aFailureId, os,
|
|
|
|
/* aForAllowing */ false);
|
2011-12-15 09:02:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) {
|
2020-02-13 19:06:41 +03:00
|
|
|
if (IsFeatureAllowlisted(aFeature)) {
|
|
|
|
// This feature is actually using the allowlist; that means after we pass
|
|
|
|
// the blocklist to prevent us explicitly from getting the feature, we now
|
|
|
|
// need to check the allowlist to ensure we are allowed to get it in the
|
|
|
|
// first place.
|
|
|
|
if (aDriverInfo.Length()) {
|
|
|
|
status = FindBlocklistedDeviceInList(aDriverInfo, aSuggestedVersion,
|
|
|
|
aFeature, aFailureId, os,
|
|
|
|
/* aForAllowing */ true);
|
|
|
|
} else {
|
|
|
|
status = FindBlocklistedDeviceInList(
|
|
|
|
GetGfxDriverInfo(), aSuggestedVersion, aFeature, aFailureId, os,
|
|
|
|
/* aForAllowing */ true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) {
|
|
|
|
status = nsIGfxInfo::FEATURE_DENIED;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// It's now done being processed. It's safe to set the status to
|
|
|
|
// STATUS_OK.
|
|
|
|
status = nsIGfxInfo::FEATURE_STATUS_OK;
|
|
|
|
}
|
2011-12-15 09:02:59 +04:00
|
|
|
}
|
|
|
|
|
2020-02-13 19:06:41 +03:00
|
|
|
*aStatus = status;
|
2011-11-03 18:50:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-20 04:30:12 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
GfxInfoBase::GetFeatureSuggestedDriverVersion(int32_t aFeature,
|
2012-07-07 00:14:07 +04:00
|
|
|
nsAString& aVersion) {
|
2011-01-20 04:30:15 +03:00
|
|
|
nsCString version;
|
|
|
|
if (GetPrefValueForDriverVersion(version)) {
|
|
|
|
aVersion = NS_ConvertASCIItoUTF16(version);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status;
|
2016-04-14 00:12:47 +03:00
|
|
|
nsCString discardFailureId;
|
2011-12-15 09:02:59 +04:00
|
|
|
nsTArray<GfxDriverInfo> driverInfo;
|
2016-04-14 00:12:47 +03:00
|
|
|
return GetFeatureStatusImpl(aFeature, &status, aVersion, driverInfo,
|
|
|
|
discardFailureId);
|
2011-01-20 04:30:12 +03:00
|
|
|
}
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
void GfxInfoBase::EvaluateDownloadedBlocklist(
|
2011-01-20 04:35:51 +03:00
|
|
|
nsTArray<GfxDriverInfo>& aDriverInfo) {
|
|
|
|
int32_t features[] = {nsIGfxInfo::FEATURE_DIRECT2D,
|
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
|
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS,
|
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS,
|
2014-05-16 20:16:21 +04:00
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
|
2015-04-10 23:17:27 +03:00
|
|
|
nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE,
|
2015-04-01 06:06:56 +03:00
|
|
|
nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
|
2011-01-20 04:35:51 +03:00
|
|
|
nsIGfxInfo::FEATURE_OPENGL_LAYERS,
|
|
|
|
nsIGfxInfo::FEATURE_WEBGL_OPENGL,
|
|
|
|
nsIGfxInfo::FEATURE_WEBGL_ANGLE,
|
2015-07-24 22:45:55 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE,
|
|
|
|
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE,
|
2020-09-28 01:18:23 +03:00
|
|
|
nsIGfxInfo::UNUSED_FEATURE_WEBGL_MSAA,
|
2012-11-02 01:13:10 +04:00
|
|
|
nsIGfxInfo::FEATURE_STAGEFRIGHT,
|
2019-10-08 20:15:44 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_H264,
|
2016-02-19 16:39:00 +03:00
|
|
|
nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION,
|
2017-11-21 21:13:10 +03:00
|
|
|
nsIGfxInfo::FEATURE_VP8_HW_DECODE,
|
|
|
|
nsIGfxInfo::FEATURE_VP9_HW_DECODE,
|
|
|
|
nsIGfxInfo::FEATURE_DX_INTEROP2,
|
|
|
|
nsIGfxInfo::FEATURE_GPU_PROCESS,
|
2017-03-02 23:48:06 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBGL2,
|
2017-07-14 21:13:54 +03:00
|
|
|
nsIGfxInfo::FEATURE_ADVANCED_LAYERS,
|
2017-07-25 21:02:36 +03:00
|
|
|
nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX,
|
2018-05-03 13:02:00 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBRENDER,
|
2019-12-10 22:16:13 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR,
|
2020-11-11 02:36:43 +03:00
|
|
|
nsIGfxInfo::FEATURE_WEBRENDER_SOFTWARE,
|
2018-05-17 06:07:20 +03:00
|
|
|
nsIGfxInfo::FEATURE_DX_NV12,
|
2018-10-11 10:32:35 +03:00
|
|
|
nsIGfxInfo::FEATURE_DX_P010,
|
|
|
|
nsIGfxInfo::FEATURE_DX_P016,
|
2019-08-09 21:57:35 +03:00
|
|
|
nsIGfxInfo::FEATURE_GL_SWIZZLE,
|
2020-10-01 11:14:12 +03:00
|
|
|
nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS,
|
2011-01-20 04:35:51 +03:00
|
|
|
0};
|
|
|
|
|
2020-06-23 18:20:33 +03:00
|
|
|
// For every feature we know about, we evaluate whether this blocklist has a
|
2014-07-02 01:44:09 +04:00
|
|
|
// non-STATUS_OK status. If it does, we set the pref we evaluate in
|
2020-06-23 18:20:33 +03:00
|
|
|
// GetFeatureStatus above, so we don't need to hold on to this blocklist
|
2011-01-20 04:35:51 +03:00
|
|
|
// anywhere permanent.
|
|
|
|
int i = 0;
|
|
|
|
while (features[i]) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t status;
|
2016-04-14 00:12:47 +03:00
|
|
|
nsCString failureId;
|
2011-01-20 04:35:51 +03:00
|
|
|
nsAutoString suggestedVersion;
|
|
|
|
if (NS_SUCCEEDED(GetFeatureStatusImpl(
|
|
|
|
features[i], &status, suggestedVersion, aDriverInfo, failureId))) {
|
|
|
|
switch (status) {
|
|
|
|
default:
|
2014-07-02 01:44:09 +04:00
|
|
|
case nsIGfxInfo::FEATURE_STATUS_OK:
|
2011-01-20 04:35:51 +03:00
|
|
|
RemovePrefForFeature(features[i]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION:
|
|
|
|
if (!suggestedVersion.IsEmpty()) {
|
|
|
|
SetPrefValueForDriverVersion(suggestedVersion);
|
|
|
|
} else {
|
|
|
|
RemovePrefForDriverVersion();
|
|
|
|
}
|
2019-12-20 10:16:43 +03:00
|
|
|
[[fallthrough]];
|
2011-01-20 04:35:51 +03:00
|
|
|
|
2015-05-15 20:43:38 +03:00
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION:
|
2011-01-20 04:35:51 +03:00
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_DEVICE:
|
|
|
|
case nsIGfxInfo::FEATURE_DISCOURAGED:
|
|
|
|
case nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION:
|
2016-04-14 00:12:47 +03:00
|
|
|
SetPrefValueForFeature(features[i], status, failureId);
|
2011-01-20 04:35:51 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 22:44:48 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
|
|
|
GfxInfoBase::LogFailure(const nsACString& failure) {
|
2015-01-14 05:19:25 +03:00
|
|
|
// gfxCriticalError has a mutex lock of its own, so we may not actually
|
|
|
|
// need this lock. ::GetFailures() accesses the data but the LogForwarder
|
|
|
|
// will not return the copy of the logs unless it can get the same lock
|
|
|
|
// that gfxCriticalError uses. Still, that is so much of an implementation
|
|
|
|
// detail that it's nicer to just add an extra lock here and in
|
|
|
|
// ::GetFailures()
|
2013-02-25 18:07:16 +04:00
|
|
|
MutexAutoLock lock(mMutex);
|
2011-02-09 18:32:24 +03:00
|
|
|
|
2015-01-14 05:19:25 +03:00
|
|
|
// By default, gfxCriticalError asserts; make it not assert in this case.
|
|
|
|
gfxCriticalError(CriticalLog::DefaultOptions(false))
|
|
|
|
<< "(LF) " << failure.BeginReading();
|
2011-02-07 22:44:48 +03:00
|
|
|
}
|
|
|
|
|
2019-06-07 23:13:56 +03:00
|
|
|
NS_IMETHODIMP GfxInfoBase::GetFailures(nsTArray<int32_t>& indices,
|
|
|
|
nsTArray<nsCString>& failures) {
|
2015-01-14 05:19:25 +03:00
|
|
|
MutexAutoLock lock(mMutex);
|
2011-02-07 22:44:48 +03:00
|
|
|
|
2015-01-14 05:19:25 +03:00
|
|
|
LogForwarder* logForwarder = Factory::GetLogForwarder();
|
|
|
|
if (!logForwarder) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2019-06-07 23:13:56 +03:00
|
|
|
// There are two string copies in this method, starting with this one. We are
|
2015-01-14 05:19:25 +03:00
|
|
|
// assuming this is not a big deal, as the size of the array should be small
|
|
|
|
// and the strings in it should be small as well (the error messages in the
|
2019-06-07 23:13:56 +03:00
|
|
|
// code.) The second copy happens with the AppendElement() calls.
|
|
|
|
// Technically, we don't need the mutex lock after the StringVectorCopy()
|
|
|
|
// call.
|
2015-12-30 13:47:00 +03:00
|
|
|
LoggingRecord loggedStrings = logForwarder->LoggingRecordCopy();
|
2019-06-07 23:13:56 +03:00
|
|
|
LoggingRecord::const_iterator it;
|
|
|
|
for (it = loggedStrings.begin(); it != loggedStrings.end(); ++it) {
|
|
|
|
failures.AppendElement(
|
|
|
|
nsDependentCSubstring(Get<1>(*it).c_str(), Get<1>(*it).size()));
|
|
|
|
indices.AppendElement(Get<0>(*it));
|
2011-02-07 22:44:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-11-03 00:53:59 +04:00
|
|
|
|
|
|
|
nsTArray<GfxInfoCollectorBase*>* sCollectors;
|
|
|
|
|
|
|
|
static void InitCollectors() {
|
|
|
|
if (!sCollectors) sCollectors = new nsTArray<GfxInfoCollectorBase*>;
|
|
|
|
}
|
|
|
|
|
2014-01-09 21:39:36 +04:00
|
|
|
nsresult GfxInfoBase::GetInfo(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aResult) {
|
2011-11-03 00:53:59 +04:00
|
|
|
InitCollectors();
|
|
|
|
InfoObject obj(aCx);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < sCollectors->Length(); i++) {
|
2011-11-03 00:53:59 +04:00
|
|
|
(*sCollectors)[i]->GetInfo(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some example property definitions
|
|
|
|
// obj.DefineProperty("wordCacheSize", gfxTextRunWordCache::Count());
|
|
|
|
// obj.DefineProperty("renderer", mRendererIDsString);
|
|
|
|
// obj.DefineProperty("five", 5);
|
|
|
|
|
|
|
|
if (!obj.mOk) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-01-09 21:39:36 +04:00
|
|
|
aResult.setObject(*obj.mObj);
|
2011-11-03 00:53:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-03-14 12:27:00 +03:00
|
|
|
nsAutoCString gBaseAppVersion;
|
|
|
|
|
2015-05-15 17:42:10 +03:00
|
|
|
const nsCString& GfxInfoBase::GetApplicationVersion() {
|
|
|
|
static bool versionInitialized = false;
|
|
|
|
if (!versionInitialized) {
|
|
|
|
// If we fail to get the version, we will not try again.
|
|
|
|
versionInitialized = true;
|
|
|
|
|
|
|
|
// Get the version from xpcom/system/nsIXULAppInfo.idl
|
|
|
|
nsCOMPtr<nsIXULAppInfo> app = do_GetService("@mozilla.org/xre/app-info;1");
|
|
|
|
if (app) {
|
2016-03-14 12:27:00 +03:00
|
|
|
app->GetVersion(gBaseAppVersion);
|
2015-05-15 17:42:10 +03:00
|
|
|
}
|
|
|
|
}
|
2016-03-14 12:27:00 +03:00
|
|
|
return gBaseAppVersion;
|
2015-05-15 17:42:10 +03:00
|
|
|
}
|
|
|
|
|
2011-11-03 00:53:59 +04:00
|
|
|
void GfxInfoBase::AddCollector(GfxInfoCollectorBase* collector) {
|
|
|
|
InitCollectors();
|
|
|
|
sCollectors->AppendElement(collector);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfxInfoBase::RemoveCollector(GfxInfoCollectorBase* collector) {
|
|
|
|
InitCollectors();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < sCollectors->Length(); i++) {
|
2011-11-03 00:53:59 +04:00
|
|
|
if ((*sCollectors)[i] == collector) {
|
|
|
|
sCollectors->RemoveElementAt(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-18 08:00:38 +04:00
|
|
|
if (sCollectors->IsEmpty()) {
|
|
|
|
delete sCollectors;
|
2012-07-30 18:20:58 +04:00
|
|
|
sCollectors = nullptr;
|
2011-11-18 08:00:38 +04:00
|
|
|
}
|
2011-11-03 00:53:59 +04:00
|
|
|
}
|
|
|
|
|
2019-04-30 23:29:18 +03:00
|
|
|
nsresult GfxInfoBase::FindMonitors(JSContext* aCx, JS::HandleObject aOutArray) {
|
|
|
|
// If we have no platform specific implementation for detecting monitors, we
|
|
|
|
// can just get the screen size from gfxPlatform as the best guess.
|
|
|
|
if (!gfxPlatform::Initialized()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the screen size is empty, we are probably in xpcshell.
|
|
|
|
gfx::IntSize screenSize = gfxPlatform::GetPlatform()->GetScreenSize();
|
|
|
|
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> screenWidth(aCx, JS::Int32Value(screenSize.width));
|
|
|
|
JS_SetProperty(aCx, obj, "screenWidth", screenWidth);
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> screenHeight(aCx, JS::Int32Value(screenSize.height));
|
|
|
|
JS_SetProperty(aCx, obj, "screenHeight", screenHeight);
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> element(aCx, JS::ObjectValue(*obj));
|
|
|
|
JS_SetElement(aCx, aOutArray, 0, element);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-13 11:12:26 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetMonitors(JSContext* aCx, JS::MutableHandleValue aResult) {
|
2019-12-11 09:17:44 +03:00
|
|
|
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
2015-07-13 11:12:26 +03:00
|
|
|
|
|
|
|
nsresult rv = FindMonitors(aCx, array);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
aResult.setObject(*array);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-29 07:52:56 +03:00
|
|
|
static inline bool SetJSPropertyString(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aObj,
|
|
|
|
const char* aProp, const char* aString) {
|
|
|
|
JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, aString));
|
|
|
|
if (!str) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
|
|
|
|
return JS_SetProperty(aCx, aObj, aProp, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static inline bool AppendJSElement(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
|
|
|
const T& aValue) {
|
|
|
|
uint32_t index;
|
2019-12-11 09:17:44 +03:00
|
|
|
if (!JS::GetArrayLength(aCx, aObj, &index)) {
|
2016-04-29 07:52:56 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return JS_SetElement(aCx, aObj, index, aValue);
|
|
|
|
}
|
|
|
|
|
2015-07-20 00:50:35 +03:00
|
|
|
nsresult GfxInfoBase::GetFeatures(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aOut) {
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!obj) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aOut.setObject(*obj);
|
|
|
|
|
|
|
|
layers::LayersBackend backend =
|
|
|
|
gfxPlatform::Initialized()
|
|
|
|
? gfxPlatform::GetPlatform()->GetCompositorBackend()
|
|
|
|
: layers::LayersBackend::LAYERS_NONE;
|
2019-11-26 22:42:06 +03:00
|
|
|
const char* backendName = layers::GetLayersBackendName(backend);
|
2016-04-29 07:52:56 +03:00
|
|
|
SetJSPropertyString(aCx, obj, "compositor", backendName);
|
2015-07-20 00:50:35 +03:00
|
|
|
|
|
|
|
// If graphics isn't initialized yet, just stop now.
|
|
|
|
if (!gfxPlatform::Initialized()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DescribeFeatures(aCx, obj);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-29 07:52:56 +03:00
|
|
|
nsresult GfxInfoBase::GetFeatureLog(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aOut) {
|
|
|
|
JS::Rooted<JSObject*> containerObj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!containerObj) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aOut.setObject(*containerObj);
|
|
|
|
|
2019-12-11 09:17:44 +03:00
|
|
|
JS::Rooted<JSObject*> featureArray(aCx, JS::NewArrayObject(aCx, 0));
|
2016-04-29 07:52:56 +03:00
|
|
|
if (!featureArray) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collect features.
|
|
|
|
gfxConfig::ForEachFeature([&](const char* aName, const char* aDescription,
|
|
|
|
FeatureState& aFeature) -> void {
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!obj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!SetJSPropertyString(aCx, obj, "name", aName) ||
|
|
|
|
!SetJSPropertyString(aCx, obj, "description", aDescription) ||
|
|
|
|
!SetJSPropertyString(aCx, obj, "status",
|
|
|
|
FeatureStatusToString(aFeature.GetValue()))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> log(aCx);
|
|
|
|
if (!BuildFeatureStateLog(aCx, aFeature, &log)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!JS_SetProperty(aCx, obj, "log", log)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!AppendJSElement(aCx, featureArray, obj)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-11 09:17:44 +03:00
|
|
|
JS::Rooted<JSObject*> fallbackArray(aCx, JS::NewArrayObject(aCx, 0));
|
2016-04-29 07:52:56 +03:00
|
|
|
if (!fallbackArray) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collect fallbacks.
|
|
|
|
gfxConfig::ForEachFallback(
|
|
|
|
[&](const char* aName, const char* aMessage) -> void {
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!obj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetJSPropertyString(aCx, obj, "name", aName) ||
|
|
|
|
!SetJSPropertyString(aCx, obj, "message", aMessage)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!AppendJSElement(aCx, fallbackArray, obj)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> val(aCx);
|
|
|
|
|
|
|
|
val = JS::ObjectValue(*featureArray);
|
|
|
|
JS_SetProperty(aCx, containerObj, "features", val);
|
|
|
|
|
|
|
|
val = JS::ObjectValue(*fallbackArray);
|
|
|
|
JS_SetProperty(aCx, containerObj, "fallbacks", val);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GfxInfoBase::BuildFeatureStateLog(JSContext* aCx,
|
|
|
|
const FeatureState& aFeature,
|
|
|
|
JS::MutableHandle<JS::Value> aOut) {
|
2019-12-11 09:17:44 +03:00
|
|
|
JS::Rooted<JSObject*> log(aCx, JS::NewArrayObject(aCx, 0));
|
2016-04-29 07:52:56 +03:00
|
|
|
if (!log) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aOut.setObject(*log);
|
|
|
|
|
|
|
|
aFeature.ForEachStatusChange([&](const char* aType, FeatureStatus aStatus,
|
2020-09-25 17:11:52 +03:00
|
|
|
const char* aMessage,
|
|
|
|
const nsCString& aFailureId) -> void {
|
2016-04-29 07:52:56 +03:00
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!obj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetJSPropertyString(aCx, obj, "type", aType) ||
|
|
|
|
!SetJSPropertyString(aCx, obj, "status",
|
|
|
|
FeatureStatusToString(aStatus)) ||
|
|
|
|
(aMessage && !SetJSPropertyString(aCx, obj, "message", aMessage))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!AppendJSElement(aCx, log, obj)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-09 20:44:21 +03:00
|
|
|
void GfxInfoBase::DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> aObj) {
|
2016-10-27 18:04:50 +03:00
|
|
|
JS::Rooted<JSObject*> obj(aCx);
|
2017-06-24 00:23:13 +03:00
|
|
|
|
2020-05-30 01:35:13 +03:00
|
|
|
gfx::FeatureState& hwCompositing =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::HW_COMPOSITING);
|
|
|
|
InitFeatureObject(aCx, aObj, "hwCompositing", hwCompositing, &obj);
|
|
|
|
|
2020-04-16 01:11:19 +03:00
|
|
|
gfx::FeatureState& gpuProcess =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::GPU_PROCESS);
|
2018-07-19 21:11:34 +03:00
|
|
|
InitFeatureObject(aCx, aObj, "gpuProcess", gpuProcess, &obj);
|
2017-06-24 00:23:13 +03:00
|
|
|
|
2020-04-16 01:11:19 +03:00
|
|
|
gfx::FeatureState& wrQualified =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::WEBRENDER_QUALIFIED);
|
2018-07-19 21:05:29 +03:00
|
|
|
InitFeatureObject(aCx, aObj, "wrQualified", wrQualified, &obj);
|
|
|
|
|
2020-04-16 01:11:19 +03:00
|
|
|
gfx::FeatureState& webrender = gfxConfig::GetFeature(gfx::Feature::WEBRENDER);
|
2018-07-31 04:58:40 +03:00
|
|
|
InitFeatureObject(aCx, aObj, "webrender", webrender, &obj);
|
|
|
|
|
2020-06-25 03:59:29 +03:00
|
|
|
gfx::FeatureState& wrCompositor =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::WEBRENDER_COMPOSITOR);
|
|
|
|
InitFeatureObject(aCx, aObj, "wrCompositor", wrCompositor, &obj);
|
|
|
|
|
2020-11-11 02:36:43 +03:00
|
|
|
gfx::FeatureState& wrSoftware =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::WEBRENDER_SOFTWARE);
|
|
|
|
InitFeatureObject(aCx, aObj, "wrSoftware", wrSoftware, &obj);
|
|
|
|
|
2020-07-04 12:38:43 +03:00
|
|
|
gfx::FeatureState& openglCompositing =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::OPENGL_COMPOSITING);
|
2020-06-30 00:21:40 +03:00
|
|
|
InitFeatureObject(aCx, aObj, "openglCompositing", openglCompositing, &obj);
|
|
|
|
|
2021-01-18 19:50:16 +03:00
|
|
|
gfx::FeatureState& omtp = gfxConfig::GetFeature(gfx::Feature::OMTP);
|
2021-01-15 05:40:22 +03:00
|
|
|
InitFeatureObject(aCx, aObj, "omtp", omtp, &obj);
|
|
|
|
|
2017-06-24 00:23:13 +03:00
|
|
|
// Only include AL if the platform attempted to use it.
|
2020-04-16 01:11:19 +03:00
|
|
|
gfx::FeatureState& advancedLayers =
|
|
|
|
gfxConfig::GetFeature(gfx::Feature::ADVANCED_LAYERS);
|
|
|
|
if (advancedLayers.GetValue() != FeatureStatus::Unused) {
|
2018-07-19 21:11:34 +03:00
|
|
|
InitFeatureObject(aCx, aObj, "advancedLayers", advancedLayers, &obj);
|
2017-07-11 10:13:26 +03:00
|
|
|
|
|
|
|
if (gfxConfig::UseFallback(Fallback::NO_CONSTANT_BUFFER_OFFSETTING)) {
|
|
|
|
JS::Rooted<JS::Value> trueVal(aCx, JS::BooleanValue(true));
|
|
|
|
JS_SetProperty(aCx, obj, "noConstantBufferOffsetting", trueVal);
|
|
|
|
}
|
2017-06-24 00:23:13 +03:00
|
|
|
}
|
2015-07-20 00:50:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GfxInfoBase::InitFeatureObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aContainer,
|
|
|
|
const char* aName,
|
2020-04-16 01:11:19 +03:00
|
|
|
mozilla::gfx::FeatureState& aFeatureState,
|
2015-07-20 00:50:35 +03:00
|
|
|
JS::MutableHandle<JSObject*> aOutObj) {
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!obj) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-19 01:39:24 +03:00
|
|
|
nsCString status = aFeatureState.GetStatusAndFailureIdString();
|
2016-05-09 20:44:21 +03:00
|
|
|
|
2020-04-16 01:11:19 +03:00
|
|
|
JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, status.get()));
|
2018-07-19 21:11:34 +03:00
|
|
|
JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
|
|
|
|
JS_SetProperty(aCx, obj, "status", val);
|
2015-07-20 00:50:35 +03:00
|
|
|
|
|
|
|
// Add the feature object to the container.
|
|
|
|
{
|
|
|
|
JS::Rooted<JS::Value> val(aCx, JS::ObjectValue(*obj));
|
|
|
|
JS_SetProperty(aCx, aContainer, aName, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
aOutObj.set(obj);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-10 21:49:16 +03:00
|
|
|
nsresult GfxInfoBase::GetActiveCrashGuards(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aOut) {
|
2019-12-11 09:17:44 +03:00
|
|
|
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
2016-05-10 21:49:16 +03:00
|
|
|
if (!array) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aOut.setObject(*array);
|
|
|
|
|
|
|
|
DriverCrashGuard::ForEachActiveCrashGuard(
|
|
|
|
[&](const char* aName, const char* aPrefName) -> void {
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
|
|
|
|
if (!obj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!SetJSPropertyString(aCx, obj, "type", aName)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!SetJSPropertyString(aCx, obj, "prefName", aPrefName)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!AppendJSElement(aCx, array, obj)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-22 22:20:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetWebRenderEnabled(bool* aWebRenderEnabled) {
|
|
|
|
*aWebRenderEnabled = gfxVars::UseWebRender();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:52:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetUsesTiling(bool* aUsesTiling) {
|
|
|
|
*aUsesTiling = gfxPlatform::GetPlatform()->UsesTiling();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-04-30 23:05:19 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetContentUsesTiling(bool* aUsesTiling) {
|
|
|
|
*aUsesTiling = gfxPlatform::GetPlatform()->ContentUsesTiling();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-08-15 07:08:18 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetOffMainThreadPaintEnabled(bool* aOffMainThreadPaintEnabled) {
|
2019-10-23 22:39:00 +03:00
|
|
|
*aOffMainThreadPaintEnabled = gfxConfig::IsEnabled(gfx::Feature::OMTP);
|
2017-08-15 07:08:18 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-01-24 00:52:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetOffMainThreadPaintWorkerCount(
|
|
|
|
int32_t* aOffMainThreadPaintWorkerCount) {
|
2019-10-23 22:39:00 +03:00
|
|
|
if (gfxConfig::IsEnabled(gfx::Feature::OMTP)) {
|
2018-01-24 00:52:13 +03:00
|
|
|
*aOffMainThreadPaintWorkerCount =
|
|
|
|
layers::PaintThread::CalculatePaintWorkerCount();
|
|
|
|
} else {
|
|
|
|
*aOffMainThreadPaintWorkerCount = 0;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-01-08 18:48:24 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetTargetFrameRate(uint32_t* aTargetFrameRate) {
|
|
|
|
*aTargetFrameRate = gfxPlatform::TargetFrameRate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-04 01:39:16 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetIsHeadless(bool* aIsHeadless) {
|
|
|
|
*aIsHeadless = gfxPlatform::IsHeadless();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-09-13 02:23:28 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetContentBackend(nsAString& aContentBackend) {
|
|
|
|
BackendType backend = gfxPlatform::GetPlatform()->GetDefaultContentBackend();
|
|
|
|
nsString outStr;
|
|
|
|
|
|
|
|
switch (backend) {
|
|
|
|
case BackendType::DIRECT2D1_1: {
|
|
|
|
outStr.AppendPrintf("Direct2D 1.1");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BackendType::SKIA: {
|
|
|
|
outStr.AppendPrintf("Skia");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BackendType::CAIRO: {
|
|
|
|
outStr.AppendPrintf("Cairo");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
aContentBackend.Assign(outStr);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-15 02:02:02 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::GetUsingGPUProcess(bool* aOutValue) {
|
|
|
|
GPUProcessManager* gpu = GPUProcessManager::Get();
|
|
|
|
if (!gpu) {
|
|
|
|
// Not supported in content processes.
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aOutValue = !!gpu->GetGPUChild();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-27 03:35:55 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GfxInfoBase::ControlGPUProcessForXPCShell(bool aEnable, bool* _retval) {
|
|
|
|
gfxPlatform::GetPlatform();
|
|
|
|
|
|
|
|
GPUProcessManager* gpm = GPUProcessManager::Get();
|
|
|
|
if (aEnable) {
|
2019-10-23 22:39:00 +03:00
|
|
|
if (!gfxConfig::IsEnabled(gfx::Feature::GPU_PROCESS)) {
|
|
|
|
gfxConfig::UserForceEnable(gfx::Feature::GPU_PROCESS, "xpcshell-test");
|
2017-01-27 03:35:55 +03:00
|
|
|
}
|
|
|
|
gpm->LaunchGPUProcess();
|
|
|
|
gpm->EnsureGPUReady();
|
|
|
|
} else {
|
2019-10-23 22:39:00 +03:00
|
|
|
gfxConfig::UserDisable(gfx::Feature::GPU_PROCESS, "xpcshell-test");
|
2017-01-27 03:35:55 +03:00
|
|
|
gpm->KillProcess();
|
|
|
|
}
|
|
|
|
|
|
|
|
*_retval = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-03 00:53:59 +04:00
|
|
|
GfxInfoCollectorBase::GfxInfoCollectorBase() {
|
|
|
|
GfxInfoBase::AddCollector(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
GfxInfoCollectorBase::~GfxInfoCollectorBase() {
|
|
|
|
GfxInfoBase::RemoveCollector(this);
|
|
|
|
}
|