Backed out changeset 6ee70eb03b02 (bug 1183788) for Android crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 05 Aug 2015 10:24:55 -0400
changeset 287972 8a866b4de644140d10238d87ff8581a5646a3c23
parent 287971 72341fb355fa66c054b6a60ba35b2f87cbf65dfe
child 287973 d52990c9dea8ca4f85249e2fc9baa900218146e9
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1183788
milestone42.0a1
backs out6ee70eb03b02e2b57e5cdd1bdc0dedbe295c55a5
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
Backed out changeset 6ee70eb03b02 (bug 1183788) for Android crashes.
gfx/gl/AndroidSurfaceTexture.cpp
gfx/gl/AndroidSurfaceTexture.h
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
--- a/gfx/gl/AndroidSurfaceTexture.cpp
+++ b/gfx/gl/AndroidSurfaceTexture.cpp
@@ -13,17 +13,16 @@
 #include "gfxImageSurface.h"
 #include "AndroidBridge.h"
 #include "nsThreadUtils.h"
 #include "mozilla/gfx/Matrix.h"
 #include "GeneratedJNIWrappers.h"
 #include "SurfaceTexture.h"
 #include "GLContext.h"
 #include "mozilla/Preferences.h"
-#include "gfxPlatform.h"
 
 using namespace mozilla;
 using namespace mozilla::jni;
 using namespace mozilla::widget;
 using namespace mozilla::widget::sdk;
 
 namespace mozilla {
 namespace gl {
@@ -95,16 +94,18 @@ AndroidSurfaceTexture::Attach(GLContext*
   }
 
   MOZ_ASSERT(aContext->IsOwningThreadCurrent(), "Trying to attach GLContext from different thread");
 
   mAttachedContext = aContext;
   mAttachedContext->MakeCurrent();
   aContext->fGenTextures(1, &mTexture);
 
+  UpdateCanDetach();
+
   return mSurfaceTexture->AttachToGLContext(mTexture);
 }
 
 nsresult
 AndroidSurfaceTexture::Detach()
 {
   MonitorAutoLock lock(mMonitor);
 
@@ -120,19 +121,35 @@ AndroidSurfaceTexture::Detach()
   mSurfaceTexture->DetachFromGLContext();
 
   mTexture = 0;
   mAttachedContext = nullptr;
   lock.NotifyAll();
   return NS_OK;
 }
 
+void
+AndroidSurfaceTexture::UpdateCanDetach()
+{
+  // The API for attach/detach only exists on 16+, and PowerVR has some sort of
+  // fencing issue. Additionally, attach/detach seems to be busted on at least some
+  // Mali adapters (400MP2 for sure, bug 1131793)
+  bool canDetach = Preferences::GetBool("gfx.SurfaceTexture.detach.enabled", true);
+
+  mCanDetach = AndroidBridge::Bridge()->GetAPIVersion() >= 16 &&
+    (!mAttachedContext || mAttachedContext->Vendor() != GLVendor::Imagination) &&
+    (!mAttachedContext || mAttachedContext->Vendor() != GLVendor::ARM /* Mali */) &&
+    canDetach;
+}
+
 bool
 AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
 {
+  UpdateCanDetach();
+
   if (!aTexture && !CanDetach()) {
     // We have no texture and cannot initialize detached, bail out
     return false;
   }
 
   if (NS_WARN_IF(NS_FAILED(
       SurfaceTexture::New(aTexture, ReturnTo(&mSurfaceTexture))))) {
     return false;
@@ -160,16 +177,17 @@ AndroidSurfaceTexture::Init(GLContext* a
 }
 
 AndroidSurfaceTexture::AndroidSurfaceTexture()
   : mTexture(0)
   , mSurfaceTexture()
   , mSurface()
   , mMonitor("AndroidSurfaceTexture::mContextMonitor")
   , mAttachedContext(nullptr)
+  , mCanDetach(false)
 {
 }
 
 AndroidSurfaceTexture::~AndroidSurfaceTexture()
 {
   sInstances.erase(mID);
 
   mFrameAvailableCallback = nullptr;
--- a/gfx/gl/AndroidSurfaceTexture.h
+++ b/gfx/gl/AndroidSurfaceTexture.h
@@ -58,17 +58,17 @@ public:
   // Only one GLContext may be attached at any given time. If another is already
   // attached, we try to wait for it to become detached.
   nsresult Attach(GLContext* aContext, PRIntervalTime aTiemout = PR_INTERVAL_NO_TIMEOUT);
 
   nsresult Detach();
 
   // Ability to detach is based on API version (16+), and we also block PowerVR since it has some type
   // of fencing problem. Bug 1100126.
-  bool CanDetach() { return gfxPlatform::GetPlatform()->CanDetachSurfaceTexture(); }
+  bool CanDetach() { return mCanDetach; }
 
   GLContext* GetAttachedContext() { return mAttachedContext; }
 
   AndroidNativeWindow* NativeWindow() {
     return mNativeWindow;
   }
 
   // This attaches the updated data to the TEXTURE_EXTERNAL target
@@ -90,23 +90,25 @@ public:
   GLuint Texture() { return mTexture; }
   const widget::sdk::Surface::Ref& JavaSurface() { return mSurface; }
 
 private:
   AndroidSurfaceTexture();
   ~AndroidSurfaceTexture();
 
   bool Init(GLContext* aContext, GLuint aTexture);
+  void UpdateCanDetach();
 
   GLuint mTexture;
   widget::sdk::SurfaceTexture::GlobalRef mSurfaceTexture;
   widget::sdk::Surface::GlobalRef mSurface;
 
   Monitor mMonitor;
   GLContext* mAttachedContext;
+  bool mCanDetach;
 
   RefPtr<AndroidNativeWindow> mNativeWindow;
   int mID;
   nsCOMPtr<nsIRunnable> mFrameAvailableCallback;
 };
 
 }
 }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -78,17 +78,16 @@
 #include "mozilla/gfx/Logging.h"
 
 #if defined(MOZ_WIDGET_GTK)
 #include "gfxPlatformGtk.h" // xxx - for UseFcFontList
 #endif
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "TexturePoolOGL.h"
-#include "AndroidBridge.h"
 #endif
 
 #ifdef MOZ_WIDGET_GONK
 #include "mozilla/layers/GrallocTextureHost.h"
 #endif
 
 #include "mozilla/Hal.h"
 #ifdef USE_SKIA
@@ -575,28 +574,16 @@ gfxPlatform::Init()
       NS_RUNTIMEABORT("Could not initialize ImageLib");
     }
 
     RegisterStrongMemoryReporter(new GfxMemoryImageReporter());
 
     if (XRE_IsParentProcess() && gfxPrefs::HardwareVsyncEnabled()) {
       gPlatform->mVsyncSource = gPlatform->CreateHardwareVsyncSource();
     }
-
-    // The API for attach/detach only exists on 16+, and PowerVR has some sort of
-    // fencing issue. Additionally, attach/detach seems to be busted on at least some
-    // Mali adapters (400MP2 for sure, bug 1131793)
-#ifdef MOZ_WIDGET_ANDROID
-    nsString vendorID;
-    gfxInfo->GetAdapterVendorID(vendorID);
-    gPlatform->mCanDetachSurfaceTexture = AndroidBridge::Bridge()->GetAPIVersion() >= 16 &&
-      !vendorID.EqualsLiteral("Imagination") &&
-      !vendorID.EqualsLiteral("ARM") &&
-      Preferences::GetBool("gfx.SurfaceTexture.detach.enabled", true);
-#endif
 }
 
 static bool sLayersIPCIsUp = false;
 
 void
 gfxPlatform::Shutdown()
 {
     if (!gPlatform) {
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -36,17 +36,16 @@ class gfxTextRun;
 class nsIURI;
 class nsIAtom;
 class nsIObserver;
 class SRGBOverrideObserver;
 
 namespace mozilla {
 namespace gl {
 class SkiaGLGlue;
-class GLContext;
 } // namespace gl
 namespace gfx {
 class DrawTarget;
 class SourceSurface;
 class DataSourceSurface;
 class ScaledFont;
 class DrawEventRecorder;
 class VsyncSource;
@@ -224,17 +223,17 @@ public:
 
     already_AddRefed<DrawTarget>
       CreateOffscreenContentDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
 
     already_AddRefed<DrawTarget>
       CreateOffscreenCanvasDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
 
     virtual already_AddRefed<DrawTarget>
-      CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize,
+      CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize, 
                               int32_t aStride, mozilla::gfx::SurfaceFormat aFormat);
 
     /**
      * Returns true if rendering to data surfaces produces the same results as
      * rendering to offscreen surfaces on this platform, making it safe to
      * render content to data surfaces. This is generally false on platforms
      * which use different backends for each type of DrawTarget.
      */
@@ -338,18 +337,18 @@ public:
 
     /**
      * Create the appropriate platform font group
      */
     virtual gfxFontGroup
     *CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
                      const gfxFontStyle *aStyle,
                      gfxUserFontSet *aUserFontSet) = 0;
-
-
+                                          
+                                          
     /**
      * Look up a local platform font using the full font face name.
      * (Needed to support @font-face src local().)
      * Ownership of the returned gfxFontEntry is passed to the caller,
      * who must either AddRef() or delete.
      */
     virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
                                           uint16_t aWeight,
@@ -430,17 +429,17 @@ public:
 
     // check whether format is supported on a platform or not (if unclear, returns true)
     virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) { return false; }
 
     virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr) { return false; }
 
     // in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs
     void GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang);
-
+    
     /**
      * Iterate over pref fonts given a list of lang groups.  For a single lang
      * group, multiple pref fonts are possible.  If error occurs, returns false,
      * true otherwise.  Callback returns false to abort process.
      */
     typedef bool (*PrefFontCallback) (eFontPrefLang aLang, const nsAString& aName,
                                         void *aClosure);
     static bool ForEachPrefFont(eFontPrefLang aLangArray[], uint32_t aLangArrayLen,
@@ -453,23 +452,23 @@ public:
     // convert a lang group atom to enum constant
     static eFontPrefLang GetFontPrefLangFor(nsIAtom *aLang);
 
     // convert an enum constant to a lang group atom
     static nsIAtom* GetLangGroupForPrefLang(eFontPrefLang aLang);
 
     // convert a enum constant to lang group string (i.e. eFontPrefLang_ChineseTW ==> "zh-TW")
     static const char* GetPrefLangName(eFontPrefLang aLang);
-
+   
     // map a Unicode range (based on char code) to a font language for Preferences
     static eFontPrefLang GetFontPrefLangFor(uint8_t aUnicodeRange);
 
     // returns true if a pref lang is CJK
     static bool IsLangCJK(eFontPrefLang aLang);
-
+    
     // helper method to add a pref lang to an array, if not already in array
     static void AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang);
 
     // returns a list of commonly used fonts for a given character
     // these are *possible* matches, no cmap-checking is done at this level
     virtual void GetCommonFallbackFonts(uint32_t /*aCh*/, uint32_t /*aNextCh*/,
                                         int32_t /*aRunScript*/,
                                         nsTArray<const char*>& /*aFontList*/)
@@ -648,22 +647,16 @@ public:
     // Trigger a test-driven graphics device reset.
     virtual void TestDeviceReset(DeviceResetReason aReason)
     {}
 
     // Return information on how child processes should initialize graphics
     // devices. Currently this is only used on Windows.
     virtual void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut);
 
-    /**
-     * Used to test whether surface texture detach is enabled. Ability to detach
-     * is based on API Version and device GPU as well as a preference.
-     */
-    bool CanDetachSurfaceTexture() { return mCanDetachSurfaceTexture; }
-
 protected:
     gfxPlatform();
     virtual ~gfxPlatform();
 
     void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen,
                             eFontPrefLang aCharLang, eFontPrefLang aPageLang);
 
     /**
@@ -731,17 +724,17 @@ protected:
       GetScaledFontForFontWithCairoSkia(mozilla::gfx::DrawTarget* aTarget, gfxFont* aFont);
 
     int8_t  mAllowDownloadableFonts;
     int8_t  mGraphiteShapingEnabled;
     int8_t  mOpenTypeSVGEnabled;
 
     int8_t  mBidiNumeralOption;
 
-    // whether to always search font cmaps globally
+    // whether to always search font cmaps globally 
     // when doing system font fallback
     int8_t  mFallbackUsesCmaps;
 
     // max character limit for words in word cache
     int32_t mWordCacheCharLimit;
 
     // max number of entries in word cache
     int32_t mWordCacheMaxEntries;
@@ -789,13 +782,11 @@ private:
     mozilla::widget::GfxInfoCollector<gfxPlatform> mApzSupportCollector;
 
     mozilla::RefPtr<mozilla::gfx::DrawEventRecorder> mRecorder;
     mozilla::RefPtr<mozilla::gl::SkiaGLGlue> mSkiaGlue;
 
     // Backend that we are compositing with. NONE, if no compositor has been
     // created yet.
     mozilla::layers::LayersBackend mCompositorBackend;
-
-    bool mCanDetachSurfaceTexture;
 };
 
 #endif /* GFX_PLATFORM_H */