Bug 797705: Check for null pointers and return early from java event handling if Gecko hasn't started to prevent crashes. [r=kats]
authorScott Johnson <sjohnson@mozilla.com>
Wed, 31 Oct 2012 11:39:44 -0500
changeset 111949 51c7ee23543838a49d89d49b1d6604d05c81cba2
parent 111948 57d8f6cd245acfc5cd8a22bac3558ce957e796e8
child 111950 f9a9ef4e6cae088cc796253b0c769abf1ad286a3
push id23783
push useremorley@mozilla.com
push dateThu, 01 Nov 2012 13:43:27 +0000
treeherdermozilla-central@71b2ea41dff7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs797705
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 797705: Check for null pointers and return early from java event handling if Gecko hasn't started to prevent crashes. [r=kats]
mobile/android/base/GeckoEvent.java
mobile/android/base/ui/PanZoomController.java
--- a/mobile/android/base/GeckoEvent.java
+++ b/mobile/android/base/GeckoEvent.java
@@ -268,16 +268,22 @@ public class GeckoEvent {
     public static GeckoEvent createNativeGestureEvent(int action, PointF pt, double size) {
         GeckoEvent event = new GeckoEvent(NATIVE_GESTURE_EVENT);
         event.mAction = action;
         event.mCount = 1;
         event.mPoints = new Point[1];
 
         PointF geckoPoint = new PointF(pt.x, pt.y);
         geckoPoint = GeckoApp.mAppContext.getLayerView().convertViewPointToLayerPoint(geckoPoint);
+
+        if (geckoPoint == null) {
+            // This could happen if Gecko isn't ready yet.
+            return null;
+        }
+
         event.mPoints[0] = new Point(Math.round(geckoPoint.x), Math.round(geckoPoint.y));
 
         event.mX = size;
         event.mTime = System.currentTimeMillis();
         return event;
     }
 
     public static GeckoEvent createMotionEvent(MotionEvent m) {
--- a/mobile/android/base/ui/PanZoomController.java
+++ b/mobile/android/base/ui/PanZoomController.java
@@ -917,16 +917,21 @@ public class PanZoomController
         // switch back to the touching state
         startTouch(detector.getFocusX(), detector.getFocusY(), detector.getEventTime());
 
         // Force a viewport synchronisation
         mTarget.setForceRedraw();
 
         PointF point = new PointF(detector.getFocusX(), detector.getFocusY());
         GeckoEvent event = GeckoEvent.createNativeGestureEvent(GeckoEvent.ACTION_MAGNIFY_END, point, getMetrics().zoomFactor);
+
+        if (event == null) {
+            return;
+        }
+
         GeckoAppShell.sendEventToGecko(event);
     }
 
     /**
      * Scales the viewport, keeping the given focus point in the same place before and after the
      * scale operation. You must hold the monitor while calling this.
      */
     private void scaleWithFocus(float zoomFactor, PointF focus) {