Skip to content

Commit

Permalink
Prevent crash reporter from getting stuck in an infinte loop (#1566)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin authored and keianhzo committed Aug 19, 2019
1 parent 4badb2e commit 2744a23
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -29,6 +29,9 @@ public class CrashReporterService extends JobIntentService {
// Threshold used to fix Infinite restart loop on startup crashes.
// See https://github.com/MozillaReality/FirefoxReality/issues/651
public static final long MAX_RESTART_COUNT = 2;
private static final int MAX_PID_CHECK_COUNT = 5;

private int mPidCheckCount = 0;

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Expand Down Expand Up @@ -71,14 +74,15 @@ protected void onHandleWork(@NonNull Intent intent) {
}
}

if (!otherProcessesFound) {
if (!otherProcessesFound || (mPidCheckCount > MAX_PID_CHECK_COUNT)) {
intent.setClass(CrashReporterService.this, VRBrowserActivity.class);
intent.setPackage(BuildConfig.APPLICATION_ID);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
break;

} else {
mPidCheckCount++;
try {
Thread.sleep(PID_CHECK_INTERVAL);
} catch (InterruptedException e) {
Expand Down

0 comments on commit 2744a23

Please sign in to comment.