Bug 696636 - Block OpenGL 1 drivers explicitly to steer clear of crashes - r=mattwoodrow
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 23 Feb 2012 17:21:30 -0500
changeset 87578 512df80d7ca4d0ce2dd9c2128bd8a6f5c2661f83
parent 87577 9304fda5ddc7118d308bb1d612f19d17ec534433
child 87579 b638c0deeafa9b8785dc74dd4a4b38f1580abc73
push id22133
push usermak77@bonardo.net
push dateFri, 24 Feb 2012 10:23:30 +0000
treeherdermozilla-central@fbcdc2c87df8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs696636
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 696636 - Block OpenGL 1 drivers explicitly to steer clear of crashes - r=mattwoodrow
widget/xpwidgets/GfxInfoX11.cpp
widget/xpwidgets/GfxInfoX11.h
--- a/widget/xpwidgets/GfxInfoX11.cpp
+++ b/widget/xpwidgets/GfxInfoX11.cpp
@@ -60,16 +60,17 @@ NS_IMPL_ISUPPORTS_INHERITED1(GfxInfo, Gf
 
 // these global variables will be set when firing the glxtest process
 int glxtest_pipe = 0;
 pid_t glxtest_pid = 0;
 
 nsresult
 GfxInfo::Init()
 {
+    mGLMajorVersion = 0;
     mMajorVersion = 0;
     mMinorVersion = 0;
     mRevisionVersion = 0;
     mIsMesa = false;
     mIsNVIDIA = false;
     mIsFGLRX = false;
     mHasTextureFromPixmap = false;
     return GfxInfoBase::Init();
@@ -202,16 +203,19 @@ GfxInfo::GetData()
     note.Append(mVersion);
     if (mHasTextureFromPixmap)
         note.Append(" -- texture_from_pixmap");
     note.Append("\n");
 #ifdef MOZ_CRASHREPORTER
     CrashReporter::AppendAppNotesToCrashReport(note);
 #endif
 
+    // determine the major OpenGL version. That's the first integer in the version string.
+    mGLMajorVersion = strtol(mVersion.get(), 0, 10);
+
     // determine driver type (vendor) and where in the version string
     // the actual driver version numbers should be expected to be found (whereToReadVersionNumbers)
     const char *whereToReadVersionNumbers = nsnull;
     const char *Mesa_in_version_string = strstr(mVersion.get(), "Mesa");
     if (Mesa_in_version_string) {
         mIsMesa = true;
         // with Mesa, the version string contains "Mesa major.minor" and that's all the version information we get:
         // there is no actual driver version info.
@@ -226,17 +230,17 @@ GfxInfo::GetData()
             whereToReadVersionNumbers = NVIDIA_in_version_string + strlen("NVIDIA");
     } else if (strstr(mVendor.get(), "ATI Technologies Inc")) {
         mIsFGLRX = true;
         // with the FGLRX driver, the version string only gives a OpenGL version :/ so let's return that.
         // that can at least give a rough idea of how old the driver is.
         whereToReadVersionNumbers = mVersion.get();
     }
 
-    // read major.minor version numbers
+    // read major.minor version numbers of the driver (not to be confused with the OpenGL version)
     if (whereToReadVersionNumbers) {
         // copy into writable buffer, for tokenization
         strncpy(buf, whereToReadVersionNumbers, buf_size);
         bufptr = buf;
 
         // now try to read major.minor version numbers. In case of failure, gracefully exit: these numbers have
         // been initialized as 0 anyways
         char *token = NS_strtok(".", &bufptr);
@@ -278,16 +282,25 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aF
 {
   NS_ENSURE_ARG_POINTER(aStatus);
   *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
   aSuggestedDriverVersion.SetIsVoid(true);
   OperatingSystem os = DRIVER_OS_LINUX;
   if (aOS)
     *aOS = os;
 
+  if (mGLMajorVersion < 2) {
+    // We're on OpenGL 1 (or the OpenGL version couldn't be read).
+    // In most cases that indicates really old hardware.
+    // We better block them, rather than rely on them to fail gracefully, because they don't!
+    // see bug 696636
+    *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
+    return NS_OK;
+  }
+
 #ifdef MOZ_PLATFORM_MAEMO
   *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
   // on Maemo, the glxtest probe doesn't build, and we don't really need GfxInfo anyway
   return NS_OK;
 #endif
 
   // Don't evaluate any special cases if we're checking the downloaded blocklist.
   if (!aDriverInfo.Length()) {
--- a/widget/xpwidgets/GfxInfoX11.h
+++ b/widget/xpwidgets/GfxInfoX11.h
@@ -95,17 +95,17 @@ protected:
 
 private:
   nsCString mVendor;
   nsCString mRenderer;
   nsCString mVersion;
   nsCString mAdapterDescription;
   bool mIsMesa, mIsNVIDIA, mIsFGLRX;
   bool mHasTextureFromPixmap;
-  int mMajorVersion, mMinorVersion, mRevisionVersion;
+  int mGLMajorVersion, mMajorVersion, mMinorVersion, mRevisionVersion;
 
   void AddCrashReportAnnotations();
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif /* __GfxInfoX11_h__ */