backout bug 645407, bug 639842, bug 642502

This commit is contained in:
Benoit Jacob 2011-05-03 17:18:44 -04:00
parent fd50b07015
commit d740fe1212
11 changed files with 136 additions and 894 deletions

View File

@ -180,25 +180,63 @@ GLXLibrary::EnsureInitialized()
}
Display *display = DefaultXDisplay();
PRBool ignoreBlacklist = PR_GetEnv("MOZ_GLX_IGNORE_BLACKLIST") != nsnull;
if (!ignoreBlacklist) {
// ATI's libGL (at least the one provided with 11.2 drivers) segfaults
// when querying server info if the server does not have the
// ATIFGLEXTENSION extension.
const char *clientVendor = xGetClientString(display, GLX_VENDOR);
if (clientVendor && strcmp(clientVendor, "ATI") == 0) {
printf("[GLX] The ATI proprietary libGL.so.1 is currently "
"blacklisted to avoid crashes that happen in some "
"situations. If you would like to bypass this, set the "
"MOZ_GLX_IGNORE_BLACKLIST environment variable.\n");
return PR_FALSE;
}
}
int screen = DefaultScreen(display);
const char *serverVendor = NULL;
const char *serverVersionStr = NULL;
const char *extensionsStr = NULL;
if (!xQueryVersion(display, &gGLXMajorVersion, &gGLXMinorVersion)) {
gGLXMajorVersion = 0;
gGLXMinorVersion = 0;
return PR_FALSE;
// This scope is covered by a ScopedXErrorHandler to catch X errors in GLX
// calls. See bug 632867 comment 3: Mesa versions up to 7.10 cause a
// BadLength error during the first GLX call that communicates with the
// server when the server GLX version < 1.3.
{
ScopedXErrorHandler xErrorHandler;
if (!xQueryVersion(display, &gGLXMajorVersion, &gGLXMinorVersion)) {
gGLXMajorVersion = 0;
gGLXMinorVersion = 0;
return PR_FALSE;
}
serverVendor = xQueryServerString(display, screen, GLX_VENDOR);
serverVersionStr = xQueryServerString(display, screen, GLX_VERSION);
PRBool IsDriverBlacklisted = !serverVendor || // it's been reported that a VNC X server was returning serverVendor=null
!serverVersionStr ||
strcmp(serverVendor, "NVIDIA Corporation");
if (IsDriverBlacklisted && !ignoreBlacklist)
{
printf("[GLX] your GL driver is currently blocked. If you would like to bypass this, "
"define the MOZ_GLX_IGNORE_BLACKLIST environment variable.\n");
return PR_FALSE;
}
if (!GLXVersionCheck(1, 1))
// Not possible to query for extensions.
return PR_FALSE;
extensionsStr = xQueryExtensionsString(display, screen);
if (xErrorHandler.GetError())
return PR_FALSE;
}
serverVendor = xQueryServerString(display, screen, GLX_VENDOR);
serverVersionStr = xQueryServerString(display, screen, GLX_VERSION);
if (!GLXVersionCheck(1, 1))
// Not possible to query for extensions.
return PR_FALSE;
LibrarySymbolLoader::SymLoadStruct *sym13;
if (!GLXVersionCheck(1, 3)) {
// Even if we don't have 1.3, we might have equivalent extensions

View File

@ -166,64 +166,6 @@ function populateGraphicsSection() {
return elem;
}
function pushInfoRow(table, name, value)
{
if(value) {
table.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName(name)),
createElement("td", value),
]));
}
}
function errorMessageForFeature(feature) {
var errorMessage;
var status;
try {
status = gfxInfo.getFeatureStatus(feature);
} catch(e) {}
switch (status) {
case gfxInfo.FEATURE_BLOCKED_DEVICE:
case gfxInfo.FEATURE_DISCOURAGED:
errorMessage = bundle.GetStringFromName("blockedGfxCard");
break;
case gfxInfo.FEATURE_BLOCKED_OS_VERSION:
errorMessage = bundle.GetStringFromName("blockedOSVersion");
break;
case gfxInfo.FEATURE_BLOCKED_DRIVER_VERSION:
var suggestedDriverVersion;
try {
suggestedDriverVersion = gfxInfo.getFeatureSuggestedDriverVersion(feature);
} catch(e) {}
if (suggestedDriverVersion)
errorMessage = bundle.formatStringFromName("tryNewerDriver", [suggestedDriverVersion], 1);
else
errorMessage = bundle.GetStringFromName("blockedDriver");
break;
}
return errorMessage;
}
function pushFeatureInfoRow(table, name, feature, isEnabled, message) {
message = message || isEnabled;
if (!isEnabled) {
var errorMessage = errorMessageForFeature(feature);
if (errorMessage)
message = errorMessage;
}
table.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName(name)),
createElement("td", message),
]));
}
function hexValueToString(value)
{
return value
? String('0000' + value.toString(16)).slice(-4)
: null;
}
let bundle = Services.strings.createBundle("chrome://global/locale/aboutSupport.properties");
let graphics_tbody = document.getElementById("graphics-tbody");
@ -235,57 +177,95 @@ function populateGraphicsSection() {
if (gfxInfo) {
let trGraphics = [];
pushInfoRow(trGraphics, "adapterDescription", gfxInfo.adapterDescription);
pushInfoRow(trGraphics, "adapterVendorID", hexValueToString(gfxInfo.adapterVendorID));
pushInfoRow(trGraphics, "adapterDeviceID", hexValueToString(gfxInfo.adapterDeviceID));
pushInfoRow(trGraphics, "adapterRAM", gfxInfo.adapterRAM);
pushInfoRow(trGraphics, "adapterDrivers", gfxInfo.adapterDriver);
pushInfoRow(trGraphics, "driverVersion", gfxInfo.adapterDriverVersion);
pushInfoRow(trGraphics, "driverDate", gfxInfo.adapterDriverDate);
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("adapterDescription")),
createElement("td", gfxInfo.adapterDescription),
]));
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("adapterVendorID")),
// pad with zeros. (printf would be nicer)
createElement("td", String('0000'+gfxInfo.adapterVendorID.toString(16)).slice(-4)),
]));
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("adapterDeviceID")),
// pad with zeros. (printf would be nicer)
createElement("td", String('0000'+gfxInfo.adapterDeviceID.toString(16)).slice(-4)),
]));
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("adapterRAM")),
createElement("td", gfxInfo.adapterRAM),
]));
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("adapterDrivers")),
createElement("td", gfxInfo.adapterDriver),
]));
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("driverVersion")),
createElement("td", gfxInfo.adapterDriverVersion),
]));
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("driverDate")),
createElement("td", gfxInfo.adapterDriverDate),
]));
#ifdef XP_WIN
var version = Cc["@mozilla.org/system-info;1"]
.getService(Ci.nsIPropertyBag2)
.getProperty("version");
var isWindowsVistaOrHigher = (parseFloat(version) >= 6.0);
if (isWindowsVistaOrHigher) {
var d2dEnabled = "false";
var d2dEnabled = false;
try {
d2dEnabled = gfxInfo.D2DEnabled;
} catch(e) {}
var d2dMessage = d2dEnabled;
if (!d2dEnabled) {
var d2dStatus = -1; // different from any status value defined in the IDL
try {
d2dEnabled = gfxInfo.D2DEnabled;
} catch(e) {}
pushFeatureInfoRow(trGraphics, "direct2DEnabled", gfxInfo.FEATURE_DIRECT2D, d2dEnabled);
var dwEnabled = "false";
try {
dwEnabled = gfxInfo.DWriteEnabled + " (" + gfxInfo.DWriteVersion + ")";
} catch(e) {}
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("directWriteEnabled")),
createElement("td", dwEnabled),
]));
d2dStatus = gfxInfo.getFeatureStatus(gfxInfo.FEATURE_DIRECT2D);
} catch(e) {
window.dump(e + '\n');
}
if (d2dStatus == gfxInfo.FEATURE_BLOCKED_DEVICE ||
d2dStatus == gfxInfo.FEATURE_DISCOURAGED)
{
d2dMessage = bundle.GetStringFromName("blockedGraphicsCard");
}
else if (d2dStatus == gfxInfo.FEATURE_BLOCKED_DRIVER_VERSION)
{
var d2dSuggestedDriverVersion = null;
try {
d2dSuggestedDriverVersion = gfxInfo.getFeatureSuggestedDriverVersion(gfxInfo.FEATURE_DIRECT2D);
} catch(e) {
window.dump(e + '\n');
}
if (d2dSuggestedDriverVersion) {
d2dMessage = bundle.GetStringFromName("tryNewerDriverVersion").replace("%1", d2dSuggestedDriverVersion);
}
}
}
#endif
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("direct2DEnabled")),
createElement("td", d2dMessage),
]));
var dwEnabled = false;
var dwriteEnabledStr = dwEnabled.toString();
var dwriteVersion;
try {
dwEnabled = gfxInfo.DWriteEnabled;
dwriteVersion = gfxInfo.DWriteVersion;
dwriteEnabledStr = dwEnabled.toString() + " (" + dwriteVersion + ")";
} catch(e) {}
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("directWriteEnabled")),
createElement("td", dwriteEnabledStr),
]));
var webglrenderer;
var webglenabled;
try {
webglrenderer = gfxInfo.getWebGLParameter("full-renderer");
webglenabled = true;
} catch (e) {
webglrenderer = false;
webglenabled = false;
webglrenderer = "(WebGL unavailable)";
}
#ifdef XP_WIN
// If ANGLE is not available but OpenGL is, we want to report on the OpenGL feature, because that's what's going to get used.
// In all other cases we want to report on the ANGLE feature.
var webglfeature = gfxInfo.FEATURE_WEBGL_ANGLE;
if (gfxInfo.getFeatureStatus(gfxInfo.FEATURE_WEBGL_ANGLE) != gfxInfo.FEATURE_NO_INFO &&
gfxInfo.getFeatureStatus(gfxInfo.FEATURE_WEBGL_OPENGL) == gfxInfo.FEATURE_NO_INFO)
webglfeature = gfxInfo.FEATURE_WEBGL_OPENGL;
#else
var webglfeature = gfxInfo.FEATURE_WEBGL_OPENGL;
#endif
pushFeatureInfoRow(trGraphics, "webglRenderer", webglfeature, webglenabled, webglrenderer);
trGraphics.push(createParentElement("tr", [
createHeader(bundle.GetStringFromName("webglRenderer")),
createElement("td", webglrenderer)
]));
appendChildren(graphics_tbody, trGraphics);
@ -316,18 +296,8 @@ function populateGraphicsSection() {
}
let msg = acceleratedWindows + "/" + totalWindows;
if (acceleratedWindows) {
if (acceleratedWindows)
msg += " " + mgrType;
} else {
#ifdef XP_WIN
var feature = gfxInfo.FEATURE_DIRECT3D_9_LAYERS;
#else
var feature = gfxInfo.FEATURE_OPENGL_LAYERS;
#endif
var errMsg = errorMessageForFeature(feature);
if (errMsg)
msg += ". " + errMsg;
}
appendChildren(graphics_tbody, [
createParentElement("tr", [

View File

@ -8,16 +8,11 @@
acceleratedWindows = GPU Accelerated Windows
# LOCALIZATION NOTE The verb "blocked" here refers to a graphics feature such as "Direct2D" or "OpenGL layers".
blockedDriver = Blocked for your graphics driver version.
# LOCALIZATION NOTE The %S here is a placeholder, leave unchanged, it will get replaced by the driver version string.
tryNewerDriver = Blocked for your graphics driver version. Try updating your graphics driver to version %S or newer.
# The %1 here is a placeholder, leave unchanged, it will get replaced by the driver version string.
tryNewerDriverVersion = Blocked on your graphics driver. Try updating your graphics driver to version %1 or newer.
# LOCALIZATION NOTE The verb "blocked" here refers to a graphics feature such as "Direct2D" or "OpenGL layers".
blockedGfxCard = Blocked for your graphics card because of unresolved driver issues.
# LOCALIZATION NOTE The verb "blocked" here refers to a graphics feature such as "Direct2D" or "OpenGL layers".
blockedOSVersion = Blocked for your operating system version.
blockedGraphicsCard = Blocked on your graphics card because of unresolved driver issues.
direct2DEnabled = Direct2D Enabled
directWriteEnabled = DirectWrite Enabled

View File

@ -66,12 +66,6 @@ CPPSRCS = \
nsSigHandlers.cpp \
$(NULL)
ifdef MOZ_X11
ifndef MOZ_PLATFORM_MAEMO
CPPSRCS += glxtest.cpp
endif
endif
ifdef MOZ_INSTRUMENT_EVENT_LOOP
CPPSRCS += EventTracer.cpp
endif

View File

@ -1,242 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//////////////////////////////////////////////////////////////////////////////
//
// Explanation: See bug 639842. Safely getting GL driver info on X11 is hard, because the only way to do
// that is to create a GL context and call glGetString(), but with bad drivers,
// just creating a GL context may crash.
//
// This file implements the idea to do that in a separate process.
//
// The only non-static function here is fire_glxtest_process(). It creates a pipe, publishes its 'read' end as the
// mozilla::widget::glxtest_pipe global variable, forks, and runs that GLX probe in the child process,
// which runs the glxtest() static function. This creates a X connection, a GLX context, calls glGetString, and writes that
// to the 'write' end of the pipe.
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <dlfcn.h>
#include "nscore.h"
namespace mozilla {
namespace widget {
// the read end of the pipe, which will be used by GfxInfo
extern int glxtest_pipe;
// the PID of the glxtest process, to pass to waitpid()
extern pid_t glxtest_pid;
}
}
// the write end of the pipe, which we're going to write to
static int write_end_of_the_pipe = -1;
// C++ standard collides with C standard in that it doesn't allow casting void* to function pointer types.
// So the work-around is to convert first to size_t.
// http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
template<typename func_ptr_type>
static func_ptr_type cast(void *ptr)
{
return reinterpret_cast<func_ptr_type>(
reinterpret_cast<size_t>(ptr)
);
}
static void fatal_error(const char *str)
{
write(write_end_of_the_pipe, str, strlen(str));
write(write_end_of_the_pipe, "\n", 1);
exit(EXIT_FAILURE);
}
static int
x_error_handler(Display *, XErrorEvent *ev)
{
enum { bufsize = 1024 };
char buf[bufsize];
int length = snprintf(buf, bufsize,
"X error occurred in GLX probe, error_code=%d, request_code=%d, minor_code=%d\n",
ev->error_code,
ev->request_code,
ev->minor_code);
write(write_end_of_the_pipe, buf, length);
exit(EXIT_FAILURE);
return 0;
}
static void glxtest()
{
///// Open libGL and load needed symbols /////
void *libgl = dlopen("libGL.so.1", RTLD_LAZY);
if (!libgl)
fatal_error("Unable to load libGL.so.1");
typedef GLXFBConfig* (* PFNGLXQUERYEXTENSION) (Display *, int *, int *);
PFNGLXQUERYEXTENSION glXQueryExtension = cast<PFNGLXQUERYEXTENSION>(dlsym(libgl, "glXQueryExtension"));
typedef GLXFBConfig* (* PFNGLXCHOOSEFBCONFIG) (Display *, int, const int *, int *);
PFNGLXCHOOSEFBCONFIG glXChooseFBConfig = cast<PFNGLXCHOOSEFBCONFIG>(dlsym(libgl, "glXChooseFBConfig"));
typedef XVisualInfo* (* PFNGLXGETVISUALFROMFBCONFIG) (Display *, GLXFBConfig);
PFNGLXGETVISUALFROMFBCONFIG glXGetVisualFromFBConfig = cast<PFNGLXGETVISUALFROMFBCONFIG>(dlsym(libgl, "glXGetVisualFromFBConfig"));
typedef GLXPixmap (* PFNGLXCREATEPIXMAP) (Display *, GLXFBConfig, Pixmap, const int *);
PFNGLXCREATEPIXMAP glXCreatePixmap = cast<PFNGLXCREATEPIXMAP>(dlsym(libgl, "glXCreatePixmap"));
typedef GLXContext (* PFNGLXCREATENEWCONTEXT) (Display *, GLXFBConfig, int, GLXContext, Bool);
PFNGLXCREATENEWCONTEXT glXCreateNewContext = cast<PFNGLXCREATENEWCONTEXT>(dlsym(libgl, "glXCreateNewContext"));
typedef Bool (* PFNGLXMAKECURRENT) (Display*, GLXDrawable, GLXContext);
PFNGLXMAKECURRENT glXMakeCurrent = cast<PFNGLXMAKECURRENT>(dlsym(libgl, "glXMakeCurrent"));
typedef void (* PFNGLXDESTROYPIXMAP) (Display *, GLXPixmap);
PFNGLXDESTROYPIXMAP glXDestroyPixmap = cast<PFNGLXDESTROYPIXMAP>(dlsym(libgl, "glXDestroyPixmap"));
typedef void (* PFNGLXDESTROYCONTEXT) (Display*, GLXContext);
PFNGLXDESTROYCONTEXT glXDestroyContext = cast<PFNGLXDESTROYCONTEXT>(dlsym(libgl, "glXDestroyContext"));
typedef GLubyte* (* PFNGLGETSTRING) (GLenum);
PFNGLGETSTRING glGetString = cast<PFNGLGETSTRING>(dlsym(libgl, "glGetString"));
if (!glXQueryExtension ||
!glXChooseFBConfig ||
!glXGetVisualFromFBConfig ||
!glXCreatePixmap ||
!glXCreateNewContext ||
!glXMakeCurrent ||
!glXDestroyPixmap ||
!glXDestroyContext ||
!glGetString)
{
fatal_error("Unable to find required symbols in libGL.so.1");
}
///// Open a connection to the X server /////
Display *dpy = XOpenDisplay(NULL);
if (!dpy)
fatal_error("Unable to open a connection to the X server");
///// Check that the GLX extension is present /////
if (!glXQueryExtension(dpy, NULL, NULL))
fatal_error("GLX extension missing");
XSetErrorHandler(x_error_handler);
///// Get a FBConfig and a visual /////
int attribs[] = {
GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
GLX_X_RENDERABLE, True,
0
};
int numReturned;
GLXFBConfig *fbConfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &numReturned );
XVisualInfo *vInfo = glXGetVisualFromFBConfig(dpy, fbConfigs[0]);
///// Get a Pixmap and a GLXPixmap /////
Pixmap pixmap = XCreatePixmap(dpy, RootWindow(dpy, vInfo->screen), 4, 4, 32);
GLXPixmap glxpixmap = glXCreatePixmap(dpy, fbConfigs[0], pixmap, NULL);
///// Get a GL context and make it current //////
GLXContext context = glXCreateNewContext(dpy, fbConfigs[0], GLX_RGBA_TYPE, NULL, True);
glXMakeCurrent(dpy, glxpixmap, context);
///// Get GL vendor/renderer/versions strings /////
enum { bufsize = 1024 };
char buf[bufsize];
const GLubyte *vendorString = glGetString(GL_VENDOR);
const GLubyte *rendererString = glGetString(GL_RENDERER);
const GLubyte *versionString = glGetString(GL_VERSION);
if (!vendorString || !rendererString || !versionString)
fatal_error("glGetString returned null");
int length = snprintf(buf, bufsize,
"VENDOR\n%s\nRENDERER\n%s\nVERSION\n%s\n",
vendorString,
rendererString,
versionString);
if (length >= bufsize)
fatal_error("GL strings length too large for buffer size");
///// Check that no X error happened /////
// In case of X errors, our X error handler will exit() now.
// We really want to make sure that the system is able to create a GL context without generating X errors,
// as these would crash the application.
XSync(dpy, False);
///// Finally write data to the pipe /////
write(write_end_of_the_pipe, buf, length);
///// Clean up. Indeed, the parent process might fail to kill us (e.g. if it doesn't need to check GL info)
///// so we might be staying alive for longer than expected, so it's important to consume as little memory as
///// possible.
glXDestroyContext(dpy, context);
glXDestroyPixmap(dpy, glxpixmap);
XFreePixmap(dpy, pixmap);
XCloseDisplay(dpy);
dlclose(libgl);
}
void fire_glxtest_process()
{
int pfd[2];
if (pipe(pfd) == -1) {
perror("pipe");
exit(EXIT_FAILURE);
}
pid_t pid = fork();
if (pid < 0) {
perror("fork");
exit(EXIT_FAILURE);
}
if (pid == 0) {
close(pfd[0]);
write_end_of_the_pipe = pfd[1];
glxtest();
close(pfd[1]);
exit(EXIT_SUCCESS);
}
close(pfd[1]);
mozilla::widget::glxtest_pipe = pfd[0];
mozilla::widget::glxtest_pid = pid;
}

View File

@ -2727,12 +2727,6 @@ static DWORD InitDwriteBG(LPVOID lpdwThreadParam)
PRTime gXRE_mainTimestamp = 0;
#ifdef MOZ_X11
#ifndef MOZ_PLATFORM_MAEMO
void fire_glxtest_process();
#endif
#endif
int
XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
{
@ -2753,16 +2747,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_BREAK();
#endif
// see bug 639842
// it's very important to fire this process BEFORE we set up error handling.
// indeed, this process is expected to be crashy, and we don't want the user to see its crashes.
// That's the whole reason for doing this in a separate process.
#ifdef MOZ_X11
#ifndef MOZ_PLATFORM_MAEMO
fire_glxtest_process();
#endif
#endif
SetupErrorHandling(argv[0]);
#ifdef CAIRO_HAS_DWRITE_FONT

View File

@ -69,7 +69,6 @@
#if defined(MOZ_X11)
#include "nsIdleServiceGTK.h"
#include "GfxInfoX11.h"
#endif
#ifdef NATIVE_THEME_SUPPORT
@ -139,12 +138,6 @@ nsNativeThemeGTKConstructor(nsISupports *aOuter, REFNSIID aIID,
#if defined(MOZ_X11)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceGTK)
namespace mozilla {
namespace widget {
// This constructor should really be shared with all platforms.
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
}
}
#endif
#ifdef NS_PRINTING
@ -264,7 +257,6 @@ NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_IMAGE_TO_PIXBUF_CID);
#if defined(MOZ_X11)
NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
#endif
@ -300,7 +292,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_IMAGE_TO_PIXBUF_CID, false, NULL, nsImageToPixbufConstructor },
#if defined(MOZ_X11)
{ &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceGTKConstructor },
{ &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
#endif
{ NULL }
};
@ -337,7 +328,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/widget/image-to-gdk-pixbuf;1", &kNS_IMAGE_TO_PIXBUF_CID },
#if defined(MOZ_X11)
{ "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
{ "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
#endif
{ NULL }
};

View File

@ -70,10 +70,6 @@
#include "nsFilePickerProxy.h"
#include "nsXULAppAPI.h"
#if defined(MOZ_X11)
#include "GfxInfoX11.h"
#endif
// from nsWindow.cpp
extern PRBool gDisableNativeTheme;
@ -119,16 +115,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceQt, Init)
#endif
#if defined(MOZ_X11)
namespace mozilla {
namespace widget {
// This constructor should really be shared with all platforms.
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
}
}
#endif
static nsresult
nsNativeThemeQtConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult)
@ -177,11 +163,7 @@ NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
#endif
#if defined(MOZ_X11)
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
#endif
#endif
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
@ -207,10 +189,7 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecQtConstructor },
{ &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceQtConstructor },
#endif
#if defined(MOZ_X11)
{ &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
#endif
#endif
{ NULL }
};
@ -238,10 +217,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
{ NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
#endif
#if defined(MOZ_X11)
{ "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
#endif
#endif
{ NULL }
};

View File

@ -1,369 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include "nsCRTGlue.h"
#include "prenv.h"
#include "GfxInfoX11.h"
#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL)
#include "nsExceptionHandler.h"
#include "nsICrashReporter.h"
#endif
namespace mozilla {
namespace widget {
// these global variables will be set when firing the glxtest process
int glxtest_pipe = 0;
pid_t glxtest_pid = 0;
nsresult
GfxInfo::Init()
{
mMajorVersion = 0;
mMinorVersion = 0;
mIsMesa = false;
mIsNVIDIA = false;
mIsFGLRX = false;
return GfxInfoBase::Init();
}
void
GfxInfo::GetData()
{
// to understand this function, see bug 639842. We retrieve the OpenGL driver information in a
// separate process to protect against bad drivers.
// if glxtest_pipe == 0, that means that we already read the information
if (!glxtest_pipe)
return;
enum { buf_size = 1024 };
char buf[buf_size];
ssize_t bytesread = read(glxtest_pipe,
&buf,
buf_size-1); // -1 because we'll append a zero
close(glxtest_pipe);
glxtest_pipe = 0;
// bytesread < 0 would mean that the above read() call failed. This should never happen.
if (bytesread < 0)
bytesread = 0;
// let buf be a zero-terminated string
buf[bytesread] = 0;
// Wait for the glxtest process to finish. This serves 2 purposes:
// * avoid having a zombie glxtest process laying around
// * get the glxtest process status info.
int glxtest_status = 0;
bool wait_for_glxtest_process = true;
bool waiting_for_glxtest_process_failed = false;
while(wait_for_glxtest_process) {
wait_for_glxtest_process = false;
if (waitpid(glxtest_pid, &glxtest_status, 0) == -1) {
if (errno == EINTR)
wait_for_glxtest_process = true;
else
waiting_for_glxtest_process_failed = true;
}
}
bool exited_with_error_code = !waiting_for_glxtest_process_failed &&
WIFEXITED(glxtest_status) &&
WEXITSTATUS(glxtest_status) != EXIT_SUCCESS;
bool received_signal = !waiting_for_glxtest_process_failed &&
WIFSIGNALED(glxtest_status);
bool error = waiting_for_glxtest_process_failed || exited_with_error_code || received_signal;
nsCString *stringToFill = nsnull;
char *bufptr = buf;
if (!error) {
while(true) {
char *line = NS_strtok("\n", &bufptr);
if (!line)
break;
if (stringToFill) {
stringToFill->Assign(line);
stringToFill = nsnull;
}
else if(!strcmp(line, "VENDOR"))
stringToFill = &mVendor;
else if(!strcmp(line, "RENDERER"))
stringToFill = &mRenderer;
else if(!strcmp(line, "VERSION"))
stringToFill = &mVersion;
}
}
const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR");
if (spoofedVendor)
mVendor.Assign(spoofedVendor);
const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER");
if (spoofedRenderer)
mRenderer.Assign(spoofedRenderer);
const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION");
if (spoofedVersion)
mVersion.Assign(spoofedVersion);
if (error ||
mVendor.IsEmpty() ||
mRenderer.IsEmpty() ||
mVersion.IsEmpty())
{
mAdapterDescription.AppendLiteral("GLXtest process failed");
if (waiting_for_glxtest_process_failed)
mAdapterDescription.AppendLiteral(" (waitpid failed)");
if (exited_with_error_code)
mAdapterDescription.AppendPrintf(" (exited with status %d)", WEXITSTATUS(glxtest_status));
if (received_signal)
mAdapterDescription.AppendPrintf(" (received signal %d)", WTERMSIG(glxtest_status));
if (bytesread) {
mAdapterDescription.AppendLiteral(": ");
mAdapterDescription.Append(nsDependentCString(buf));
mAdapterDescription.AppendLiteral("\n");
}
#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL)
CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription);
#endif
return;
}
mAdapterDescription.Append(mVendor);
mAdapterDescription.AppendLiteral(" -- ");
mAdapterDescription.Append(mRenderer);
nsCAutoString note;
note.Append("OpenGL: ");
note.Append(mAdapterDescription);
note.Append(" -- ");
note.Append(mVersion);
note.Append("\n");
#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL)
CrashReporter::AppendAppNotesToCrashReport(note);
#endif
// 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.
whereToReadVersionNumbers = Mesa_in_version_string + strlen("Mesa");
} else if (strstr(mVendor.get(), "NVIDIA Corporation")) {
mIsNVIDIA = true;
// with the NVIDIA driver, the version string contains "NVIDIA major.minor"
// note that here the vendor and version strings behave differently, that's why we don't put this above
// alongside Mesa_in_version_string.
const char *NVIDIA_in_version_string = strstr(mVersion.get(), "NVIDIA");
if (NVIDIA_in_version_string)
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
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);
if (token) {
mMajorVersion = strtol(token, 0, 10);
token = NS_strtok(".", &bufptr);
if (token)
mMinorVersion = strtol(token, 0, 10);
}
}
}
static inline PRUint64 version(PRUint32 major, PRUint32 minor)
{
return (PRUint64(major) << 32) + PRUint64(minor);
}
nsresult
GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, GfxDriverInfo* aDriverInfo /* = nsnull */)
{
GetData();
*aStatus = nsIGfxInfo::FEATURE_NO_INFO;
aSuggestedDriverVersion.SetIsVoid(PR_TRUE);
#ifdef MOZ_PLATFORM_MAEMO
// on Maemo, the glxtest probe doesn't build, and we don't really need GfxInfo anyway
return NS_OK;
#endif
// whitelist the linux test slaves' current configuration.
// this is necessary as they're still using the slightly outdated 190.42 driver.
// this isn't a huge risk, as at least this is the exact setting in which we do continuous testing,
// and this only affects GeForce 9400 cards on linux on this precise driver version, which is very few users.
// We do the same thing on Windows XP, see in widget/src/windows/GfxInfo.cpp
if (mIsNVIDIA &&
!strcmp(mRenderer.get(), "GeForce 9400/PCI/SSE2") &&
!strcmp(mVersion.get(), "3.2.0 NVIDIA 190.42"))
{
return NS_OK;
}
if (mIsMesa) {
if (version(mMajorVersion, mMinorVersion) < version(7,10)) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
aSuggestedDriverVersion.AssignLiteral("Mesa 7.10");
}
else if (strstr(mRenderer.get(), "Gallium")) {
// see bug 624935
// and http://marc.info/?l=mesa3d-dev&m=126525088903956&w=2
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
aSuggestedDriverVersion.AssignLiteral("<NOT Gallium>");
}
} else if (mIsNVIDIA) {
if (version(mMajorVersion, mMinorVersion) < version(257,21)) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
aSuggestedDriverVersion.AssignLiteral("NVIDIA 257.21");
}
} else if (mIsFGLRX) {
// FGLRX does not report a driver version number, so we have the OpenGL version instead.
// by requiring OpenGL 3, we effectively require recent drivers.
if (version(mMajorVersion, mMinorVersion) < version(3, 0)) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION;
}
} else {
// like on windows, let's block unknown vendors. Think of virtual machines.
// Also, this case is hit whenever the GLXtest probe failed to get driver info or crashed.
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
}
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetD2DEnabled(PRBool *aEnabled)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetDWriteEnabled(PRBool *aEnabled)
{
return NS_ERROR_FAILURE;
}
/* readonly attribute DOMString DWriteVersion; */
NS_IMETHODIMP
GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
{
return NS_ERROR_FAILURE;
}
/* readonly attribute DOMString adapterDescription; */
NS_IMETHODIMP
GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)
{
GetData();
AppendASCIItoUTF16(mAdapterDescription, aAdapterDescription);
return NS_OK;
}
/* readonly attribute DOMString adapterRAM; */
NS_IMETHODIMP
GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM)
{
aAdapterRAM.AssignLiteral("");
return NS_OK;
}
/* readonly attribute DOMString adapterDriver; */
NS_IMETHODIMP
GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver)
{
aAdapterDriver.AssignLiteral("");
return NS_OK;
}
/* readonly attribute DOMString adapterDriverVersion; */
NS_IMETHODIMP
GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)
{
GetData();
CopyASCIItoUTF16(mVersion, aAdapterDriverVersion);
return NS_OK;
}
/* readonly attribute DOMString adapterDriverDate; */
NS_IMETHODIMP
GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate)
{
aAdapterDriverDate.AssignLiteral("");
return NS_OK;
}
/* readonly attribute unsigned long adapterVendorID; */
NS_IMETHODIMP
GfxInfo::GetAdapterVendorID(PRUint32 *aAdapterVendorID)
{
*aAdapterVendorID = 0;
return NS_OK;
}
/* readonly attribute unsigned long adapterDeviceID; */
NS_IMETHODIMP
GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID)
{
*aAdapterDeviceID = 0;
return NS_OK;
}
} // end namespace widget
} // end namespace mozilla

View File

@ -1,89 +0,0 @@
/* vim: se cin sw=2 ts=2 et : */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __GfxInfoX11_h__
#define __GfxInfoX11_h__
#include "GfxInfoBase.h"
namespace mozilla {
namespace widget {
class GfxInfo : public GfxInfoBase
{
public:
// We only declare the subset of nsIGfxInfo that we actually implement. The
// rest is brought forward from GfxInfoBase.
NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled);
NS_SCRIPTABLE NS_IMETHOD GetDWriteEnabled(PRBool *aDWriteEnabled);
NS_SCRIPTABLE NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion);
NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription);
NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver);
NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID);
NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID);
NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM);
NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion);
NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate);
using GfxInfoBase::GetFeatureStatus;
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
using GfxInfoBase::GetWebGLParameter;
virtual nsresult Init();
protected:
virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, GfxDriverInfo* aDriverInfo = nsnull);
private:
nsCString mVendor;
nsCString mRenderer;
nsCString mVersion;
nsCString mAdapterDescription;
bool mIsMesa, mIsNVIDIA, mIsFGLRX;
int mMajorVersion, mMinorVersion;
void AddCrashReportAnnotations();
void GetData();
};
} // namespace widget
} // namespace mozilla
#endif /* __GfxInfoX11_h__ */

View File

@ -75,11 +75,6 @@ CPPSRCS = \
nsFilePickerProxy.cpp \
$(NULL)
ifdef MOZ_X11
CPPSRCS += \
GfxInfoX11.cpp
endif
ifneq (,$(filter os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += nsBaseClipboard.cpp
endif