mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 826053 - Avoid reporting duplicate ANRs; r=blassey
This commit is contained in:
parent
b34df63443
commit
997a9f5486
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user