Fix race conditions when updating view transform, by switching to an absolute transform.
authorAli Juma <ajuma@mozilla.com>
Fri, 10 Feb 2012 16:08:24 -0500
changeset 92431 731ab9e54b5e48f35d7da1af101e9e807214ef72
parent 92430 02a93a9ff51a5184fc9101ef2aebfc1c614a64f7
child 92432 7fafa64fced9e0800ad643a1085900a19b13ab7b
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [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
Fix race conditions when updating view transform, by switching to an absolute transform.
gfx/layers/ipc/CompositorParent.cpp
mobile/android/base/gfx/GeckoGLLayerClient.java
mobile/android/chrome/content/browser.js
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -163,29 +163,24 @@ CompositorParent::Composite()
   mCurrentCompositeTask = NULL;
 
   if (mPaused || !mLayerManager) {
     return;
   }
 
 #ifdef MOZ_WIDGET_ANDROID
   RequestViewTransform();
-#endif
-
-  gfx3DMatrix worldTransform;
-  gfxPoint3D offset(-mScrollOffset.x, -mScrollOffset.y, 0.0f);
+  Layer* layer = GetPrimaryScrollableLayer();
   printf_stderr("Correcting for position fixed %i, %i\n", -mScrollOffset.x, -mScrollOffset.y);
-  worldTransform.Translate(offset);
-  worldTransform.Scale(mXScale, mYScale, 1.0f);
-#ifdef MOZ_WIDGET_ANDROID
-  Layer* layer = GetPrimaryScrollableLayer();
+  ViewTransform v(mScrollOffset, mXScale, mYScale);
+  TransformShadowTree(layer, v);
 #else
   Layer* layer = mLayerManager->GetRoot();
+  layer->AsShadowLayer()->SetShadowTransform(worldTransform);
 #endif
-  layer->AsShadowLayer()->SetShadowTransform(worldTransform);
 
 #if 0
 #ifdef MOZ_WIDGET_ANDROID
   // Hang the transform of the root layer off the layer manager.
   gfx3DMatrix transform = layer->GetTransform();
   transform *= worldTransform;
   TransformLayerUserData* transformUserData = new TransformLayerUserData(transform);
   mLayerManager->SetUserData(nsGkAtoms::transform, transformUserData);
--- a/mobile/android/base/gfx/GeckoGLLayerClient.java
+++ b/mobile/android/base/gfx/GeckoGLLayerClient.java
@@ -182,19 +182,19 @@ public class GeckoGLLayerClient extends 
         // 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.
 
         LayerController layerController = getLayerController();
         synchronized (layerController) {
             ViewportMetrics viewportMetrics = layerController.getViewportMetrics();
             PointF viewportOrigin = viewportMetrics.getOrigin();
             Point tileOrigin = mTileLayer.getOrigin();
-            float scrollX = viewportOrigin.x - tileOrigin.x;
-            float scrollY = viewportOrigin.y - tileOrigin.y;
-            float zoomFactor = viewportMetrics.getZoomFactor() / mTileLayer.getResolution();
+            float scrollX = viewportOrigin.x; 
+            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");
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1580,17 +1580,19 @@ Tab.prototype = {
       this.viewportExcess.x = excessX;
     }
     if ((aViewport.offsetY != this._viewport.offsetY) ||
         (excessY != this.viewportExcess.y)) {
       this._viewport.offsetY = aViewport.offsetY;
       this.viewportExcess.y = excessY;
     }
     if (Math.abs(aViewport.zoom - this._viewport.zoom) >= 1e-6) {
-      this._viewport.zoom = aViewport.zoom;
+      //FIXME: Uncomment once zoom is working again.
+      //this._viewport.zoom = aViewport.zoom;
+      this._viewport.zoom = 1;
     }
   },
 
   screenshot: function(aSrc, aDst) {
       // FIXME: Reenable
       //if (!this.browser || !this.browser.contentWindow)
         return;
 
@@ -1666,17 +1668,19 @@ Tab.prototype = {
 
   updateViewport: function(aReset, aZoomLevel) {
     dump("### JS side updateViewport " + aReset + " zoom " + aZoomLevel + "\n");
 
     if (!aZoomLevel)
       aZoomLevel = this.getDefaultZoomLevel();
 
     let win = this.browser.contentWindow;
-    let zoom = (aReset ? aZoomLevel : this._viewport.zoom);
+    //FIXME: Uncomment when zoom is working again.
+    //let zoom = (aReset ? aZoomLevel : this._viewport.zoom);
+    zoom = 1;
     let xpos = ((aReset && win) ? win.scrollX * zoom : this._viewport.x);
     let ypos = ((aReset && win) ? win.scrollY * zoom : this._viewport.y);
 
     this.viewportExcess = { x: 0, y: 0 };
     this.viewport = { x: xpos, y: ypos,
                       offsetX: 0, offsetY: 0,
                       width: this._viewport.width, height: this._viewport.height,
                       pageWidth: gScreenWidth, pageHeight: gScreenHeight,