Merge heads.
authorAli Juma <ajuma@mozilla.com>
Fri, 17 Feb 2012 17:57:28 -0500
changeset 89161 24039604393a8bc73c8fce82d6e5930280767776
parent 89160 f8729fdce1848626f13b0bc0446db9328ce78aeb (current diff)
parent 89159 d810d4d2ff0b9574887aa40c65cc81a5a12529a3 (diff)
child 89162 ed42513a664612def0c97d64084b50680eaa4dd2
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.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
Merge heads.
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -387,29 +387,31 @@ GLContext::InitWithPrefix(const char *pr
     const char *glRendererString;
 
     if (mInitialized) {
         glVendorString = (const char *)fGetString(LOCAL_GL_VENDOR);
         const char *vendorMatchStrings[VendorOther] = {
                 "Intel",
                 "NVIDIA",
                 "ATI",
-                "Qualcomm"
+                "Qualcomm",
+                "Imagination"
         };
         mVendor = VendorOther;
         for (int i = 0; i < VendorOther; ++i) {
             if (DoesStringMatch(glVendorString, vendorMatchStrings[i])) {
                 mVendor = i;
                 break;
             }
         }
 
         glRendererString = (const char *)fGetString(LOCAL_GL_RENDERER);
         const char *rendererMatchStrings[RendererOther] = {
-                "Adreno 200"
+                "Adreno 200",
+                "PowerVR SGX 540"
         };
         mRenderer = RendererOther;
         for (int i = 0; i < RendererOther; ++i) {
             if (DoesStringMatch(glRendererString, rendererMatchStrings[i])) {
                 mRenderer = i;
                 break;
             }
         }
@@ -609,16 +611,37 @@ bool
 GLContext::CanUploadSubTextures()
 {
     // There are certain GPUs that we don't want to use glTexSubImage2D on
     // because that function can be very slow and/or buggy
 
     return !(Renderer() == RendererAdreno200);
 }
 
+bool
+GLContext::WantsSmallTiles()
+{
+#ifdef MOZ_WIDGET_ANDROID
+    // We must use small tiles for good performance if we can't use
+    // glTexSubImage2D() for some reason.
+    if (!CanUploadSubTextures())
+        return true;
+
+    // We can't use small tiles on the SGX 540, because of races in texture upload.
+    if (Renderer() == RendererSGX540)
+        return false;
+
+    // Don't use small tiles otherwise. (If we implement incremental texture upload,
+    // then we will want to revisit this.)
+    return false;
+#else
+    return false;
+#endif
+}
+
 // Common code for checking for both GL extensions and GLX extensions.
 bool
 GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
 {
     // fix bug 612572 - we were crashing as we were calling this function with extensions==null
     if (extensions == nsnull || extension == nsnull)
         return false;
 
@@ -861,17 +884,17 @@ TiledTextureImage::TiledTextureImage(GLC
                                      bool aUseNearestFilter)
     : TextureImage(aSize, LOCAL_GL_CLAMP_TO_EDGE, aContentType, aUseNearestFilter)
     , mCurrentImage(0)
     , mInUpdate(false)
     , mGL(aGL)
     , mUseNearestFilter(aUseNearestFilter)
     , mTextureState(Created)
 {
-    mTileSize = 256;//mGL->GetMaxTextureSize();
+    mTileSize = mGL->WantsSmallTiles() ? 256 : mGL->GetMaxTextureSize();
     if (aSize != nsIntSize(0,0)) {
         Resize(aSize);
     }
 }
 
 TiledTextureImage::~TiledTextureImage()
 {
 }
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -690,33 +690,36 @@ public:
      */
     virtual bool SupportsRobustness() = 0;
 
     enum {
         VendorIntel,
         VendorNVIDIA,
         VendorATI,
         VendorQualcomm,
+        VendorImagination,
         VendorOther
     };
 
     enum {
         RendererAdreno200,
+        RendererSGX540,
         RendererOther
     };
 
     int Vendor() const {
         return mVendor;
     }
 
     int Renderer() const {
         return mRenderer;
     }
 
     bool CanUploadSubTextures();
+    bool WantsSmallTiles();
 
     /**
      * If this context wraps a double-buffered target, swap the back
      * and front buffers.  It should be assumed that after a swap, the
      * contents of the new back buffer are undefined.
      */
     virtual bool SwapBuffers() { return false; }
 
--- a/mobile/android/base/gfx/GeckoGLLayerClient.java
+++ b/mobile/android/base/gfx/GeckoGLLayerClient.java
@@ -43,143 +43,26 @@ import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Point;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.util.Log;
 import android.view.View;
 
-public class GeckoGLLayerClient extends GeckoLayerClient
-                                implements FlexibleGLSurfaceView.Listener, VirtualLayer.Listener {
+public class GeckoGLLayerClient extends GeckoLayerClient {
     private static final String LOGTAG = "GeckoGLLayerClient";
 
-    private LayerRenderer mLayerRenderer;
     private boolean mLayerRendererInitialized;
 
     public GeckoGLLayerClient(Context context) {
         super(context);
     }
 
-    @Override
-    public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight,
-                             String metadata, boolean hasDirectTexture) {
-        Rect bufferRect = super.beginDrawing(width, height, tileWidth, tileHeight,
-                                             metadata, hasDirectTexture);
-        if (bufferRect == null) {
-            return null;
-        }
-
-        // Be sure to adjust the buffer size; if it's not at least as large as the viewport size,
-        // ViewportMetrics.getOptimumViewportOffset() gets awfully confused and severe display
-        // corruption results!
-        if (mBufferSize.width != width || mBufferSize.height != height) {
-            mBufferSize = new IntSize(width, height);
-        }
-
-        return bufferRect;
-    }
-
-    @Override
-    protected boolean handleDirectTextureChange(boolean hasDirectTexture) {
-        Log.e(LOGTAG, "### handleDirectTextureChange");
-        if (mTileLayer != null) {
-            return false;
-        }
-
-        Log.e(LOGTAG, "### Creating virtual layer");
-        VirtualLayer virtualLayer = new VirtualLayer();
-        virtualLayer.setListener(this);
-        virtualLayer.setSize(getBufferSize());
-        mLayerController.setRoot(virtualLayer);
-        mTileLayer = virtualLayer;
-
-        sendResizeEventIfNecessary(true);
-        return true;
-    }
-
-    @Override
-    public void setLayerController(LayerController layerController) {
-        super.setLayerController(layerController);
-
-        LayerView view = layerController.getView();
-        view.setListener(this);
-
-        mLayerRenderer = new LayerRenderer(view);
-    }
-
-    @Override
-    protected boolean shouldDrawProceed(int tileWidth, int tileHeight) {
-        Log.e(LOGTAG, "### shouldDrawProceed");
-        // Always draw.
-        return true;
-    }
-
-    @Override
-    protected void updateLayerAfterDraw(Rect updatedRect) {
-        Log.e(LOGTAG, "### updateLayerAfterDraw");
-        // Nothing to do.
-    }
-
-    @Override
-    protected IntSize getBufferSize() {
-        View view = mLayerController.getView();
-        IntSize size = new IntSize(view.getWidth(), view.getHeight());
-        Log.e(LOGTAG, "### getBufferSize " + size);
-        return size;
-    }
-
-    @Override
-    protected IntSize getTileSize() {
-        Log.e(LOGTAG, "### getTileSize " + getBufferSize());
-        return getBufferSize();
-    }
-
-    @Override
-    protected void tileLayerUpdated() {
-        // Set the new origin and resolution instantly.
-        mTileLayer.performUpdates(null);
-    }
-
-    @Override
-    public Bitmap getBitmap() {
-        Log.e(LOGTAG, "### getBitmap");
-        IntSize size = getBufferSize();
-        try {
-            return Bitmap.createBitmap(size.width, size.height, Bitmap.Config.RGB_565);
-        } catch (OutOfMemoryError oom) {
-            Log.e(LOGTAG, "Unable to create bitmap", oom);
-            return null;
-        }
-    }
-
-    public void dimensionsChanged(Point newOrigin, float newResolution) {
-        Log.e(LOGTAG, "### dimensionsChanged " + newOrigin + " " + newResolution);
-    }
-
-    /* Informs Gecko that the screen size has changed. */
-    @Override
-    protected void sendResizeEventIfNecessary(boolean force) {
-        Log.e(LOGTAG, "### sendResizeEventIfNecessary " + force);
-
-        IntSize newSize = getBufferSize();
-        if (!force && mScreenSize != null && mScreenSize.equals(newSize)) {
-            return;
-        }
-
-        mScreenSize = newSize;
-
-        Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize);
-        GeckoEvent event = GeckoEvent.createSizeChangedEvent(mScreenSize.width, mScreenSize.height,
-                                                             mScreenSize.width, mScreenSize.height,
-                                                             mScreenSize.width, mScreenSize.height);
-        GeckoAppShell.sendEventToGecko(event);
-    }
-
-    /** For Gecko to use. */
+    /** This function is invoked by Gecko via JNI; be careful when modifying signature. */
     public ViewTransform getViewTransform() {
         Log.e(LOGTAG, "### getViewTransform()");
 
         // NB: We don't begin a transaction here because this can be called in a synchronous
         // manner between beginDrawing() and endDrawing(), and that will cause a deadlock.
 
         synchronized (mLayerController) {
             ViewportMetrics viewportMetrics = mLayerController.getViewportMetrics();
@@ -189,55 +72,33 @@ public class GeckoGLLayerClient extends 
             float scrollY = viewportOrigin.y;
             float zoomFactor = viewportMetrics.getZoomFactor();
             Log.e(LOGTAG, "### Viewport metrics = " + viewportMetrics + " tile reso = " +
                   mTileLayer.getResolution());
             return new ViewTransform(scrollX, scrollY, zoomFactor);
         }
     }
 
-    public void renderRequested() {
-        Log.e(LOGTAG, "### Render requested, scheduling composite");
-        GeckoAppShell.scheduleComposite();
-    }
-
-    public void compositionPauseRequested() {
-        Log.e(LOGTAG, "### Scheduling PauseComposition");
-        GeckoAppShell.schedulePauseComposition();
-    }
-
-    public void compositionResumeRequested() {
-        Log.e(LOGTAG, "### Scheduling ResumeComposition");
-        GeckoAppShell.scheduleResumeComposition();
-    }
-
-    public void surfaceChanged(int width, int height) {
-        compositionPauseRequested();
-        mLayerController.setViewportSize(new FloatSize(width, height));
-        compositionResumeRequested();
-        renderRequested();
-    }
-
-    /** For Gecko to use. */
+    /** This function is invoked by Gecko via JNI; be careful when modifying signature. */
     public LayerRenderer.Frame createFrame() {
         // Create the shaders and textures if necessary.
         if (!mLayerRendererInitialized) {
             mLayerRenderer.createProgram();
             mLayerRendererInitialized = true;
         }
 
         // Build the contexts and create the frame.
         Layer.RenderContext pageContext = mLayerRenderer.createPageContext();
         Layer.RenderContext screenContext = mLayerRenderer.createScreenContext();
         return mLayerRenderer.createFrame(pageContext, screenContext);
     }
 
-    /** For Gecko to use. */
+    /** This function is invoked by Gecko via JNI; be careful when modifying signature. */
     public void activateProgram() {
         mLayerRenderer.activateProgram();
     }
 
-    /** For Gecko to use. */
+    /** This function is invoked by Gecko via JNI; be careful when modifying signature. */
     public void deactivateProgram() {
         mLayerRenderer.deactivateProgram();
     }
 }
 
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -43,31 +43,37 @@ import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoEventListener;
 import org.json.JSONException;
 import org.json.JSONObject;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Color;
+import android.graphics.Point;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.os.SystemClock;
 import android.util.DisplayMetrics;
 import android.util.Log;
+import android.view.View;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-public abstract class GeckoLayerClient implements GeckoEventListener {
+public abstract class GeckoLayerClient implements GeckoEventListener,
+                                                  FlexibleGLSurfaceView.Listener,
+                                                  VirtualLayer.Listener {
     private static final String LOGTAG = "GeckoLayerClient";
 
     protected LayerController mLayerController;
+    protected LayerRenderer mLayerRenderer;
 
     protected IntSize mScreenSize;
+    protected IntSize mWindowSize;
     protected IntSize mBufferSize;
 
     protected Layer mTileLayer;
 
     /* The viewport that Gecko is currently displaying. */
     protected ViewportMetrics mGeckoViewport;
 
     /* The viewport that Gecko will display when drawing is finished */
@@ -87,24 +93,16 @@ public abstract class GeckoLayerClient i
 
     private String mLastCheckerboardColor;
 
     private static Pattern sColorPattern;
 
     /* Used by robocop for testing purposes */
     private DrawListener mDrawListener;
 
-    protected abstract boolean handleDirectTextureChange(boolean hasDirectTexture);
-    protected abstract boolean shouldDrawProceed(int tileWidth, int tileHeight);
-    protected abstract void updateLayerAfterDraw(Rect updatedRect);
-    protected abstract IntSize getBufferSize();
-    protected abstract IntSize getTileSize();
-    protected abstract void tileLayerUpdated();
-    public abstract Bitmap getBitmap();
-
     public GeckoLayerClient(Context context) {
         mScreenSize = new IntSize(0, 0);
         mBufferSize = new IntSize(0, 0);
     }
 
     /** Attaches the root layer to the layer controller so that Gecko appears. */
     public void setLayerController(LayerController layerController) {
         mLayerController = layerController;
@@ -113,18 +111,24 @@ public abstract class GeckoLayerClient i
         if (mGeckoViewport != null) {
             layerController.setViewportMetrics(mGeckoViewport);
         }
 
         GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this);
         GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this);
 
         sendResizeEventIfNecessary();
+
+        LayerView view = layerController.getView();
+        view.setListener(this);
+
+        mLayerRenderer = new LayerRenderer(view);
     }
 
+    /** This function is invoked by Gecko via JNI; be careful when modifying signature. */
     public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight,
                              String metadata, boolean hasDirectTexture) {
         Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " +
               tileHeight + " " + hasDirectTexture);
 
         // If we've changed surface types, cancel this draw
         if (handleDirectTextureChange(hasDirectTexture)) {
             Log.e(LOGTAG, "### Cancelling draw due to direct texture change");
@@ -188,20 +192,29 @@ public abstract class GeckoLayerClient i
                     mTileLayer.endTransaction();
                 }
                 return null;
             }
             bufferRect.offset(Math.round(-currentOrigin.x), Math.round(-currentOrigin.y));
         }
 
         mTileLayer.beginTransaction(mLayerController.getView());
+
+        // Be sure to adjust the buffer size; if it's not at least as large as the viewport size,
+        // ViewportMetrics.getOptimumViewportOffset() gets awfully confused and severe display
+        // corruption results!
+        if (mBufferSize.width != width || mBufferSize.height != height) {
+            mBufferSize = new IntSize(width, height);
+        }
+
         return bufferRect;
     }
 
-    /*
+    /** This function is invoked by Gecko via JNI; be careful when modifying signature.
+     *
      * TODO: Would be cleaner if this took an android.graphics.Rect instead, but that would require
      * a little more JNI magic.
      */
     public void endDrawing(int x, int y, int width, int height) {
         synchronized (mLayerController) {
             try {
                 updateViewport(!mUpdateViewportOnEndDraw);
                 mUpdateViewportOnEndDraw = false;
@@ -246,39 +259,46 @@ public abstract class GeckoLayerClient i
         } else {
             mLayerController.setViewportMetrics(mGeckoViewport);
             mLayerController.abortPanZoomAnimation();
         }
     }
 
     /* Informs Gecko that the screen size has changed. */
     protected void sendResizeEventIfNecessary(boolean force) {
-        Log.e(LOGTAG, "### sendResizeEventIfNecessary " + force);
+        Log.d(LOGTAG, "### sendResizeEventIfNecessary " + force);
 
         DisplayMetrics metrics = new DisplayMetrics();
         GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
 
-        // Return immediately if the screen size hasn't changed or the viewport
-        // size is zero (which indicates that the rendering surface hasn't been
-        // allocated yet).
-        boolean screenSizeChanged = (metrics.widthPixels != mScreenSize.width ||
-                                     metrics.heightPixels != mScreenSize.height);
-        boolean viewportSizeValid = (mLayerController != null &&
-                                     mLayerController.getViewportSize().isPositive());
-        if (!(force || (screenSizeChanged && viewportSizeValid))) {
+        IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
+        IntSize newWindowSize = getBufferSize();
+
+        boolean screenSizeChanged = mScreenSize == null || !mScreenSize.equals(newScreenSize);
+        boolean windowSizeChanged = mWindowSize == null || !mWindowSize.equals(newWindowSize);
+
+        if (!force && !screenSizeChanged && !windowSizeChanged) {
             return;
         }
 
-        mScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
-        IntSize bufferSize = getBufferSize(), tileSize = getTileSize();
+        mScreenSize = newScreenSize;
+        mWindowSize = newWindowSize;
+
+        if (screenSizeChanged) {
+            Log.i(LOGTAG, "### Screen-size changed to " + mScreenSize);
+        }
 
-        Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize);
-        GeckoEvent event = GeckoEvent.createSizeChangedEvent(bufferSize.width, bufferSize.height,
-                                                             metrics.widthPixels, metrics.heightPixels,
-                                                             tileSize.width, tileSize.height);
+        if (windowSizeChanged) {
+            Log.i(LOGTAG, "### Window-size changed to " + mWindowSize);
+        }
+
+        IntSize bufferSize = getBufferSize();
+        GeckoEvent event = GeckoEvent.createSizeChangedEvent(mWindowSize.width, mWindowSize.height, // Window (buffer) size
+                                                             mScreenSize.width, mScreenSize.height, // Screen size
+                                                             0, 0);                                 // Tile-size (unused)
         GeckoAppShell.sendEventToGecko(event);
     }
 
     // Parses a color from an RGB triple of the form "rgb([0-9]+, [0-9]+, [0-9]+)". If the color
     // cannot be parsed, returns white.
     private static int parseColorFromGecko(String string) {
         if (sColorPattern == null) {
             sColorPattern = Pattern.compile("rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)");
@@ -290,16 +310,72 @@ public abstract class GeckoLayerClient i
         }
 
         int r = Integer.parseInt(matcher.group(1));
         int g = Integer.parseInt(matcher.group(2));
         int b = Integer.parseInt(matcher.group(3));
         return Color.rgb(r, g, b);
     }
 
+    protected boolean handleDirectTextureChange(boolean hasDirectTexture) {
+        Log.e(LOGTAG, "### handleDirectTextureChange");
+        if (mTileLayer != null) {
+            return false;
+        }
+
+        Log.e(LOGTAG, "### Creating virtual layer");
+        VirtualLayer virtualLayer = new VirtualLayer();
+        virtualLayer.setListener(this);
+        virtualLayer.setSize(getBufferSize());
+        mLayerController.setRoot(virtualLayer);
+        mTileLayer = virtualLayer;
+
+        sendResizeEventIfNecessary(true);
+        return true;
+    }
+
+    protected boolean shouldDrawProceed(int tileWidth, int tileHeight) {
+        Log.e(LOGTAG, "### shouldDrawProceed");
+        // Always draw.
+        return true;
+    }
+
+    protected void updateLayerAfterDraw(Rect updatedRect) {
+        Log.e(LOGTAG, "### updateLayerAfterDraw");
+        // Nothing to do.
+    }
+
+    protected IntSize getBufferSize() {
+        View view = mLayerController.getView();
+        IntSize size = new IntSize(view.getWidth(), view.getHeight());
+        Log.e(LOGTAG, "### getBufferSize " + size);
+        return size;
+    }
+
+    protected IntSize getTileSize() {
+        Log.e(LOGTAG, "### getTileSize " + getBufferSize());
+        return getBufferSize();
+    }
+
+    protected void tileLayerUpdated() {
+        // Set the new origin and resolution instantly.
+        mTileLayer.performUpdates(null);
+    }
+
+    public Bitmap getBitmap() {
+        Log.e(LOGTAG, "### getBitmap");
+        IntSize size = getBufferSize();
+        try {
+            return Bitmap.createBitmap(size.width, size.height, Bitmap.Config.RGB_565);
+        } catch (OutOfMemoryError oom) {
+            Log.e(LOGTAG, "Unable to create bitmap", oom);
+            return null;
+        }
+    }
+
     public void render() {
         adjustViewportWithThrottling();
     }
 
     private void adjustViewportWithThrottling() {
         if (!mLayerController.getRedrawHint())
             return;
 
@@ -377,16 +453,47 @@ public abstract class GeckoLayerClient i
             return new ViewportMetrics(mGeckoViewport);
         return null;
     }
 
     private void sendResizeEventIfNecessary() {
         sendResizeEventIfNecessary(false);
     }
 
+    /** Implementation of FlexibleGLSurfaceView.Listener */
+    public void renderRequested() {
+        Log.e(LOGTAG, "### Render requested, scheduling composite");
+        GeckoAppShell.scheduleComposite();
+    }
+
+    /** Implementation of FlexibleGLSurfaceView.Listener */
+    public void compositionPauseRequested() {
+        Log.e(LOGTAG, "### Scheduling PauseComposition");
+        GeckoAppShell.schedulePauseComposition();
+    }
+
+    /** Implementation of FlexibleGLSurfaceView.Listener */
+    public void compositionResumeRequested() {
+        Log.e(LOGTAG, "### Scheduling ResumeComposition");
+        GeckoAppShell.scheduleResumeComposition();
+    }
+
+    /** Implementation of FlexibleGLSurfaceView.Listener */
+    public void surfaceChanged(int width, int height) {
+        compositionPauseRequested();
+        mLayerController.setViewportSize(new FloatSize(width, height));
+        compositionResumeRequested();
+        renderRequested();
+    }
+
+    /** Implementation of VirtualLayer.Listener */
+    public void dimensionsChanged(Point newOrigin, float newResolution) {
+        Log.e(LOGTAG, "### dimensionsChanged " + newOrigin + " " + newResolution);
+    }
+
     /** Used by robocop for testing purposes. Not for production use! This is called via reflection by robocop. */
     public void setDrawListener(DrawListener listener) {
         mDrawListener = listener;
     }
 
     /** Used by robocop for testing purposes. Not for production use! This is used via reflection by robocop. */
     public interface DrawListener {
         public void drawFinished(int x, int y, int width, int height);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2034,17 +2034,16 @@ Tab.prototype = {
         aMetadata.defaultZoom *= scaleRatio;
       if ("minZoom" in aMetadata && aMetadata.minZoom > 0)
         aMetadata.minZoom *= scaleRatio;
       if ("maxZoom" in aMetadata && aMetadata.maxZoom > 0)
         aMetadata.maxZoom *= scaleRatio;
     }
     ViewportHandler.setMetadataForDocument(this.browser.contentDocument, aMetadata);
     this.updateViewportSize();
-    this.updateViewport(true);
   },
 
   /** Update viewport when the metadata or the window size changes. */
   updateViewportSize: function updateViewportSize() {
     let browser = this.browser;
     if (!browser)
       return;
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -923,26 +923,20 @@ nsWindow::OnGlobalAndroidEvent(AndroidGe
             win->mBounds.height = 0;
             // also resize the children
             for (PRUint32 i = 0; i < win->mChildren.Length(); i++) {
                 win->mChildren[i]->mBounds.width = 0;
                 win->mChildren[i]->mBounds.height = 0;
             }
         case AndroidGeckoEvent::SIZE_CHANGED: {
             nsTArray<nsIntPoint> points = ae->Points();
-            NS_ASSERTION(points.Length() != 3, "Size changed does not have enough coordinates");
+            NS_ASSERTION(points.Length() == 3, "Size changed does not have enough coordinates");
 
-#ifdef MOZ_JAVA_COMPOSITOR
-            int nw = points[1].x;
-            int nh = points[1].y;
-#else
             int nw = points[0].x;
             int nh = points[0].y;
-#endif
-
 
             if (ae->Type() == AndroidGeckoEvent::FORCED_RESIZE || nw != gAndroidBounds.width ||
                 nh != gAndroidBounds.height) {
 
                 gAndroidBounds.width = nw;
                 gAndroidBounds.height = nh;
 
                 // tell all the windows about the new size