Bug 826053 - Avoid reporting duplicate ANRs; r=blassey

This commit is contained in:
Jim Chen 2013-02-08 18:17:42 -05:00
parent 7dd6a24fee
commit a698c25d7e

View File

@ -58,6 +58,7 @@ public final class ANRReporter extends BroadcastReceiver
private static final ANRReporter sInstance = new ANRReporter();
private static int sRegisteredCount;
private Handler mHandler;
private volatile boolean mPendingANR;
public static void register(Context context) {
if (sRegisteredCount++ != 0) {
@ -444,6 +445,27 @@ public final class ANRReporter extends BroadcastReceiver
@Override
public void onReceive(Context context, Intent intent) {
if (mPendingANR) {
// we already processed an ANR without getting unstuck; skip this one
if (DEBUG) {
Log.d(LOGTAG, "skipping duplicate ANR");
}
return;
}
if (GeckoApp.mAppContext != null && GeckoApp.mAppContext.mMainHandler != null) {
mPendingANR = true;
// detect when the main thread gets unstuck
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
@Override
public void run() {
// okay to reset mPendingANR on main thread
mPendingANR = false;
if (DEBUG) {
Log.d(LOGTAG, "yay we got unstuck!");
}
}
});
}
if (DEBUG) {
Log.d(LOGTAG, "receiving " + String.valueOf(intent));
}