Bug 1235341 - Don't request rendering until compositor is created; r=me
authorJim Chen <nchen@mozilla.com>
Mon, 28 Dec 2015 17:41:45 -0500
changeset 277733 18f2e2c3636fbe89794be06ead60178cca6761ad
parent 277732 b1e3bb1b90728c40161baa96b7e79ec7ed426513
child 277734 8e026b0e24a5a123ab590c9c30968e95fddf1db5
push id29832
push usercbook@mozilla.com
push dateTue, 29 Dec 2015 10:55:58 +0000
treeherdermozilla-central@9ddf0da90fb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1235341
milestone46.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 1235341 - Don't request rendering until compositor is created; r=me Simple patch. Don't call into the compositor to request a rendering until the compositor has been created.
mobile/android/base/java/org/mozilla/gecko/gfx/GLController.java
mobile/android/base/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/GLController.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/GLController.java
@@ -81,17 +81,17 @@ public class GLController extends JNIObj
     @WrapForJNI
     private native void pauseCompositor();
 
     // UI thread resumes compositor and notifies Gecko thread; does not block UI thread.
     @WrapForJNI
     private native void syncResumeResizeCompositor(int width, int height);
 
     @WrapForJNI
-    /* package */ native void syncInvalidateAndScheduleComposite();
+    private native void syncInvalidateAndScheduleComposite();
 
     public GLController() {
     }
 
     synchronized void serverSurfaceDestroyed() {
         ThreadUtils.assertOnUiThread();
 
         mServerSurfaceValid = false;
@@ -282,16 +282,22 @@ public class GLController extends JNIObj
         // It is important to not notify Gecko until after the compositor has
         // been resumed, otherwise Gecko may send updates that get dropped.
         if (mCompositorCreated) {
             syncResumeResizeCompositor(width, height);
             mView.requestRender();
         }
     }
 
+    /* package */ void invalidateAndScheduleComposite() {
+        if (mCompositorCreated) {
+            syncInvalidateAndScheduleComposite();
+        }
+    }
+
     public static class GLControllerException extends RuntimeException {
         public static final long serialVersionUID = 1L;
 
         GLControllerException(String e) {
             super(e);
         }
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.gfx;
 
+import org.mozilla.gecko.annotation.ReflectionTarget;
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.gfx.LayerView.DrawListener;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.ZoomConstraints;
@@ -145,16 +146,18 @@ class GeckoLayerClient implements LayerV
         mPanZoomController.setOverscrollHandler(listener);
     }
 
     /** Attaches to root layer so that Gecko appears. */
     /* package */ boolean isGeckoReady() {
         return mGeckoIsReady;
     }
 
+    // Used by GeckoThread.queueNativeCallUntil through LayerView.onAttachedToWindow.
+    @ReflectionTarget
     public void onGeckoReady() {
         mGeckoIsReady = true;
 
         mRootLayer = new VirtualLayer(new IntSize(mView.getWidth(), mView.getHeight()));
         mLayerRenderer = mView.getRenderer();
 
         sendResizeEventIfNecessary(true, null);
 
@@ -748,17 +751,20 @@ class GeckoLayerClient implements LayerV
         if (getRedrawHint()) {
             adjustViewport(displayPort);
         }
     }
 
     /** Implementation of LayerView.Listener */
     @Override
     public void renderRequested() {
-        mView.getGLController().syncInvalidateAndScheduleComposite();
+        final GLController glController = mView.getGLController();
+        if (glController != null) {
+            glController.invalidateAndScheduleComposite();
+        }
     }
 
     /** Implementation of LayerView.Listener */
     @Override
     public void sizeChanged(int width, int height) {
         // We need to make sure a draw happens synchronously at this point,
         // but resizing the surface before the SurfaceView has resized will
         // cause a visible jump.