diff --git a/mobile/android/base/gfx/FloatSize.java b/mobile/android/base/gfx/FloatSize.java index 1824b27edda..07dfc9fe845 100644 --- a/mobile/android/base/gfx/FloatSize.java +++ b/mobile/android/base/gfx/FloatSize.java @@ -61,6 +61,10 @@ public class FloatSize { @Override public String toString() { return "(" + width + "," + height + ")"; } + public boolean isPositive() { + return (width > 0 && height > 0); + } + public boolean fuzzyEquals(FloatSize size) { return (FloatUtils.fuzzyEquals(size.width, width) && FloatUtils.fuzzyEquals(size.height, height)); diff --git a/mobile/android/base/gfx/GeckoSoftwareLayerClient.java b/mobile/android/base/gfx/GeckoSoftwareLayerClient.java index f5e0ee52b52..cec9e83988d 100644 --- a/mobile/android/base/gfx/GeckoSoftwareLayerClient.java +++ b/mobile/android/base/gfx/GeckoSoftwareLayerClient.java @@ -429,8 +429,14 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL DisplayMetrics metrics = new DisplayMetrics(); GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); - if (!force && metrics.widthPixels == mScreenSize.width && - metrics.heightPixels == mScreenSize.height) { + // 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 = (getLayerController() != null && + getLayerController().getViewportSize().isPositive()); + if (!(force || (screenSizeChanged && viewportSizeValid))) { return; }