Backed out 4 changesets (bug 1319850) for android xpcshell bustage a=backout
authorWes Kocher <wkocher@mozilla.com>
Thu, 22 Dec 2016 18:16:34 -0800
changeset 327111 b1213723e15613628949342a2aad4b068cd45aad
parent 327110 f0840950a19b8d610f4974d8f2d908866bfa7493
child 327112 1f37e6b5cf6df91c4d5bd442610407111b7c3fa3
push id31119
push userkwierso@gmail.com
push dateFri, 23 Dec 2016 22:34:59 +0000
treeherdermozilla-central@da22155a2dc3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1319850
milestone53.0a1
backs out15b92bb6d8107bbc60c1932e340b4a954ed8a8d2
e31107c3f677659805753097d4273e472975dfbb
2a8012945a74914ef0d51052d4fbdbf637d06573
8717bea884c99079359f7cfcc1e1ecea46b61ed9
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 4 changesets (bug 1319850) for android xpcshell bustage a=backout Backed out changeset 15b92bb6d810 (bug 1319850) Backed out changeset e31107c3f677 (bug 1319850) Backed out changeset 2a8012945a74 (bug 1319850) Backed out changeset 8717bea884c9 (bug 1319850)
ipc/chromium/src/base/message_loop.cc
ipc/chromium/src/base/message_loop.h
ipc/glue/MessagePump.cpp
ipc/glue/MessagePump.h
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/AndroidUiThread.cpp
widget/android/AndroidUiThread.h
widget/android/moz.build
widget/android/nsAppShell.cpp
widget/android/nsWindow.cpp
--- a/ipc/chromium/src/base/message_loop.cc
+++ b/ipc/chromium/src/base/message_loop.cc
@@ -125,22 +125,16 @@ MessageLoop::MessageLoop(Type type, nsIT
   case TYPE_MOZILLA_NONMAINTHREAD:
     pump_ = new mozilla::ipc::MessagePumpForNonMainThreads(aThread);
     return;
 #if defined(OS_WIN)
   case TYPE_MOZILLA_NONMAINUITHREAD:
     pump_ = new mozilla::ipc::MessagePumpForNonMainUIThreads(aThread);
     return;
 #endif
-#if defined(MOZ_WIDGET_ANDROID)
-  case TYPE_MOZILLA_ANDROID_UI:
-    MOZ_RELEASE_ASSERT(aThread);
-    pump_ = new mozilla::ipc::MessagePumpForAndroidUI(aThread);
-    return;
-#endif // defined(MOZ_WIDGET_ANDROID)
   default:
     // Create one of Chromium's standard MessageLoop types below.
     break;
   }
 
 #if defined(OS_WIN)
   // TODO(rvargas): Get rid of the OS guards.
   if (type_ == TYPE_DEFAULT) {
--- a/ipc/chromium/src/base/message_loop.h
+++ b/ipc/chromium/src/base/message_loop.h
@@ -175,18 +175,17 @@ public:
   //
   enum Type {
     TYPE_DEFAULT,
     TYPE_UI,
     TYPE_IO,
     TYPE_MOZILLA_CHILD,
     TYPE_MOZILLA_PARENT,
     TYPE_MOZILLA_NONMAINTHREAD,
-    TYPE_MOZILLA_NONMAINUITHREAD,
-    TYPE_MOZILLA_ANDROID_UI
+    TYPE_MOZILLA_NONMAINUITHREAD
   };
 
   // Normally, it is not necessary to instantiate a MessageLoop.  Instead, it
   // is typical to make use of the current thread's MessageLoop instance.
   explicit MessageLoop(Type type = TYPE_DEFAULT, nsIThread* aThread = nullptr);
   ~MessageLoop();
 
   // Returns the type passed to the constructor.
--- a/ipc/glue/MessagePump.cpp
+++ b/ipc/glue/MessagePump.cpp
@@ -458,34 +458,8 @@ MessagePumpForNonMainUIThreads::OnProces
 NS_IMETHODIMP
 MessagePumpForNonMainUIThreads::AfterProcessNextEvent(nsIThreadInternal *thread,
                                                       bool eventWasProcessed)
 {
   return NS_OK;
 }
 
 #endif // XP_WIN
-
-#if defined(MOZ_WIDGET_ANDROID)
-void
-MessagePumpForAndroidUI::Run(Delegate* delegate)
-{
-  MOZ_CRASH("MessagePumpForAndroidUI should never be Run.");
-}
-
-void
-MessagePumpForAndroidUI::Quit()
-{
-  MOZ_CRASH("MessagePumpForAndroidUI should never be Quit.");
-}
-
-void
-MessagePumpForAndroidUI::ScheduleWork()
-{
-  MOZ_CRASH("MessagePumpForAndroidUI should never ScheduleWork");
-}
-
-void
-MessagePumpForAndroidUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time)
-{
-  MOZ_CRASH("MessagePumpForAndroidUI should never ScheduleDelayedWork");
-}
-#endif // defined(MOZ_WIDGET_ANDROID)
--- a/ipc/glue/MessagePump.h
+++ b/ipc/glue/MessagePump.h
@@ -159,49 +159,12 @@ private:
   {
   }
 
   bool mInWait;
   mozilla::Mutex mWaitLock;
 };
 #endif // defined(XP_WIN)
 
-#if defined(MOZ_WIDGET_ANDROID)
-/*`
- * The MessagePumpForAndroidUI exists to enable IPDL in the Android UI thread. The Android
- * UI thread event loop is controlled by Android. This prevents running an existing
- * MessagePump implementation in the Android UI thread. In order to enable IPDL on the
- * Android UI thread it is necessary to have a non-looping MessagePump. This class enables
- * forwarding of nsIRunnables from MessageLoop::PostTask_Helper to the registered
- * nsIEventTarget with out the need to control the event loop. The only member function
- * that should be invoked is GetXPCOMThread. All other member functions will invoke MOZ_CRASH
-*/
-class MessagePumpForAndroidUI : public base::MessagePump {
-
-public:
-  MessagePumpForAndroidUI(nsIEventTarget* aEventTarget)
-    : mEventTarget(aEventTarget)
-  { }
-
-  virtual void Run(Delegate* delegate);
-  virtual void Quit();
-  virtual void ScheduleWork();
-  virtual void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time);
-  virtual nsIEventTarget* GetXPCOMThread()
-  {
-    return mEventTarget;
-  }
-
-private:
-  ~MessagePumpForAndroidUI()
-  { }
-  MessagePumpForAndroidUI()
-  { }
-
-  nsIEventTarget* mEventTarget;
-};
-#endif // defined(MOZ_WIDGET_ANDROID)
-
-
 } /* namespace ipc */
 } /* namespace mozilla */
 
 #endif /* __IPC_GLUE_MESSAGEPUMP_H__ */
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -994,22 +994,22 @@ AndroidBridge::IsContentDocumentDisplaye
 }
 
 class AndroidBridge::DelayedTask
 {
     using TimeStamp = mozilla::TimeStamp;
     using TimeDuration = mozilla::TimeDuration;
 
 public:
-    DelayedTask(already_AddRefed<nsIRunnable> aTask)
+    DelayedTask(already_AddRefed<Runnable> aTask)
         : mTask(aTask)
         , mRunTime() // Null timestamp representing no delay.
     {}
 
-    DelayedTask(already_AddRefed<nsIRunnable> aTask, int aDelayMs)
+    DelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs)
         : mTask(aTask)
         , mRunTime(TimeStamp::Now() + TimeDuration::FromMilliseconds(aDelayMs))
     {}
 
     bool IsEarlierThan(const DelayedTask& aOther) const
     {
         if (mRunTime) {
             return aOther.mRunTime ? mRunTime < aOther.mRunTime : false;
@@ -1022,29 +1022,29 @@ public:
     int64_t MillisecondsToRunTime() const
     {
         if (mRunTime) {
             return int64_t((mRunTime - TimeStamp::Now()).ToMilliseconds());
         }
         return 0;
     }
 
-    already_AddRefed<nsIRunnable> TakeTask()
+    already_AddRefed<Runnable> TakeTask()
     {
         return mTask.forget();
     }
 
 private:
-    nsCOMPtr<nsIRunnable> mTask;
+    RefPtr<Runnable> mTask;
     const TimeStamp mRunTime;
 };
 
 
 void
-AndroidBridge::PostTaskToUiThread(already_AddRefed<nsIRunnable> aTask, int aDelayMs)
+AndroidBridge::PostTaskToUiThread(already_AddRefed<Runnable> aTask, int aDelayMs)
 {
     // add the new task into the mUiTaskQueue, sorted with
     // the earliest task first in the queue
     size_t i;
     DelayedTask newTask(aDelayMs ? DelayedTask(mozilla::Move(aTask), aDelayMs)
                                  : DelayedTask(mozilla::Move(aTask)));
 
     {
@@ -1081,17 +1081,17 @@ AndroidBridge::RunDelayedUiThreadTasks()
         if (timeLeft > 0) {
             // this task (and therefore all remaining tasks)
             // have not yet reached their runtime. return the
             // time left until we should be called again
             return timeLeft;
         }
 
         // Retrieve task before unlocking/running.
-        nsCOMPtr<nsIRunnable> nextTask(mUiTaskQueue[0].TakeTask());
+        RefPtr<Runnable> nextTask(mUiTaskQueue[0].TakeTask());
         mUiTaskQueue.RemoveElementAt(0);
 
         // Unlock to allow posting new tasks reentrantly.
         MutexAutoUnlock unlock(mUiTaskQueueLock);
         nextTask->Run();
     }
     return -1;
 }
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -37,22 +37,26 @@
 #include "Units.h"
 
 // Some debug #defines
 // #define DEBUG_ANDROID_EVENTS
 // #define DEBUG_ANDROID_WIDGET
 
 class nsPIDOMWindowOuter;
 
+namespace base {
+class Thread;
+} // end namespace base
+
 typedef void* EGLSurface;
-class nsIRunnable;
 
 namespace mozilla {
 
 class AutoLocalJNIFrame;
+class Runnable;
 
 namespace hal {
 class BatteryInformation;
 class NetworkInformation;
 } // namespace hal
 
 // The order and number of the members in this structure must correspond
 // to the attrsAppearance array in GeckoAppShell.getSystemColors()
@@ -230,17 +234,17 @@ protected:
     jmethodID mMessageQueueNext;
 
 private:
     class DelayedTask;
     nsTArray<DelayedTask> mUiTaskQueue;
     mozilla::Mutex mUiTaskQueueLock;
 
 public:
-    void PostTaskToUiThread(already_AddRefed<nsIRunnable> aTask, int aDelayMs);
+    void PostTaskToUiThread(already_AddRefed<Runnable> aTask, int aDelayMs);
     int64_t RunDelayedUiThreadTasks();
 };
 
 class AutoJNIClass {
 private:
     JNIEnv* const mEnv;
     const jclass mClass;
 
deleted file mode 100644
--- a/widget/android/AndroidUiThread.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "AndroidBridge.h"
-#include "base/message_loop.h"
-#include "mozilla/Monitor.h"
-#include "mozilla/RefPtr.h"
-#include "mozilla/StaticPtr.h"
-#include "nsThread.h"
-#include "nsThreadManager.h"
-#include "nsThreadUtils.h"
-
-using namespace mozilla;
-
-namespace {
-
-class AndroidUiThread;
-
-StaticRefPtr<AndroidUiThread> sThread;
-static MessageLoop* sMessageLoop;
-
-/*
- * The AndroidUiThread is derived from nsThread so that nsIRunnable objects that get
- * dispatched may be intercepted. Only nsIRunnable objects that need to be synchronously
- * executed are passed into the nsThread to be queued. All other nsIRunnable object
- * are immediately dispatched to the Android UI thread via the AndroidBridge.
- * AndroidUiThread is derived from nsThread instead of being an nsIEventTarget
- * wrapper that contains an nsThread object because if nsIRunnable objects with a
- * delay were dispatch directly to an nsThread object, such as obtained from
- * nsThreadManager::GetCurrentThread(), the nsIRunnable could get stuck in the
- * nsThread nsIRunnable queue. This is due to the fact that Android controls the
- * event loop in the Android UI thread and has no knowledge of when the nsThread
- * needs to be drained.
-*/
-
-class AndroidUiThread : public nsThread
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  AndroidUiThread() : nsThread(nsThread::NOT_MAIN_THREAD, 0)
-  {}
-
-  nsresult Dispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags) override;
-  nsresult DelayedDispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aDelayMs) override;
-
-private:
-  ~AndroidUiThread()
-  {}
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(AndroidUiThread, nsThread)
-
-NS_IMETHODIMP
-AndroidUiThread::Dispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags)
-{
-  if (aFlags & NS_DISPATCH_SYNC) {
-    return nsThread::Dispatch(Move(aEvent), aFlags);
-  } else {
-    AndroidBridge::Bridge()->PostTaskToUiThread(Move(aEvent), 0);
-    return NS_OK;
-  }
-}
-
-NS_IMETHODIMP
-AndroidUiThread::DelayedDispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aDelayMs)
-{
-  AndroidBridge::Bridge()->PostTaskToUiThread(Move(aEvent), aDelayMs);
-  return NS_OK;
-}
-
-static void
-PumpEvents() {
-  NS_ProcessPendingEvents(sThread.get());
-}
-
-class ThreadObserver : public nsIThreadObserver
-{
-public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSITHREADOBSERVER
-
-  ThreadObserver()
-  {}
-
-private:
-  virtual ~ThreadObserver()
-  {}
-};
-
-NS_IMPL_ISUPPORTS(ThreadObserver, nsIThreadObserver)
-
-NS_IMETHODIMP
-ThreadObserver::OnDispatchedEvent(nsIThreadInternal *thread)
-{
-  AndroidBridge::Bridge()->PostTaskToUiThread(NS_NewRunnableFunction(&PumpEvents), 0);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ThreadObserver::OnProcessNextEvent(nsIThreadInternal *thread, bool mayWait)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ThreadObserver::AfterProcessNextEvent(nsIThreadInternal *thread, bool eventWasProcessed)
-{
-  return NS_OK;
-}
-
-class CreateOnUiThread : public Runnable {
-public:
-  CreateOnUiThread() : mCreated(false), mThreadCreationMonitor("AndroidUiThreadCreationLock")
-  {}
-
-  NS_IMETHOD Run() override {
-    MonitorAutoLock lock(mThreadCreationMonitor);
-
-    sThread = new AndroidUiThread();
-    sThread->InitCurrentThread();
-    sThread->SetObserver(new ThreadObserver());
-    sMessageLoop = new MessageLoop(MessageLoop::TYPE_MOZILLA_ANDROID_UI, sThread.get());
-    mCreated = true;
-    lock.NotifyAll();
-    return NS_OK;
-  }
-
-  void WaitForCreation()
-  {
-    MonitorAutoLock lock(mThreadCreationMonitor);
-    while (!mCreated) {
-      lock.Wait();
-    }
-  }
-
-private:
-  bool mCreated;
-  Monitor mThreadCreationMonitor;
-};
-
-class DestroyOnUiThread : public Runnable {
-public:
-  DestroyOnUiThread() : mDestroyed(false), mThreadDestructionMonitor("AndroidUiThreadCreationLock")
-  {}
-
-  NS_IMETHOD Run() override {
-    MonitorAutoLock lock(mThreadDestructionMonitor);
-
-    delete sMessageLoop;
-    sMessageLoop = nullptr;
-    MOZ_ASSERT(sThread);
-    nsThreadManager::get().UnregisterCurrentThread(*sThread);
-    sThread = nullptr;
-    mDestroyed = true;
-    lock.NotifyAll();
-    return NS_OK;
-  }
-
-  void WaitForDestruction()
-  {
-    MonitorAutoLock lock(mThreadDestructionMonitor);
-    while (!mDestroyed) {
-      lock.Wait();
-    }
-  }
-
-private:
-  bool mDestroyed;
-  Monitor mThreadDestructionMonitor;
-};
-
-} // namespace
-
-namespace mozilla {
-
-void
-CreateAndroidUiThread()
-{
-  MOZ_ASSERT(!sThread);
-  RefPtr<CreateOnUiThread> runnable = new CreateOnUiThread;
-  AndroidBridge::Bridge()->PostTaskToUiThread(do_AddRef(runnable), 0);
-  runnable->WaitForCreation();
-}
-
-void
-DestroyAndroidUiThread()
-{
-  MOZ_ASSERT(sThread);
-  RefPtr<DestroyOnUiThread> runnable = new DestroyOnUiThread;
-  // Insure the Android bridge has not already been deconstructed.
-  MOZ_ASSERT(AndroidBridge::Bridge() != nullptr);
-  AndroidBridge::Bridge()->PostTaskToUiThread(do_AddRef(runnable), 0);
-  runnable->WaitForDestruction();
-}
-
-MessageLoop*
-GetAndroidUiThreadMessageLoop()
-{
-  return sMessageLoop;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/widget/android/AndroidUiThread.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#ifndef AndroidUiThread_h__
-#define AndroidUiThread_h__
-
-class MessageLoop;
-
-namespace mozilla {
-
-void CreateAndroidUiThread();
-void DestroyAndroidUiThread();
-
-MessageLoop* GetAndroidUiThreadMessageLoop();
-
-} // namespace mozilla
-
-#endif // AndroidUiThread_h__
--- a/widget/android/moz.build
+++ b/widget/android/moz.build
@@ -31,17 +31,16 @@ EXPORTS.mozilla.widget += [
 UNIFIED_SOURCES += [
     'AndroidAlerts.cpp',
     'AndroidBridge.cpp',
     'AndroidCompositorWidget.cpp',
     'AndroidContentController.cpp',
     'AndroidJavaWrappers.cpp',
     'AndroidJNI.cpp',
     'AndroidJNIWrapper.cpp',
-    'AndroidUiThread.cpp',
     'ANRReporter.cpp',
     'EventDispatcher.cpp',
     'GeneratedJNIWrappers.cpp',
     'GfxInfo.cpp',
     'NativeJSContainer.cpp',
     'nsAndroidProtocolHandler.cpp',
     'nsAppShell.cpp',
     'nsClipboard.cpp',
@@ -60,17 +59,16 @@ FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/docshell/base',
     '/dom/base',
     '/dom/system/android',
     '/netwerk/base',
     '/netwerk/cache',
     '/widget',
-    '/xpcom/threads',
 ]
 
 CXXFLAGS += ['-Wno-error=shadow']
 
 OS_LIBS += ['android']
 
 #DEFINES['DEBUG_WIDGETS'] = True
 
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -56,17 +56,16 @@
 #endif
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsICrashReporter.h"
 #include "nsExceptionHandler.h"
 #endif
 
 #include "AndroidAlerts.h"
-#include "AndroidUiThread.h"
 #include "ANRReporter.h"
 #include "GeckoBatteryManager.h"
 #include "GeckoNetworkManager.h"
 #include "GeckoScreenOrientation.h"
 #include "PrefsHelper.h"
 #include "fennec/MemoryMonitor.h"
 #include "fennec/Telemetry.h"
 #include "fennec/ThumbnailHelper.h"
@@ -391,33 +390,29 @@ nsAppShell::nsAppShell()
         if (jni::IsFennec()) {
             mozilla::ANRReporter::Init();
             mozilla::MemoryMonitor::Init();
             mozilla::widget::Telemetry::Init();
             mozilla::ThumbnailHelper::Init();
         }
 
         java::GeckoThread::SetState(java::GeckoThread::State::JNI_READY());
-
-        CreateAndroidUiThread();
     }
 
     sPowerManagerService = do_GetService(POWERMANAGERSERVICE_CONTRACTID);
 
     if (sPowerManagerService) {
         sWakeLockListener = new WakeLockListener();
     } else {
         NS_WARNING("Failed to retrieve PowerManagerService, wakelocks will be broken!");
     }
 }
 
 nsAppShell::~nsAppShell()
 {
-    DestroyAndroidUiThread();
-
     {
         MutexAutoLock lock(*sAppShellLock);
         sAppShell = nullptr;
     }
 
     while (mEventQueue.Pop(/* mayWait */ false)) {
         NS_WARNING("Discarded event on shutdown");
     }
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -68,17 +68,16 @@ using mozilla::Unused;
 #include "ScopedGLHelpers.h"
 #include "mozilla/layers/CompositorOGL.h"
 #include "AndroidContentController.h"
 
 #include "nsTArray.h"
 
 #include "AndroidBridge.h"
 #include "AndroidBridgeUtilities.h"
-#include "AndroidUiThread.h"
 #include "android_npapi.h"
 #include "FennecJNINatives.h"
 #include "GeneratedJNINatives.h"
 #include "KeyEvent.h"
 #include "MotionEvent.h"
 
 #include "imgIEncoder.h"
 
@@ -3556,17 +3555,17 @@ nsWindow::NeedsPaint()
         return false;
     }
     return nsIWidget::NeedsPaint();
 }
 
 void
 nsWindow::ConfigureAPZControllerThread()
 {
-    APZThreadUtils::SetControllerThread(mozilla::GetAndroidUiThreadMessageLoop());
+    APZThreadUtils::SetControllerThread(nullptr);
 }
 
 already_AddRefed<GeckoContentController>
 nsWindow::CreateRootContentController()
 {
     RefPtr<GeckoContentController> controller = new AndroidContentController(this, mAPZEventState, mAPZC);
     return controller.forget();
 }