Backed out 3 changesets (bug 999071) for Android rc1 failures
authorWes Kocher <wkocher@mozilla.com>
Thu, 24 Apr 2014 18:12:46 -0700
changeset 180464 d83cad7c58539b5969fece4f09389861e0186da2
parent 180463 acbb894db34842044c641097e3b119665384dd17
child 180465 3961ab6093b47fa43db9216f8c7ea8caccf9cd90
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
bugs999071
milestone31.0a1
backs outddf970be0abd398b2c6bc0e5a2c7152e387fbbd6
8d2738b2227522649c54859249c23561051e07b0
b82a8c50aa904edada187a844e21f8dc9d96e955
Backed out 3 changesets (bug 999071) for Android rc1 failures Backed out changeset ddf970be0abd (bug 999071) Backed out changeset 8d2738b22275 (bug 999071) Backed out changeset b82a8c50aa90 (bug 999071)
build/mobile/remoteautomation.py
mobile/android/base/tests/robocop.ini
mobile/android/base/tests/testANRReporter.java
tools/profiler/TableTicker.cpp
tools/profiler/platform.cpp
tools/profiler/platform.h
--- a/build/mobile/remoteautomation.py
+++ b/build/mobile/remoteautomation.py
@@ -93,22 +93,20 @@ class RemoteAutomation(Automation):
                       "allowed maximum time" % (self.lastTestSeen)
         if status == 2:
             print "TEST-UNEXPECTED-FAIL | %s | application timed out after %d seconds with no output" \
                 % (self.lastTestSeen, int(timeout))
 
         return status
 
     def deleteANRs(self):
-        # empty ANR traces.txt file; usually need root permissions
-        # we make it empty and writable so we can test the ANR reporter later
+        # delete ANR traces.txt file; usually need root permissions
         traces = "/data/anr/traces.txt"
         try:
-            self._devicemanager.shellCheckOutput(['echo', '', '>', traces], root=True)
-            self._devicemanager.shellCheckOutput(['chmod', '666', traces], root=True)
+            self._devicemanager.shellCheckOutput(['rm', traces], root=True)
         except DMError:
             print "Error deleting %s" % traces
             pass
 
     def checkForANRs(self):
         traces = "/data/anr/traces.txt"
         if self._devicemanager.fileExists(traces):
             try:
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -5,17 +5,16 @@ skip-if = android_version == "10"
 [testAddonManager]
 # disabled on x86 only; bug 936216
 skip-if = processor == "x86"
 [testAddSearchEngine]
 # disabled on Android 2.3; bug 979552
 skip-if = android_version == "10"
 [testAdobeFlash]
 skip-if = processor == "x86"
-[testANRReporter]
 [testAwesomebar]
 [testAxisLocking]
 # disabled on x86 only; bug 927476
 skip-if = processor == "x86"
 # [testBookmark] # see bug 915350
 [testBookmarksPanel]
 # disabled on 2.3; bug 979615
 skip-if = android_version == "10"
deleted file mode 100644
--- a/mobile/android/base/tests/testANRReporter.java
+++ /dev/null
@@ -1,207 +0,0 @@
-package org.mozilla.gecko.tests;
-
-import org.mozilla.gecko.AppConstants;
-
-import android.content.Context;
-import android.content.Intent;
-
-import com.jayway.android.robotium.solo.Condition;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-
-import org.json.JSONObject;
-
-/**
- * Tests the proper operation of the ANR reporter.
- */
-public class testANRReporter extends BaseTest {
-
-    private static final String ANR_ACTION = "android.intent.action.ANR";
-    private static final String PING_DIR = "saved-telemetry-pings";
-    private static final int WAIT_FOR_PING_TIMEOUT = 10000;
-    private static final String ANR_PATH = "/data/anr/traces.txt";
-    private static final String SAMPLE_ANR
-        = "----- pid 1 at 2014-01-15 18:55:51 -----\n"
-        + "Cmd line: " + AppConstants.ANDROID_PACKAGE_NAME + "\n"
-        + "\n"
-        + "JNI: CheckJNI is off; workarounds are off; pins=0; globals=397\n"
-        + "\n"
-        + "DALVIK THREADS:\n"
-        + "(mutexes: tll=0 tsl=0 tscl=0 ghl=0)\n"
-        + "\n"
-        + "\"main\" prio=5 tid=1 WAIT\n"
-        + "  | group=\"main\" sCount=1 dsCount=0 obj=0x41d6bc90 self=0x41d5a3c8\n"
-        + "  | sysTid=3485 nice=0 sched=0/0 cgrp=apps handle=1074852180\n"
-        + "  | state=S schedstat=( 0 0 0 ) utm=1065 stm=152 core=0\n"
-        + "  at java.lang.Object.wait(Native Method)\n"
-        + "  - waiting on <0x427ab340> (a org.mozilla.gecko.GeckoEditable$5)\n"
-        + "  at java.lang.Object.wait(Object.java:364)\n"
-        + "  at org.mozilla.gecko.GeckoEditable$5.run(GeckoEditable.java:746)\n"
-        + "  at android.os.Handler.handleCallback(Handler.java:733)\n"
-        + "  at android.os.Handler.dispatchMessage(Handler.java:95)\n"
-        + "  at android.os.Looper.loop(Looper.java:137)\n"
-        + "  at android.app.ActivityThread.main(ActivityThread.java:4998)\n"
-        + "  at java.lang.reflect.Method.invokeNative(Native Method)\n"
-        + "  at java.lang.reflect.Method.invoke(Method.java:515)\n"
-        + "  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)\n"
-        + "  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)\n"
-        + "  at dalvik.system.NativeStart.main(Native Method)\n"
-        + "\n"
-        + "\"Gecko\" prio=5 tid=16 SUSPENDED\n"
-        + "  | group=\"main\" sCount=1 dsCount=0 obj=0x426e2b28 self=0x76ae92e8\n"
-        + "  | sysTid=3541 nice=0 sched=0/0 cgrp=apps handle=1991153472\n"
-        + "  | state=S schedstat=( 0 0 0 ) utm=1118 stm=145 core=0\n"
-        + "  #00  pc 00000904  /system/lib/libc.so (__futex_syscall3+4294832136)\n"
-        + "  #01  pc 0000eec4  /system/lib/libc.so (__pthread_cond_timedwait_relative+48)\n"
-        + "  #02  pc 0000ef24  /system/lib/libc.so (__pthread_cond_timedwait+64)\n"
-        + "  #03  pc 000536b7  /system/lib/libdvm.so\n"
-        + "  #04  pc 00053c79  /system/lib/libdvm.so (dvmChangeStatus(Thread*, ThreadStatus)+34)\n"
-        + "  #05  pc 00049507  /system/lib/libdvm.so\n"
-        + "  #06  pc 0004d84b  /system/lib/libdvm.so\n"
-        + "  #07  pc 0003f1df  /dev/ashmem/libxul.so (deleted)\n"
-        + "  at org.mozilla.gecko.mozglue.GeckoLoader.nativeRun(Native Method)\n"
-        + "  at org.mozilla.gecko.GeckoAppShell.runGecko(GeckoAppShell.java:384)\n"
-        + "  at org.mozilla.gecko.GeckoThread.run(GeckoThread.java:177)\n"
-        + "\n"
-        + "----- end 1 -----\n"
-        + "\n"
-        + "\n"
-        + "----- pid 2 at 2013-01-25 13:27:01 -----\n"
-        + "Cmd line: system_server\n"
-        + "\n"
-        + "----- end 2 -----\n";
-
-    private boolean mDone;
-
-    public void testANRReporter() throws Exception {
-        blockForGeckoReady();
-
-        // Cannot test ANR reporter if it's disabled.
-        if (!AppConstants.MOZ_ANDROID_ANR_REPORTER) {
-            mAsserter.ok(true, "ANR reporter is disabled", null);
-            return;
-        }
-
-        // For the ANR reporter to work, we need to provide sample ANR traces to it.
-        // Therefore, we need the ANR file to exist and writable. If not, we don't
-        // have the right permissions to create the file, so we just bail.
-        final File anrFile = new File(ANR_PATH);
-        if (!anrFile.exists()) {
-            mAsserter.ok(true, "ANR file does not exist", null);
-            return;
-        }
-        if (!anrFile.canWrite()) {
-            mAsserter.ok(true, "ANR file is not writable", null);
-            return;
-        }
-
-        final FileWriter anrWriter = new FileWriter(anrFile);
-        try {
-            anrWriter.write(SAMPLE_ANR);
-        } finally {
-            anrWriter.close();
-        }
-
-        // Block the UI thread to simulate an ANR
-        final Runnable uiBlocker = new Runnable() {
-            @Override
-            public synchronized void run() {
-                while (!mDone) {
-                    try {
-                        wait();
-                    } catch (final InterruptedException e) {
-                    }
-                }
-            }
-        };
-        getActivity().runOnUiThread(uiBlocker);
-
-        // Make sure our initial ping directory is empty.
-        final File pingDir = new File(mProfile, PING_DIR);
-        final String[] initialFiles = pingDir.list();
-        mAsserter.ok(initialFiles == null || initialFiles.length == 0,
-                     "Ping directory is empty", null);
-
-        final Intent anrIntent = new Intent(ANR_ACTION);
-        anrIntent.setPackage(AppConstants.ANDROID_PACKAGE_NAME);
-        mAsserter.is(anrIntent.getPackage(), AppConstants.ANDROID_PACKAGE_NAME,
-                     "Successfully set package name");
-
-        final Context testContext = getInstrumentation().getContext();
-        mAsserter.isnot(testContext, null, "testContext should not be null");
-
-        // Trigger the ANR.
-        mAsserter.info("Triggering ANR", null);
-        testContext.sendBroadcast(anrIntent);
-
-        // ANR reporter is supposed to ignore duplicate ANRs.
-        // This will be checked later when we look for ping files.
-        mAsserter.info("Triggering second ANR", null);
-        testContext.sendBroadcast(new Intent(anrIntent));
-
-        mAsserter.info("Waiting for ping", null);
-        waitForCondition(new Condition() {
-            @Override
-            public boolean isSatisfied() {
-                final String[] newFiles = pingDir.list();
-                return newFiles != null && newFiles.length > 0;
-            }
-        }, WAIT_FOR_PING_TIMEOUT);
-
-        mAsserter.ok(pingDir.exists(), "Ping directory exists", null);
-        mAsserter.ok(pingDir.isDirectory(), "Ping directory is a directory", null);
-
-        final File[] newFiles = pingDir.listFiles();
-        mAsserter.isnot(newFiles, null, "Ping directory is not empty");
-        mAsserter.is(newFiles.length, 1, "ANR reporter wrote one ping");
-        mAsserter.ok(newFiles[0].exists(), "Ping exists", null);
-        mAsserter.ok(newFiles[0].isFile(), "Ping is a file", null);
-        mAsserter.ok(newFiles[0].canRead(), "Ping is readable", null);
-        mAsserter.info("Found ping file", newFiles[0].getPath());
-
-        final char[] buffer = new char[(int) newFiles[0].length()];
-        final FileReader reader = new FileReader(newFiles[0]);
-        try {
-            mAsserter.ok(reader.read(buffer) > 0, "Read from ping file", null);
-        } finally {
-            reader.close();
-        }
-
-        // Check standard properties required by Telemetry server.
-        final JSONObject pingObject = new JSONObject(new String(buffer));
-        mAsserter.ok(pingObject.has("slug"), "Ping has slug property", null);
-        mAsserter.ok(pingObject.has("reason"), "Ping has reason property", null);
-        mAsserter.ok(pingObject.has("payload"), "Ping has payload property", null);
-
-        final JSONObject pingPayload = pingObject.getJSONObject("payload");
-        mAsserter.ok(pingPayload.has("ver"), "Payload has ver property", null);
-        mAsserter.ok(pingPayload.has("info"), "Payload has info property", null);
-        mAsserter.ok(pingPayload.has("androidANR"), "Payload has androidANR property", null);
-
-        final JSONObject pingInfo = pingPayload.getJSONObject("info");
-        mAsserter.ok(pingInfo.has("reason"), "Info has reason property", null);
-        mAsserter.ok(pingInfo.has("appName"), "Info has appName property", null);
-        mAsserter.ok(pingInfo.has("appUpdateChannel"), "Info has appUpdateChannel property", null);
-        mAsserter.ok(pingInfo.has("appVersion"), "Info has appVersion property", null);
-        mAsserter.ok(pingInfo.has("appBuildID"), "Info has appBuildID property", null);
-
-        // Do some profile clean up. This is not absolutely necessary because the profile
-        // is blown away after test runs anyways, so we don't check return values here.
-        for (final File ping : newFiles) {
-            ping.delete();
-        }
-        pingDir.delete();
-
-        // Unblock UI thread
-        synchronized (uiBlocker) {
-            mDone = true;
-            uiBlocker.notify();
-        }
-
-        // Clear the sample ANR
-        final FileWriter anrClearer = new FileWriter(anrFile);
-        anrClearer.close();
-    }
-}
--- a/tools/profiler/TableTicker.cpp
+++ b/tools/profiler/TableTicker.cpp
@@ -278,41 +278,40 @@ void TableTicker::StreamJSObject(JSStrea
             continue;
 
           MutexAutoLock lock(*sRegisteredThreads->at(i)->Profile()->GetMutex());
 
           sRegisteredThreads->at(i)->Profile()->StreamJSObject(b);
         }
       }
 
-      if (Sampler::CanNotifyObservers()) {
-        // Send a event asking any subprocesses (plugins) to
-        // give us their information
-        SubprocessClosure closure(&b);
-        nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-        if (os) {
-          nsRefPtr<ProfileSaveEvent> pse = new ProfileSaveEvent(SubProcessCallback, &closure);
-          os->NotifyObservers(pse, "profiler-subprocess", nullptr);
-        }
+      // Send a event asking any subprocesses (plugins) to
+      // give us their information
+      SubprocessClosure closure(&b);
+      nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
+      if (os) {
+        nsRefPtr<ProfileSaveEvent> pse = new ProfileSaveEvent(SubProcessCallback, &closure);
+        os->NotifyObservers(pse, "profiler-subprocess", nullptr);
       }
 
   #if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
       if (ProfileJava()) {
         mozilla::widget::android::GeckoJavaSampler::PauseJavaProfiling();
 
         BuildJavaThreadJSObject(b);
 
         mozilla::widget::android::GeckoJavaSampler::UnpauseJavaProfiling();
       }
   #endif
 
       SetPaused(false);
     b.EndArray();
 
   b.EndObject();
+
 }
 
 // END SaveProfileTask et al
 ////////////////////////////////////////////////////////////////////////
 
 static
 void addDynamicTag(ThreadProfile &aProfile, char aTagName, const char *aStr)
 {
--- a/tools/profiler/platform.cpp
+++ b/tools/profiler/platform.cpp
@@ -693,21 +693,19 @@ void mozilla_sampler_start(int aProfileE
       sInterposeObserver = new mozilla::ProfilerIOInterposeObserver();
     }
     mozilla::IOInterposer::Register(mozilla::IOInterposeObserver::OpAll,
                                     sInterposeObserver);
   }
 
   sIsProfiling = true;
 
-  if (Sampler::CanNotifyObservers()) {
-    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-    if (os)
-      os->NotifyObservers(nullptr, "profiler-started", nullptr);
-  }
+  nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
+  if (os)
+    os->NotifyObservers(nullptr, "profiler-started", nullptr);
 
   LOG("END   mozilla_sampler_start");
 }
 
 void mozilla_sampler_stop()
 {
   LOG("BEGIN mozilla_sampler_stop");
 
@@ -746,21 +744,19 @@ void mozilla_sampler_stop()
   }
 
   mozilla::IOInterposer::Unregister(mozilla::IOInterposeObserver::OpAll,
                                     sInterposeObserver);
   sInterposeObserver = nullptr;
 
   sIsProfiling = false;
 
-  if (Sampler::CanNotifyObservers()) {
-    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-    if (os)
-      os->NotifyObservers(nullptr, "profiler-stopped", nullptr);
-  }
+  nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
+  if (os)
+    os->NotifyObservers(nullptr, "profiler-stopped", nullptr);
 
   LOG("END   mozilla_sampler_stop");
 }
 
 bool mozilla_sampler_is_paused() {
   if (Sampler::GetActiveSampler()) {
     return Sampler::GetActiveSampler()->IsPaused();
   } else {
--- a/tools/profiler/platform.h
+++ b/tools/profiler/platform.h
@@ -39,17 +39,16 @@
 #include <pthread.h>
 #endif
 
 #include <stdint.h>
 #include <math.h>
 #include "mozilla/unused.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Mutex.h"
-#include "MainThreadUtils.h"
 #include "PlatformMacros.h"
 #include "v8-support.h"
 #include <vector>
 
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
@@ -349,27 +348,16 @@ class Sampler {
   static void Startup();
   // Should only be called on shutdown
   static void Shutdown();
 
   static TableTicker* GetActiveSampler() { return sActiveSampler; }
   static void SetActiveSampler(TableTicker* sampler) { sActiveSampler = sampler; }
 
   static mozilla::Mutex* sRegisteredThreadsMutex;
-
-  static bool CanNotifyObservers() {
-#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
-    // Android ANR reporter uses the profiler off the main thread
-    return NS_IsMainThread();
-#else
-    MOZ_ASSERT(NS_IsMainThread());
-    return true;
-#endif
-  }
-
  protected:
   static std::vector<ThreadInfo*>* sRegisteredThreads;
   static TableTicker* sActiveSampler;
 
  private:
   void SetActive(bool value) { NoBarrier_Store(&active_, value); }
 
   const double interval_;