Backed out changesets a99bd0b3b075, a7fb851f823a, and 9fc2d99376cd (bug 552020) for non-unified bustage and OSX 10.6 tsvgr crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 14 Nov 2014 15:57:35 -0500
changeset 242277 647ec1593edb4ef1fe148db1813ea5f635d52796
parent 242276 d26d34236c4eddd67b0c88cfe85808253aff7181
child 242278 acbd7b68fa8c7c8cfa542adf9a9adeca2df9e46c
child 242282 9b77a97a378b4a7cb7ef0ddc30093dc9f00879f6
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs552020
milestone36.0a1
backs outa99bd0b3b0759be1419cd06b3d4e971ae2abb35f
a7fb851f823a4452aa6311553cd5d4a84040460e
9fc2d99376cdb7c1873cd3f7e0d80c65590aa068
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 changesets a99bd0b3b075, a7fb851f823a, and 9fc2d99376cd (bug 552020) for non-unified bustage and OSX 10.6 tsvgr crashes. CLOSED TREE
gfx/layers/ipc/CompositorParent.cpp
widget/VsyncDispatcher.cpp
widget/VsyncDispatcher.h
widget/cocoa/nsAppShell.h
widget/cocoa/nsAppShell.mm
widget/gonk/HwcComposer2D.cpp
widget/gonk/nsAppShell.cpp
xpcom/ds/TimeStamp.h
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -1325,17 +1325,17 @@ InsertVsyncProfilerMarker(TimeStamp aVsy
   VsyncPayload* payload = new VsyncPayload(aVsyncTimestamp);
   PROFILER_MARKER_PAYLOAD("VsyncTimestamp", payload);
 #endif
 }
 
 /*static */ void
 CompositorParent::PostInsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
 {
-  if (profiler_is_active() && sCompositorThreadHolder) {
+  if (profiler_is_active()) {
     CompositorLoop()->PostTask(FROM_HERE,
       NewRunnableFunction(InsertVsyncProfilerMarker, aVsyncTimestamp));
   }
 }
 
 /**
  * This class handles layer updates pushed directly from child
  * processes to the compositor thread.  It's associated with a
--- a/widget/VsyncDispatcher.cpp
+++ b/widget/VsyncDispatcher.cpp
@@ -3,21 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "VsyncDispatcher.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/layers/CompositorParent.h"
 #include "gfxPrefs.h"
 
-#ifdef MOZ_ENABLE_PROFILER_SPS
-#include "GeckoProfiler.h"
-#include "ProfilerMarkers.h"
-#endif
-
 #ifdef MOZ_WIDGET_GONK
 #include "GeckoTouchDispatcher.h"
 #endif
 
 using namespace mozilla::layers;
 
 namespace mozilla {
 
@@ -42,43 +37,31 @@ VsyncDispatcher::VsyncDispatcher()
 
 VsyncDispatcher::~VsyncDispatcher()
 {
   MutexAutoLock lock(mCompositorObserverLock);
   mCompositorObservers.Clear();
 }
 
 void
-VsyncDispatcher::SetVsyncSource(VsyncSource* aVsyncSource)
-{
-  mVsyncSource = aVsyncSource;
-}
-
-void
 VsyncDispatcher::DispatchTouchEvents(bool aNotifiedCompositors, TimeStamp aVsyncTime)
 {
   // Touch events can sometimes start a composite, so make sure we dispatch touches
   // even if we don't composite
 #ifdef MOZ_WIDGET_GONK
   if (!aNotifiedCompositors && gfxPrefs::TouchResampling()) {
     GeckoTouchDispatcher::NotifyVsync(aVsyncTime);
   }
 #endif
 }
 
 void
 VsyncDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
 {
   bool notifiedCompositors = false;
-#ifdef MOZ_ENABLE_PROFILER_SPS
-    if (profiler_is_active()) {
-        CompositorParent::PostInsertVsyncProfilerMarker(aVsyncTimestamp);
-    }
-#endif
-
   if (gfxPrefs::VsyncAlignedCompositor()) {
     MutexAutoLock lock(mCompositorObserverLock);
     notifiedCompositors = NotifyVsyncObservers(aVsyncTimestamp, mCompositorObservers);
   }
 
   DispatchTouchEvents(notifiedCompositors, aVsyncTimestamp);
 }
 
@@ -100,17 +83,17 @@ VsyncDispatcher::AddCompositorVsyncObser
   if (!mCompositorObservers.Contains(aVsyncObserver)) {
     mCompositorObservers.AppendElement(aVsyncObserver);
   }
 }
 
 void
 VsyncDispatcher::RemoveCompositorVsyncObserver(VsyncObserver* aVsyncObserver)
 {
-  MOZ_ASSERT(CompositorParent::IsInCompositorThread() || NS_IsMainThread());
+  MOZ_ASSERT(CompositorParent::IsInCompositorThread());
   MutexAutoLock lock(mCompositorObserverLock);
   if (mCompositorObservers.Contains(aVsyncObserver)) {
     mCompositorObservers.RemoveElement(aVsyncObserver);
   } else {
     NS_WARNING("Could not delete a compositor vsync observer\n");
   }
 }
 
--- a/widget/VsyncDispatcher.h
+++ b/widget/VsyncDispatcher.h
@@ -16,73 +16,53 @@ class MessageLoop;
 
 namespace mozilla {
 class TimeStamp;
 
 namespace layers {
 class CompositorVsyncObserver;
 }
 
-// Controls how and when to enable/disable vsync.
-class VsyncSource
-{
-public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncSource)
-  virtual void EnableVsync() = 0;
-  virtual void DisableVsync() = 0;
-  virtual bool IsVsyncEnabled() = 0;
-
-protected:
-  virtual ~VsyncSource() {}
-}; // VsyncSource
-
 class VsyncObserver
 {
   // Must be destroyed on main thread since the compositor is as well
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(VsyncObserver)
 
 public:
   // The method called when a vsync occurs. Return true if some work was done.
   // Vsync notifications will occur on the hardware vsync thread
   virtual bool NotifyVsync(TimeStamp aVsyncTimestamp) = 0;
 
 protected:
   VsyncObserver() {}
   virtual ~VsyncObserver() {}
-}; // VsyncObserver
+};
 
 // VsyncDispatcher is used to dispatch vsync events to the registered observers.
 class VsyncDispatcher
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncDispatcher)
 
 public:
   static VsyncDispatcher* GetInstance();
   // Called on the vsync thread when a hardware vsync occurs
-  // The aVsyncTimestamp can mean different things depending on the platform:
-  // b2g - The vsync timestamp of the previous frame that was just displayed
-  // OSX - The vsync timestamp of the upcoming frame
-  // TODO: Windows / Linux. DOCUMENT THIS WHEN IMPLEMENTING ON THOSE PLATFORMS
-  // Android: TODO
   void NotifyVsync(TimeStamp aVsyncTimestamp);
-  void SetVsyncSource(VsyncSource* aVsyncSource);
 
   // Compositor vsync observers must be added/removed on the compositor thread
   void AddCompositorVsyncObserver(VsyncObserver* aVsyncObserver);
   void RemoveCompositorVsyncObserver(VsyncObserver* aVsyncObserver);
 
 private:
   VsyncDispatcher();
   virtual ~VsyncDispatcher();
   void DispatchTouchEvents(bool aNotifiedCompositors, TimeStamp aVsyncTime);
 
   // Called on the vsync thread. Returns true if observers were notified
   bool NotifyVsyncObservers(TimeStamp aVsyncTimestamp, nsTArray<nsRefPtr<VsyncObserver>>& aObservers);
 
   // Can have multiple compositors. On desktop, this is 1 compositor per window
   Mutex mCompositorObserverLock;
   nsTArray<nsRefPtr<VsyncObserver>> mCompositorObservers;
-  nsRefPtr<VsyncSource> mVsyncSource;
-}; // VsyncDispatcher
+};
 
 } // namespace mozilla
 
 #endif // __mozilla_widget_VsyncDispatcher_h
--- a/widget/cocoa/nsAppShell.h
+++ b/widget/cocoa/nsAppShell.h
@@ -1,16 +1,16 @@
 /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Runs the main native Cocoa run loop, interrupting it as needed to process
- * Gecko events.
+ * Gecko events.  
  */
 
 #ifndef nsAppShell_h_
 #define nsAppShell_h_
 
 class nsCocoaWindow;
 
 #include "nsBaseAppShell.h"
@@ -25,17 +25,17 @@ class nsCocoaWindow;
 @end
 
 @class AppShellDelegate;
 
 class nsAppShell : public nsBaseAppShell
 {
 public:
   NS_IMETHOD ResumeNative(void);
-
+	
   nsAppShell();
 
   nsresult Init();
 
   NS_IMETHOD Run(void);
   NS_IMETHOD Exit(void);
   NS_IMETHOD OnProcessNextEvent(nsIThreadInternal *aThread, bool aMayWait,
                                 uint32_t aRecursionDepth);
--- a/widget/cocoa/nsAppShell.mm
+++ b/widget/cocoa/nsAppShell.mm
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Runs the main native Cocoa run loop, interrupting it as needed to process
  * Gecko events.
  */
 
 #import <Cocoa/Cocoa.h>
-#import <CoreVideo/CoreVideo.h>
 
 #include "CustomCocoaEvents.h"
 #include "mozilla/WidgetTraceEvent.h"
 #include "nsAppShell.h"
 #include "nsCOMPtr.h"
 #include "nsIFile.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsString.h"
@@ -33,19 +32,16 @@
 #include "TextInputHandler.h"
 #include "mozilla/HangMonitor.h"
 #include "GeckoProfiler.h"
 #include "pratom.h"
 
 #include <IOKit/pwr_mgt/IOPMLib.h>
 #include "nsIDOMWakeLockListener.h"
 #include "nsIPowerManagerService.h"
-#include "mozilla/TimeStamp.h"
-#include "mozilla/VsyncDispatcher.h"
-#include "gfxPrefs.h"
 
 using namespace mozilla::widget;
 
 // A wake lock listener that disables screen saver when requested by
 // Gecko. For example when we're playing video in a foreground tab we
 // don't want the screen saver to turn on.
 
 class MacWakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener {
@@ -86,95 +82,17 @@ private:
         IOReturn result = ::IOPMAssertionRelease(mAssertionID);
         if (result != kIOReturnSuccess) {
           NS_WARNING("failed to release screensaver");
         }
       }
     }
     return NS_OK;
   }
-}; // MacWakeLockListener
-
-// This is the renderer output callback function, called on the vsync thread
-static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink,
-                              const CVTimeStamp* aNow,
-                              const CVTimeStamp* aOutputTime,
-                              CVOptionFlags aFlagsIn,
-                              CVOptionFlags* aFlagsOut,
-                              void* aDisplayLinkContext)
-{
-  VsyncSource* vsyncSource = (VsyncSource*) aDisplayLinkContext;
-  if (vsyncSource->IsVsyncEnabled()) {
-    // Now refers to "Now" as in when this callback is called or when the current frame
-    // is displayed. aOutputTime is when the next frame should be displayed.
-    // Now is VERY VERY noisy, aOutputTime is in the future though.
-    int64_t timestamp = aOutputTime->hostTime;
-    mozilla::TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(timestamp);
-    mozilla::VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
-    return kCVReturnSuccess;
-  } else {
-    return kCVReturnDisplayLinkNotRunning;
-  }
-}
-
-class OSXVsyncSource MOZ_FINAL : public VsyncSource
-{
-public:
-  OSXVsyncSource()
-  {
-    EnableVsync();
-  }
-
-  virtual void EnableVsync() MOZ_OVERRIDE
-  {
-    // Create a display link capable of being used with all active displays
-    // TODO: See if we need to create an active DisplayLink for each monitor in multi-monitor
-    // situations. According to the docs, it is compatible with all displays running on the computer
-    // But if we have different monitors at different display rates, we may hit issues.
-    if (CVDisplayLinkCreateWithActiveCGDisplays(&mDisplayLink) != kCVReturnSuccess) {
-      NS_WARNING("Could not create a display link, returning");
-      return;
-    }
-
-    // Set the renderer output callback function
-    if (CVDisplayLinkSetOutputCallback(mDisplayLink, &VsyncCallback, this) != kCVReturnSuccess) {
-      NS_WARNING("Could not set displaylink output callback");
-      return;
-    }
-
-    // Activate the display link
-    if (CVDisplayLinkStart(mDisplayLink) != kCVReturnSuccess) {
-      NS_WARNING("Could not activate the display link");
-      mDisplayLink = nullptr;
-    }
-  }
-
-  virtual void DisableVsync() MOZ_OVERRIDE
-  {
-    // Release the display link
-    if (mDisplayLink) {
-      CVDisplayLinkRelease(mDisplayLink);
-      mDisplayLink = nullptr;
-    }
-  }
-
-  virtual bool IsVsyncEnabled() MOZ_OVERRIDE
-  {
-    return mDisplayLink != nullptr;
-  }
-
-private:
-  virtual ~OSXVsyncSource()
-  {
-    DisableVsync();
-  }
-
-  // Manages the display link render thread
-  CVDisplayLinkRef   mDisplayLink;
-}; // OSXVsyncSource
+};
 
 // defined in nsCocoaWindow.mm
 extern int32_t             gXULModalLevel;
 
 static bool gAppShellMethodsSwizzled = false;
 
 @implementation GeckoNSApplication
 
@@ -364,33 +282,24 @@ nsAppShell::Init()
   NS_ENSURE_STATE(mCFRunLoop);
   ::CFRetain(mCFRunLoop);
 
   CFRunLoopSourceContext context;
   bzero(&context, sizeof(context));
   // context.version = 0;
   context.info = this;
   context.perform = ProcessGeckoEvents;
-
+  
   mCFRunLoopSource = ::CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context);
   NS_ENSURE_STATE(mCFRunLoopSource);
 
   ::CFRunLoopAddSource(mCFRunLoop, mCFRunLoopSource, kCFRunLoopCommonModes);
 
   rv = nsBaseAppShell::Init();
 
-  // gfxPrefs are init on the main thread and we need it super early
-  // to see if we should enable vsync aligned compositor
-  gfxPrefs::GetSingleton();
-  if (gfxPrefs::HardwareVsyncEnabled() && gfxPrefs::VsyncAlignedCompositor())
-  {
-    nsRefPtr<VsyncSource> osxVsyncSource = new OSXVsyncSource();
-    mozilla::VsyncDispatcher::GetInstance()->SetVsyncSource(osxVsyncSource);
-  }
-
 #ifndef __LP64__
   TextInputHandler::InstallPluginKeyEventsHandler();
 #endif
 
   if (!gAppShellMethodsSwizzled) {
     // We should only replace the original terminate: method if we're not
     // running in a Cocoa embedder. See bug 604901.
     if (!mRunningCocoaEmbedded) {
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -24,16 +24,22 @@
 #include "mozilla/layers/CompositorParent.h"
 #include "mozilla/layers/LayerManagerComposite.h"
 #include "mozilla/layers/PLayerTransaction.h"
 #include "mozilla/layers/ShadowLayerUtilsGralloc.h"
 #include "mozilla/layers/TextureHostOGL.h"  // for TextureHostOGL
 #include "mozilla/StaticPtr.h"
 #include "cutils/properties.h"
 #include "gfx2DGlue.h"
+#include "GeckoTouchDispatcher.h"
+
+#ifdef MOZ_ENABLE_PROFILER_SPS
+#include "GeckoProfiler.h"
+#include "ProfilerMarkers.h"
+#endif
 
 #if ANDROID_VERSION >= 17
 #include "libdisplay/FramebufferSurface.h"
 #include "gfxPrefs.h"
 #include "nsThreadUtils.h"
 
 #ifndef HWC_BLIT
 #define HWC_BLIT (HWC_FRAMEBUFFER_TARGET + 1)
@@ -226,22 +232,29 @@ HwcComposer2D::RunVsyncEventControl(bool
             device->eventControl(device, HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, aEnable);
         }
     }
 }
 
 void
 HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
 {
-    TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(aVsyncTimestamp);
+    TimeStamp vsyncTime = mozilla::TimeStamp(aVsyncTimestamp);
     nsecs_t vsyncInterval = aVsyncTimestamp - mLastVsyncTime;
     if (vsyncInterval < 16000000 || vsyncInterval > 17000000) {
       LOGE("Non-uniform vsync interval: %lld\n", vsyncInterval);
     }
     mLastVsyncTime = aVsyncTimestamp;
+
+#ifdef MOZ_ENABLE_PROFILER_SPS
+    if (profiler_is_active()) {
+        CompositorParent::PostInsertVsyncProfilerMarker(vsyncTime);
+    }
+#endif
+
     VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
 }
 
 // Called on the "invalidator" thread (run from HAL).
 void
 HwcComposer2D::Invalidate()
 {
     if (!Initialized()) {
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -710,17 +710,17 @@ addMultiTouch(MultiTouchInput& aMultiTou
 
 void
 GeckoInputDispatcher::notifyMotion(const NotifyMotionArgs* args)
 {
     uint32_t time = nanosecsToMillisecs(args->eventTime);
     int32_t action = args->action & AMOTION_EVENT_ACTION_MASK;
     int touchCount = args->pointerCount;
     MOZ_ASSERT(touchCount <= MAX_POINTERS);
-    TimeStamp timestamp = mozilla::TimeStamp::FromSystemTime(args->eventTime);
+    TimeStamp timestamp = TimeStamp(args->eventTime);
     Modifiers modifiers = getDOMModifiers(args->metaState);
 
     MultiTouchInput::MultiTouchType touchType = MultiTouchInput::MULTITOUCH_CANCEL;
     switch (action) {
     case AMOTION_EVENT_ACTION_DOWN:
     case AMOTION_EVENT_ACTION_POINTER_DOWN:
         touchType = MultiTouchInput::MULTITOUCH_START;
         break;
--- a/xpcom/ds/TimeStamp.h
+++ b/xpcom/ds/TimeStamp.h
@@ -382,30 +382,21 @@ class TimeStamp
 {
 public:
   /**
    * Initialize to the "null" moment
    */
   MOZ_CONSTEXPR TimeStamp() : mValue(0) {}
   // Default copy-constructor and assignment are OK
 
-  /**
-   * The system timestamps are the same as the TimeStamp
-   * retrieved by mozilla::TimeStamp. Since we need this for
-   * vsync timestamps, we enable the creation of mozilla::TimeStamps
-   * on platforms that support vsync aligned refresh drivers / compositors
-   * Verified true as of Nov 7, 2014: B2G and OS X
-   * UNTESTED ON OTHER PLATFORMS
-   */
-#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_COCOA)
-  static TimeStamp FromSystemTime(int64_t aSystemTime)
+#ifdef MOZ_WIDGET_GONK
+  TimeStamp(int64_t aAndroidTime) : mValue(aAndroidTime)
   {
-    static_assert(sizeof(aSystemTime) == sizeof(TimeStampValue),
-                  "System timestamp should be same units as TimeStampValue");
-    return TimeStamp(aSystemTime);
+    static_assert(sizeof(aAndroidTime) == sizeof(TimeStampValue),
+                  "Android timestamp should be same units as TimeStampValue");
   }
 #endif
 
   /**
    * Return true if this is the "null" moment
    */
   bool IsNull() const { return mValue == 0; }