Bug 1489569 - 1. Avoid unnecessary setActive calls; r=droeh a=cpeterson GECKOVIEW_62_RELBRANCH
authorJim Chen <nchen@mozilla.com>
Mon, 10 Sep 2018 12:42:34 -0400
branchGECKOVIEW_62_RELBRANCH
changeset 481128 c019d0af0d64
parent 481126 4cdeecd31350
child 481129 ae008cd087d2
push id1783
push usernchen@mozilla.com
push dateFri, 14 Sep 2018 20:24:17 +0000
treeherdermozilla-release@ae008cd087d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh, cpeterson
bugs1489569
milestone62.0.2
Bug 1489569 - 1. Avoid unnecessary setActive calls; r=droeh a=cpeterson To avoid unnecessary setActive calls, only call it when we have a display and when the display acquires or releases a surface. In other cases, we can delay the setActive call until later. Differential Revision: https://phabricator.services.mozilla.com/D5328
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java
@@ -106,18 +106,18 @@ public class GeckoView extends FrameLayo
             }
 
             // Tell display there is already a surface.
             onGlobalLayout();
             if (GeckoView.this.mSurfaceView != null) {
                 final SurfaceHolder holder = GeckoView.this.mSurfaceView.getHolder();
                 final Rect frame = holder.getSurfaceFrame();
                 mDisplay.surfaceChanged(holder.getSurface(), frame.right, frame.bottom);
+                GeckoView.this.setActive(true);
             }
-            GeckoView.this.setActive(true);
         }
 
         public GeckoDisplay release() {
             if (mValid) {
                 mDisplay.surfaceDestroyed();
                 GeckoView.this.setActive(false);
             }
 
@@ -130,27 +130,29 @@ public class GeckoView extends FrameLayo
         public void surfaceCreated(final SurfaceHolder holder) {
         }
 
         @Override // SurfaceHolder.Callback
         public void surfaceChanged(final SurfaceHolder holder, final int format,
                                    final int width, final int height) {
             if (mDisplay != null) {
                 mDisplay.surfaceChanged(holder.getSurface(), width, height);
+                if (!mValid) {
+                    GeckoView.this.setActive(true);
+                }
             }
-            GeckoView.this.setActive(true);
             mValid = true;
         }
 
         @Override // SurfaceHolder.Callback
         public void surfaceDestroyed(final SurfaceHolder holder) {
             if (mDisplay != null) {
                 mDisplay.surfaceDestroyed();
+                GeckoView.this.setActive(false);
             }
-            GeckoView.this.setActive(false);
             mValid = false;
         }
 
         public void onGlobalLayout() {
             if (mDisplay == null) {
                 return;
             }
             if (GeckoView.this.mSurfaceView != null) {