Bug 711333 - Fix race condition when moving and updating textures. r=kats
authorPatrick Walton <pwalton@mozilla.com>
Fri, 30 Dec 2011 14:08:58 -0800
changeset 84819 d4c526ba534353396ea1d12c49b5c60b67f8a56e
parent 84818 f2610136fb54094038a312f6d92ba4f5a428fdb5
child 84820 2ea7afaa47a90d18c2ff51095d7e0daa8e4d9dfe
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs711333
milestone12.0a1
Bug 711333 - Fix race condition when moving and updating textures. r=kats
mobile/android/base/gfx/GeckoSoftwareLayerClient.java
--- a/mobile/android/base/gfx/GeckoSoftwareLayerClient.java
+++ b/mobile/android/base/gfx/GeckoSoftwareLayerClient.java
@@ -175,53 +175,53 @@ public class GeckoSoftwareLayerClient ex
             // JS-side viewport dimensions override the java-side ones because
             // java is the One True Source of this information, and allowing JS
             // to override can lead to race conditions where this data gets clobbered.
             FloatSize viewportSize = getLayerController().getViewportSize();
             mGeckoViewport = new ViewportMetrics(viewportObject);
             mGeckoViewport.setSize(viewportSize);
 
             LayerController controller = getLayerController();
-            synchronized (controller) {
-                PointF displayportOrigin = mGeckoViewport.getDisplayportOrigin();
-                mTileLayer.setOrigin(PointUtils.round(displayportOrigin));
-                mTileLayer.setResolution(mGeckoViewport.getZoomFactor());
+            PointF displayportOrigin = mGeckoViewport.getDisplayportOrigin();
+            mTileLayer.setOrigin(PointUtils.round(displayportOrigin));
+            mTileLayer.setResolution(mGeckoViewport.getZoomFactor());
 
-                if (onlyUpdatePageSize) {
-                    // Don't adjust page size when zooming unless zoom levels are
-                    // approximately equal.
-                    if (FloatUtils.fuzzyEquals(controller.getZoomFactor(),
-                            mGeckoViewport.getZoomFactor()))
-                        controller.setPageSize(mGeckoViewport.getPageSize());
-                } else {
-                    Log.d(LOGTAG, "Received viewport update from gecko");
-                    controller.setViewportMetrics(mGeckoViewport);
-                    controller.abortPanZoomAnimation();
-                }
+            if (onlyUpdatePageSize) {
+                // Don't adjust page size when zooming unless zoom levels are
+                // approximately equal.
+                if (FloatUtils.fuzzyEquals(controller.getZoomFactor(),
+                        mGeckoViewport.getZoomFactor()))
+                    controller.setPageSize(mGeckoViewport.getPageSize());
+            } else {
+                Log.d(LOGTAG, "Received viewport update from gecko");
+                controller.setViewportMetrics(mGeckoViewport);
+                controller.abortPanZoomAnimation();
             }
         } catch (JSONException e) {
             Log.e(LOGTAG, "Bad viewport description: " + viewportDescription);
             throw new RuntimeException(e);
         }
     }
 
     /*
      * 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, String metadata) {
-        try {
-            updateViewport(metadata, !mUpdateViewportOnEndDraw);
-            mUpdateViewportOnEndDraw = false;
-            Rect rect = new Rect(x, y, x + width, y + height);
+        synchronized (getLayerController()) {
+            try {
+                updateViewport(metadata, !mUpdateViewportOnEndDraw);
+                mUpdateViewportOnEndDraw = false;
+                Rect rect = new Rect(x, y, x + width, y + height);
 
-            if (mTileLayer instanceof SingleTileLayer)
-                ((SingleTileLayer)mTileLayer).invalidate(rect);
-        } finally {
-            endTransaction(mTileLayer);
+                if (mTileLayer instanceof SingleTileLayer)
+                    ((SingleTileLayer)mTileLayer).invalidate(rect);
+            } finally {
+                endTransaction(mTileLayer);
+            }
         }
     }
 
     public ViewportMetrics getGeckoViewportMetrics() {
         // Return a copy, as we modify this inside the Gecko thread
         if (mGeckoViewport != null)
             return new ViewportMetrics(mGeckoViewport);
         return null;