Bug 1401737 - 1. Add a diagnostic crash; r=me
authorJim Chen <nchen@mozilla.com>
Thu, 21 Sep 2017 23:41:22 -0400
changeset 668888 40023b79401d49e45e1eb53acb2b96976f24a939
parent 668885 14cf84cd05639c0bd7db54118102b1742e90cadf
child 668889 0b39d5cbf3d1cf23fc162fb8b4e9261cbb3d6521
push id81146
push userbmo:topwu.tw@gmail.com
push dateFri, 22 Sep 2017 05:24:51 +0000
reviewersme
bugs1401737
milestone58.0a1
Bug 1401737 - 1. Add a diagnostic crash; r=me Add a diagnostic crash for the unexpected case where GeckoService.register() is called a second time. We know the stack for the second call, but we want to know the stack for the first call, so we introduce this intentional crash. r=me for trivial diagnostic patch which will be backed out ASAP. MozReview-Commit-ID: HobtPiVSSTR
mobile/android/base/java/org/mozilla/gecko/GeckoService.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoService.java
@@ -66,20 +66,32 @@ public class GeckoService extends Servic
             default:
                 throw new UnsupportedOperationException(event);
             }
         }
     }
 
     private static final EventListener EVENT_LISTENER = new EventListener();
 
+    private static RuntimeException bug1401737Diag;
+
     public static void register() {
         if (DEBUG) {
             Log.d(LOGTAG, "Registered listener");
         }
+
+        // Diagnose bug 1401737. register() is unexpectedly getting called a second time.
+        // We know the stack for the second call, but we want to collect stack for the first call.
+        if (bug1401737Diag == null) {
+            bug1401737Diag = new IllegalStateException("Bug 1401737 diagnostic crash");
+        } else {
+            Log.e(LOGTAG, "register() is called a second time", new Exception());
+            throw bug1401737Diag;
+        }
+
         EventDispatcher.getInstance().registerGeckoThreadListener(EVENT_LISTENER,
                 "Gecko:ScheduleRun");
     }
 
     public static void unregister() {
         if (DEBUG) {
             Log.d(LOGTAG, "Unregistered listener");
         }