From 59f6f04750f2ad5ec2fdd5fa12453a8f9135d1db Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 7 Sep 2011 17:17:44 -0400 Subject: [PATCH] Bug 681026 - always get data from glxtest process and waitpid() for it - r=joe This patch makes GetShouldAccelerate directly call GetData, just before the place where we call GetFeatureStatus, which we know is reached. Initially I considered instead calling GetData from GfxInfo::Init() but that turned out to be a bad idea: Init() is called by the factory constructor, which is called significantly earlier in the startup process. We want to call GetData as late as possible, just when we need it, to maximize chances that the glxtest process be already finished by the time we waitpid() it, so that we don't end up wasting time waiting for it. --- widget/public/nsIGfxInfo.idl | 3 +++ widget/src/xpwidgets/GfxInfoBase.h | 3 +++ widget/src/xpwidgets/GfxInfoX11.h | 3 ++- widget/src/xpwidgets/nsBaseWidget.cpp | 8 ++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/widget/public/nsIGfxInfo.idl b/widget/public/nsIGfxInfo.idl index 72f12e88e26..81616fe51b6 100644 --- a/widget/public/nsIGfxInfo.idl +++ b/widget/public/nsIGfxInfo.idl @@ -143,5 +143,8 @@ interface nsIGfxInfo : nsISupports * underlying GL impl that's used to implement WebGL. */ DOMString getWebGLParameter(in DOMString aParam); + + // only useful on X11 + [noscript, notxpcom] void GetData(); }; diff --git a/widget/src/xpwidgets/GfxInfoBase.h b/widget/src/xpwidgets/GfxInfoBase.h index b2f27d36933..1519ebd9bac 100644 --- a/widget/src/xpwidgets/GfxInfoBase.h +++ b/widget/src/xpwidgets/GfxInfoBase.h @@ -84,6 +84,9 @@ public: // Ideally, Init() would be void-return, but the rules of // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return. virtual nsresult Init(); + + // only useful on X11 + virtual void GetData() { } protected: diff --git a/widget/src/xpwidgets/GfxInfoX11.h b/widget/src/xpwidgets/GfxInfoX11.h index e907aff0e04..dd1a9c2f878 100644 --- a/widget/src/xpwidgets/GfxInfoX11.h +++ b/widget/src/xpwidgets/GfxInfoX11.h @@ -76,6 +76,8 @@ public: using GfxInfoBase::GetWebGLParameter; virtual nsresult Init(); + + virtual void GetData(); protected: @@ -91,7 +93,6 @@ private: int mMajorVersion, mMinorVersion, mRevisionVersion; void AddCrashReportAnnotations(); - void GetData(); }; } // namespace widget diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 55684b91108..fdc6a5407f9 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -827,10 +827,14 @@ nsBaseWidget::GetShouldAccelerate() bool whitelisted = false; - // bug 655578: on X11 at least, we must always call GetFeatureStatus (even if we don't need that information) - // as that's what causes GfxInfo initialization which kills the zombie 'glxtest' process. nsCOMPtr gfxInfo = do_GetService("@mozilla.org/gfx/info;1"); if (gfxInfo) { + // bug 655578: on X11 at least, we must always call GetData (even if we don't need that information) + // as that's what causes GfxInfo initialization which kills the zombie 'glxtest' process. + // initially we relied on the fact that GetFeatureStatus calls GetData for us, but bug 681026 showed + // that assumption to be unsafe. + gfxInfo->GetData(); + PRInt32 status; if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &status))) { if (status == nsIGfxInfo::FEATURE_NO_INFO) {