Backed out changeset 1662b38e3107 (bug 1351148)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 28 Jul 2017 09:20:23 +0200
changeset 420159 b789b817d9627100b1cda5524530e85bdf0dabb6
parent 420158 95551faed54a120214d16620af6fa8d2da50dfa5
child 420160 f2b817a915de6331c85e98a4151704a806b6530e
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1351148
milestone56.0a1
backs out1662b38e3107e1e270fb3dc708ff3feef7c68cb4
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 1662b38e3107 (bug 1351148)
dom/base/nsDOMWindowUtils.cpp
gfx/layers/apz/test/mochitest/helper_touch_action_regions.html
xpcom/threads/nsIRunnable.idl
xpcom/threads/nsIThreadManager.idl
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadUtils.cpp
xpcom/threads/nsThreadUtils.h
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -170,40 +170,16 @@ private:
     return item;
   }
 
   static LinkedList<OldWindowSize> sList;
   nsWeakPtr mWindowRef;
   nsSize mSize;
 };
 
-namespace {
-
-class NativeInputRunnable final : public PrioritizableRunnable
-{
-  explicit NativeInputRunnable(already_AddRefed<nsIRunnable>&& aEvent);
-  ~NativeInputRunnable() {}
-public:
-  static already_AddRefed<nsIRunnable> Create(already_AddRefed<nsIRunnable>&& aEvent);
-};
-
-NativeInputRunnable::NativeInputRunnable(already_AddRefed<nsIRunnable>&& aEvent)
-  : PrioritizableRunnable(Move(aEvent), nsIRunnablePriority::PRIORITY_INPUT)
-{
-}
-
-/* static */ already_AddRefed<nsIRunnable>
-NativeInputRunnable::Create(already_AddRefed<nsIRunnable>&& aEvent)
-{
-  nsCOMPtr<nsIRunnable> event(new NativeInputRunnable(Move(aEvent)));
-  return event.forget();
-}
-
-} // unnamed namespace
-
 LinkedList<OldWindowSize> OldWindowSize::sList;
 
 NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
@@ -1139,77 +1115,76 @@ nsDOMWindowUtils::SendNativeKeyEvent(int
                                      const nsAString& aUnmodifiedCharacters,
                                      nsIObserver* aObserver)
 {
   // get the widget to send the event to
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget)
     return NS_ERROR_FAILURE;
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
+  NS_DispatchToMainThread(
     NewRunnableMethod<int32_t,
                       int32_t,
                       uint32_t,
                       nsString,
                       nsString,
                       nsIObserver*>("nsIWidget::SynthesizeNativeKeyEvent",
                                     widget,
                                     &nsIWidget::SynthesizeNativeKeyEvent,
                                     aNativeKeyboardLayout,
                                     aNativeKeyCode,
                                     aModifiers,
                                     aCharacters,
                                     aUnmodifiedCharacters,
-                                    aObserver)));
+                                    aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
                                        int32_t aScreenY,
                                        int32_t aNativeMessage,
                                        int32_t aModifierFlags,
                                        nsIDOMElement* aElement,
                                        nsIObserver* aObserver)
 {
   // get the widget to send the event to
   nsCOMPtr<nsIWidget> widget = GetWidgetForElement(aElement);
   if (!widget)
     return NS_ERROR_FAILURE;
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
+  NS_DispatchToMainThread(
     NewRunnableMethod<LayoutDeviceIntPoint, int32_t, int32_t, nsIObserver*>(
       "nsIWidget::SynthesizeNativeMouseEvent",
       widget,
       &nsIWidget::SynthesizeNativeMouseEvent,
       LayoutDeviceIntPoint(aScreenX, aScreenY),
       aNativeMessage,
       aModifierFlags,
-      aObserver)));
+      aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SendNativeMouseMove(int32_t aScreenX,
                                       int32_t aScreenY,
                                       nsIDOMElement* aElement,
                                       nsIObserver* aObserver)
 {
   // get the widget to send the event to
   nsCOMPtr<nsIWidget> widget = GetWidgetForElement(aElement);
   if (!widget)
     return NS_ERROR_FAILURE;
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
-    NewRunnableMethod<LayoutDeviceIntPoint, nsIObserver*>(
-      "nsIWidget::SynthesizeNativeMouseMove",
-      widget,
-      &nsIWidget::SynthesizeNativeMouseMove,
-      LayoutDeviceIntPoint(aScreenX, aScreenY),
-      aObserver)));
+  NS_DispatchToMainThread(NewRunnableMethod<LayoutDeviceIntPoint, nsIObserver*>(
+    "nsIWidget::SynthesizeNativeMouseMove",
+    widget,
+    &nsIWidget::SynthesizeNativeMouseMove,
+    LayoutDeviceIntPoint(aScreenX, aScreenY),
+    aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
                                              int32_t aScreenY,
                                              uint32_t aNativeMessage,
                                              double aDeltaX,
@@ -1221,36 +1196,35 @@ nsDOMWindowUtils::SendNativeMouseScrollE
                                              nsIObserver* aObserver)
 {
   // get the widget to send the event to
   nsCOMPtr<nsIWidget> widget = GetWidgetForElement(aElement);
   if (!widget) {
     return NS_ERROR_FAILURE;
   }
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
-    NewRunnableMethod<mozilla::LayoutDeviceIntPoint,
-                      uint32_t,
-                      double,
-                      double,
-                      double,
-                      uint32_t,
-                      uint32_t,
-                      nsIObserver*>(
-      "nsIWidget::SynthesizeNativeMouseScrollEvent",
-      widget,
-      &nsIWidget::SynthesizeNativeMouseScrollEvent,
-      LayoutDeviceIntPoint(aScreenX, aScreenY),
-      aNativeMessage,
-      aDeltaX,
-      aDeltaY,
-      aDeltaZ,
-      aModifierFlags,
-      aAdditionalFlags,
-      aObserver)));
+  NS_DispatchToMainThread(NewRunnableMethod<mozilla::LayoutDeviceIntPoint,
+                                            uint32_t,
+                                            double,
+                                            double,
+                                            double,
+                                            uint32_t,
+                                            uint32_t,
+                                            nsIObserver*>(
+    "nsIWidget::SynthesizeNativeMouseScrollEvent",
+    widget,
+    &nsIWidget::SynthesizeNativeMouseScrollEvent,
+    LayoutDeviceIntPoint(aScreenX, aScreenY),
+    aNativeMessage,
+    aDeltaX,
+    aDeltaY,
+    aDeltaZ,
+    aModifierFlags,
+    aAdditionalFlags,
+    aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
                                        uint32_t aTouchState,
                                        int32_t aScreenX,
                                        int32_t aScreenY,
@@ -1262,53 +1236,53 @@ nsDOMWindowUtils::SendNativeTouchPoint(u
   if (!widget) {
     return NS_ERROR_FAILURE;
   }
 
   if (aPressure < 0 || aPressure > 1 || aOrientation > 359) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
+  NS_DispatchToMainThread(
     NewRunnableMethod<uint32_t,
                       nsIWidget::TouchPointerState,
                       LayoutDeviceIntPoint,
                       double,
                       uint32_t,
                       nsIObserver*>("nsIWidget::SynthesizeNativeTouchPoint",
                                     widget,
                                     &nsIWidget::SynthesizeNativeTouchPoint,
                                     aPointerId,
                                     (nsIWidget::TouchPointerState)aTouchState,
                                     LayoutDeviceIntPoint(aScreenX, aScreenY),
                                     aPressure,
                                     aOrientation,
-                                    aObserver)));
+                                    aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
                                      int32_t aScreenY,
                                      bool aLongTap,
                                      nsIObserver* aObserver)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return NS_ERROR_FAILURE;
   }
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
+  NS_DispatchToMainThread(
     NewRunnableMethod<LayoutDeviceIntPoint, bool, nsIObserver*>(
       "nsIWidget::SynthesizeNativeTouchTap",
       widget,
       &nsIWidget::SynthesizeNativeTouchTap,
       LayoutDeviceIntPoint(aScreenX, aScreenY),
       aLongTap,
-      aObserver)));
+      aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SuppressAnimation(bool aSuppress)
 {
   nsIWidget* widget = GetWidget();
   if (widget) {
@@ -1320,21 +1294,21 @@ nsDOMWindowUtils::SuppressAnimation(bool
 NS_IMETHODIMP
 nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return NS_ERROR_FAILURE;
   }
 
-  NS_DispatchToMainThread(NativeInputRunnable::Create(
+  NS_DispatchToMainThread(
     NewRunnableMethod<nsIObserver*>("nsIWidget::ClearNativeTouchSequence",
                                     widget,
                                     &nsIWidget::ClearNativeTouchSequence,
-                                    aObserver)));
+                                    aObserver));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::ActivateNativeMenuItemAt(const nsAString& indexString)
 {
   // get the widget to send the event to
   nsCOMPtr<nsIWidget> widget = GetWidget();
--- a/gfx/layers/apz/test/mochitest/helper_touch_action_regions.html
+++ b/gfx/layers/apz/test/mochitest/helper_touch_action_regions.html
@@ -88,21 +88,16 @@ function waitFor(eventType, count) {
     if (Date.now() - start > 10000) {
       // It's taking too long, let's abort
       return false;
     }
   }
   return true;
 }
 
-function RunAfterProcessedQueuedInputEvents(aCallback) {
-  let tm = SpecialPowers.Services.tm;
-  tm.dispatchToMainThread(aCallback, SpecialPowers.Ci.nsIRunnablePriority.PRIORITY_INPUT);
-}
-
 function* test(testDriver) {
   // The main part of this test should run completely before the child process'
   // main-thread deals with the touch event, so check to make sure that happens.
   document.body.addEventListener('touchstart', failure, { passive: true });
 
   // What we want here is to synthesize all of the touch events (from this code in
   // the child process), and have the chrome process generate and process them,
   // but not allow the events to be dispatched back into the child process until
@@ -139,29 +134,26 @@ function* test(testDriver) {
   //     handle DOM touchstart  <-- touchstart goes at end of queue
   //
   // As we continue yielding one at a time, the synthesizations run, and the
   // touch events get added to the end of the queue. As we yield, we take
   // snapshots in the chrome process, to make sure that the APZ has started
   // scrolling even though we know we haven't yet processed the DOM touch events
   // in the child process yet.
   //
-  // Note that the "async callback" we use here is SpecialPowers.tm.dispatchToMainThread
-  // with priority = input, because nothing else does exactly what we want:
+  // Note that the "async callback" we use here is SpecialPowers.executeSoon,
+  // because nothing else does exactly what we want:
   // - setTimeout(..., 0) does not maintain ordering, because it respects the
   //   time delta provided (i.e. the callback can jump the queue to meet its
   //   deadline).
   // - SpecialPowers.spinEventLoop and SpecialPowers.executeAfterFlushingMessageQueue
   //   are not e10s friendly, and can get arbitrarily delayed due to IPC
   //   round-trip time.
   // - SimpleTest.executeSoon has a codepath that delegates to setTimeout, so
   //   is less reliable if it ever decides to switch to that codepath.
-  // - SpecialPowers.executeSoon dispatches a task to main thread. However,
-  //   normal runnables may be preempted by input events and be executed in an
-  //   unexpected order.
 
   // The other problem we need to deal with is the asynchronicity in the chrome
   // process. That is, we might request a snapshot before the chrome process has
   // actually synthesized the event and processed it. To guard against this, we
   // register a thing in the chrome process that counts the touch events that
   // have been dispatched, and poll that thing synchronously in order to make
   // sure we only snapshot after the event in question has been processed.
   // That's what the chromeTouchEventCounter business is all about. The sync
@@ -172,23 +164,23 @@ function* test(testDriver) {
   // So, here we go...
 
   // Set up the chrome process touch listener
   ok(chromeTouchEventCounter('start'), "Chrome touch counter registered");
 
   // Set up the child process events and callbacks
   var scroller = document.getElementById('scroller');
   synthesizeNativeTouch(scroller, 10, 110, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, null, 0);
-  RunAfterProcessedQueuedInputEvents(testDriver);
+  SpecialPowers.executeSoon(testDriver);
   for (var i = 1; i < 10; i++) {
     synthesizeNativeTouch(scroller, 10, 110 - (i * 10), SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, null, 0);
-    RunAfterProcessedQueuedInputEvents(testDriver);
+    SpecialPowers.executeSoon(testDriver);
   }
   synthesizeNativeTouch(scroller, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, null, 0);
-  RunAfterProcessedQueuedInputEvents(testDriver);
+  SpecialPowers.executeSoon(testDriver);
   ok(true, "Finished setting up event queue");
 
   // Get our baseline snapshot
   var rect = rectRelativeToScreen(scroller);
   var lastSnapshot = getSnapshot(rect);
   ok(true, "Got baseline snapshot");
   var numDifferentSnapshotPairs = 0;
 
--- a/xpcom/threads/nsIRunnable.idl
+++ b/xpcom/threads/nsIRunnable.idl
@@ -13,16 +13,16 @@
 interface nsIRunnable : nsISupports
 {
     /**
      * The function implementing the task to be run.
      */
     void run();
 };
 
-[scriptable, uuid(e75aa42a-80a9-11e6-afb5-e89d87348e2c)]
+[uuid(e75aa42a-80a9-11e6-afb5-e89d87348e2c)]
 interface nsIRunnablePriority : nsISupports
 {
     const unsigned short PRIORITY_NORMAL = 0;
     const unsigned short PRIORITY_INPUT = 1;
     const unsigned short PRIORITY_HIGH = 2;
     readonly attribute unsigned long priority;
 };
--- a/xpcom/threads/nsIThreadManager.idl
+++ b/xpcom/threads/nsIThreadManager.idl
@@ -87,17 +87,17 @@ interface nsIThreadManager : nsISupports
   /**
    * This queues a runnable to the main thread. It's a shortcut for JS callers
    * to be used instead of
    *   .mainThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
    * or
    *   .currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
    * C++ callers should instead use NS_DispatchToMainThread.
    */
-  void dispatchToMainThread(in nsIRunnable event, [optional] in uint32_t priority);
+  void dispatchToMainThread(in nsIRunnable event);
 
   /**
    * This queues a runnable to the main thread's idle queue.
    *
    * @param event
    *   The event to dispatch.
    * @param timeout
    *   The time in milliseconds until this event should be moved from the idle
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -381,30 +381,26 @@ nsThreadManager::SpinEventLoopUntilEmpty
 uint32_t
 nsThreadManager::GetHighestNumberOfThreads()
 {
   OffTheBooksMutexAutoLock lock(mLock);
   return mHighestNumberOfThreads;
 }
 
 NS_IMETHODIMP
-nsThreadManager::DispatchToMainThread(nsIRunnable *aEvent, uint32_t aPriority)
+nsThreadManager::DispatchToMainThread(nsIRunnable *aEvent)
 {
   // Note: C++ callers should instead use NS_DispatchToMainThread.
   MOZ_ASSERT(NS_IsMainThread());
 
   // Keep this functioning during Shutdown
   if (NS_WARN_IF(!mMainThread)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
-  if (aPriority != nsIRunnablePriority::PRIORITY_NORMAL) {
-    nsCOMPtr<nsIRunnable> event(aEvent);
-    return mMainThread->DispatchFromScript(
-             new PrioritizableRunnable(event.forget(), aPriority), 0);
-  }
+
   return mMainThread->DispatchFromScript(aEvent, 0);
 }
 
 void
 nsThreadManager::EnableMainThreadEventPrioritization()
 {
   static bool sIsInitialized = false;
   if (sIsInitialized) {
--- a/xpcom/threads/nsThreadUtils.cpp
+++ b/xpcom/threads/nsThreadUtils.cpp
@@ -83,57 +83,16 @@ namespace detail {
 already_AddRefed<nsITimer> CreateTimer()
 {
   nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
   return timer.forget();
 }
 } // namespace detail
 } // namespace mozilla
 
-NS_IMPL_ISUPPORTS_INHERITED(PrioritizableRunnable, Runnable,
-                            nsIRunnablePriority)
-
-PrioritizableRunnable::PrioritizableRunnable(already_AddRefed<nsIRunnable>&& aRunnable,
-                                             uint32_t aPriority)
- // Real runnable name is managed by overridding the GetName function.
- : Runnable("PrioritizableRunnable")
- , mRunnable(Move(aRunnable))
- , mPriority(aPriority)
-{
-#if DEBUG
-  nsCOMPtr<nsIRunnablePriority> runnablePrio = do_QueryInterface(mRunnable);
-  MOZ_ASSERT(!runnablePrio);
-#endif
-}
-
-NS_IMETHODIMP
-PrioritizableRunnable::GetName(nsACString& aName)
-{
-  // Try to get a name from the underlying runnable.
-  nsCOMPtr<nsINamed> named = do_QueryInterface(mRunnable);
-  if (named) {
-    named->GetName(aName);
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-PrioritizableRunnable::Run()
-{
-  MOZ_RELEASE_ASSERT(NS_IsMainThread());
-  return mRunnable->Run();
-}
-
-NS_IMETHODIMP
-PrioritizableRunnable::GetPriority(uint32_t* aPriority)
-{
-  *aPriority = mPriority;
-  return NS_OK;
-}
-
 #endif  // XPCOM_GLUE_AVOID_NSPR
 
 //-----------------------------------------------------------------------------
 
 nsresult
 NS_NewNamedThread(const nsACString& aName,
                   nsIThread** aResult,
                   nsIRunnable* aEvent,
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -481,36 +481,16 @@ public:
 protected:
   virtual ~IdleRunnable() {}
 private:
   IdleRunnable(const IdleRunnable&) = delete;
   IdleRunnable& operator=(const IdleRunnable&) = delete;
   IdleRunnable& operator=(const IdleRunnable&&) = delete;
 };
 
-// This class is designed to be a wrapper of a real runnable to support event
-// prioritizable.
-class PrioritizableRunnable : public Runnable, public nsIRunnablePriority
-{
-public:
-  PrioritizableRunnable(already_AddRefed<nsIRunnable>&& aRunnable,
-                        uint32_t aPriority);
-
-  NS_IMETHOD GetName(nsACString& aName) override;
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIRUNNABLE
-  NS_DECL_NSIRUNNABLEPRIORITY
-
-protected:
-  virtual ~PrioritizableRunnable() {};
-  nsCOMPtr<nsIRunnable> mRunnable;
-  uint32_t mPriority;
-};
-
 namespace detail {
 
 // An event that can be used to call a C++11 functions or function objects,
 // including lambdas. The function must have no required arguments, and must
 // return void.
 template<typename StoredFunction>
 class RunnableFunction : public Runnable
 {