diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 40cee8d0c98..e0c2d7815f9 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -42,6 +42,8 @@ static const char *sEGLExtensionNames[] = { static PRLibrary* LoadApitraceLibrary() { + // Initialization of gfx prefs here is only needed during the unit tests... + gfxPrefs::GetSingleton(); if (!gfxPrefs::UseApitrace()) { return nullptr; } diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp index 89f71b22391..24570d8f247 100644 --- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -50,7 +50,7 @@ using namespace mozilla::gfx; using namespace mozilla::jni; using namespace mozilla::widget; -AndroidBridge* AndroidBridge::sBridge; +AndroidBridge* AndroidBridge::sBridge = nullptr; pthread_t AndroidBridge::sJavaUiThread = -1; static unsigned sJavaEnvThreadIndex = 0; static jobject sGlobalContext = nullptr; @@ -161,14 +161,12 @@ AndroidBridge::ConstructBridge(JNIEnv *jEnv, Object::Param clsLoader) PR_NewThreadPrivateIndex(&sJavaEnvThreadIndex, JavaThreadDetachFunc); - AndroidBridge *bridge = new AndroidBridge(); - if (!bridge->Init(jEnv, clsLoader)) { - delete bridge; - } - sBridge = bridge; + MOZ_ASSERT(!sBridge); + sBridge = new AndroidBridge; + sBridge->Init(jEnv, clsLoader); // Success or crash } -bool +void AndroidBridge::Init(JNIEnv *jEnv, Object::Param clsLoader) { ALOG_BRIDGE("AndroidBridge::Init"); @@ -244,8 +242,6 @@ AndroidBridge::Init(JNIEnv *jEnv, Object::Param clsLoader) // jEnv should NOT be cached here by anything -- the jEnv here // is not valid for the real gecko main thread, which is set // at SetMainThread time. - - return true; } bool diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h index 5e22bdb1f24..bb2d7f58a31 100644 --- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -364,7 +364,7 @@ protected: ~AndroidBridge(); void InitStubs(JNIEnv *jEnv); - bool Init(JNIEnv *jEnv, jni::Object::Param clsLoader); + void Init(JNIEnv *jEnv, jni::Object::Param clsLoader); bool mOpenedGraphicsLibraries; void OpenGraphicsLibraries(); diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp index 95bd0d409cd..5fdf1fa99b0 100644 --- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -41,8 +41,9 @@ public: return mVendor; } + // This spoofed value wins, even if the environment variable + // MOZ_GFX_SPOOF_GL_VENDOR was set. void SpoofVendor(const nsCString& s) { - EnsureInitialized(); mVendor = s; } @@ -51,8 +52,9 @@ public: return mRenderer; } + // This spoofed value wins, even if the environment variable + // MOZ_GFX_SPOOF_GL_RENDERER was set. void SpoofRenderer(const nsCString& s) { - EnsureInitialized(); mRenderer = s; } @@ -61,8 +63,9 @@ public: return mVersion; } + // This spoofed value wins, even if the environment variable + // MOZ_GFX_SPOOF_GL_VERSION was set. void SpoofVersion(const nsCString& s) { - EnsureInitialized(); mVersion = s; } @@ -85,21 +88,32 @@ public: gl->MakeCurrent(); - const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR"); - if (spoofedVendor) + if (mVendor.IsEmpty()) { + const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR"); + if (spoofedVendor) { mVendor.Assign(spoofedVendor); - else + } else { mVendor.Assign((const char*)gl->fGetString(LOCAL_GL_VENDOR)); - const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER"); - if (spoofedRenderer) + } + } + + if (mRenderer.IsEmpty()) { + const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER"); + if (spoofedRenderer) { mRenderer.Assign(spoofedRenderer); - else + } else { mRenderer.Assign((const char*)gl->fGetString(LOCAL_GL_RENDERER)); - const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION"); - if (spoofedVersion) + } + } + + if (mVersion.IsEmpty()) { + const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION"); + if (spoofedVersion) { mVersion.Assign(spoofedVersion); - else + } else { mVersion.Assign((const char*)gl->fGetString(LOCAL_GL_VERSION)); + } + } mReady = true; } @@ -153,9 +167,10 @@ GfxInfo::EnsureInitialized() if (mInitialized) return; - mGLStrings->EnsureInitialized(); - - MOZ_ASSERT(mozilla::AndroidBridge::Bridge()); + if (!mozilla::AndroidBridge::Bridge()) { + gfxWarning() << "AndroidBridge missing during initialization"; + return; + } if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", mModel)) { mAdapterDescription.AppendPrintf("Model: %s", NS_LossyConvertUTF16toASCII(mModel).get()); @@ -601,7 +616,6 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, /* void spoofVendorID (in DOMString aVendorID); */ NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) { - EnsureInitialized(); mGLStrings->SpoofVendor(NS_LossyConvertUTF16toASCII(aVendorID)); return NS_OK; } @@ -609,7 +623,6 @@ NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) /* void spoofDeviceID (in unsigned long aDeviceID); */ NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) { - EnsureInitialized(); mGLStrings->SpoofRenderer(NS_LossyConvertUTF16toASCII(aDeviceID)); return NS_OK; } @@ -617,7 +630,6 @@ NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) /* void spoofDriverVersion (in DOMString aDriverVersion); */ NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion) { - EnsureInitialized(); mGLStrings->SpoofVersion(NS_LossyConvertUTF16toASCII(aDriverVersion)); return NS_OK; }