Bug 703256 - Fix incorrect thread access [r=pcwalton]
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 21 Nov 2011 10:06:20 -0500
changeset 83557 6e07405e7c5098c956d29103bebf6aec5bc193d4
parent 83556 74e9842f2d0fa56fa1aad636794dad176aab47d9
child 83558 2b458bfe5a17d7436b2ac961467a649173f96dce
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs703256
milestone11.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
Bug 703256 - Fix incorrect thread access [r=pcwalton] Make sure things that touch the zoom/pan state and view hierarchy are executing on the main UI thread.
mobile/android/base/gfx/LayerRenderer.java
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -171,25 +171,31 @@ public class LayerRenderer implements GL
 
         int left = Math.max(0, rect.left);
         int top = Math.max(0, rect.top);
         int right = Math.min(screenSize.width, rect.right);
         int bottom = Math.min(screenSize.height, rect.bottom);
         return new Rect(left, top, right, bottom);
     }
 
-    public void onSurfaceChanged(GL10 gl, int width, int height) {
+    public void onSurfaceChanged(GL10 gl, final int width, final int height) {
         gl.glViewport(0, 0, width, height);
         gl.glMatrixMode(GL10.GL_PROJECTION);
         gl.glLoadIdentity();
         gl.glOrthof(0.0f, (float)width, (float)height, 0.0f, -10.0f, 10.0f);
         gl.glMatrixMode(GL10.GL_MODELVIEW);
         gl.glLoadIdentity();
 
-        mView.setScreenSize(width, height);
+        // updating the state in the view/controller/client should be
+        // done on the main UI thread, not the GL renderer thread
+        mView.post(new Runnable() {
+            public void run() {
+                mView.setScreenSize(width, height);
+            }
+        });
 
         /* TODO: Throw away tile images? */
     }
 
     private void checkFPS() {
         if (System.currentTimeMillis() >= mFrameCountTimestamp + 1000) {
             mFrameCountTimestamp = System.currentTimeMillis();