Bug 750778 - Ensure PluginLayer is always present when plugin is visible r=blassey
authorJames Willcox <jwillcox@mozilla.com>
Fri, 11 May 2012 10:54:51 -0400
changeset 93784 0f2444af3a1df8b7284de44cdedc5e2b279ff722
parent 93783 b3cc73614c0908baf7ef4495245fea2c4f533700
child 93785 8489ba281a04e3eb335b0c16b498af3d337e809c
push id9317
push userjwillcox@mozilla.com
push dateFri, 11 May 2012 14:55:16 +0000
treeherdermozilla-inbound@0f2444af3a1d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs750778
milestone15.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 750778 - Ensure PluginLayer is always present when plugin is visible r=blassey
mobile/android/base/GeckoApp.java
mobile/android/base/gfx/LayerRenderer.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1349,21 +1349,22 @@ abstract public class GeckoApp
             public void run() {
                 Tabs tabs = Tabs.getInstance();
                 Tab tab = tabs.getSelectedTab();
 
                 PluginLayer layer = (PluginLayer) tab.getPluginLayer(view);
                 if (layer == null) {
                     layer = new PluginLayer(view, rect, mLayerController.getView().getRenderer().getMaxTextureSize());
                     tab.addPluginLayer(view, layer);
-                    mLayerController.getView().addLayer(layer);
                 } else {
                     layer.reset(rect);
                     layer.setVisible(true);
                 }
+
+                mLayerController.getView().addLayer(layer);
             }
         });
     }
 
     void removePluginView(final View view) {
         mMainHandler.post(new Runnable() { 
             public void run() {
                 Tabs tabs = Tabs.getInstance();
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -66,17 +66,17 @@ import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.WindowManager;
 import javax.microedition.khronos.egl.EGLConfig;
 import javax.microedition.khronos.opengles.GL10;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
-import java.util.ArrayList;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * The layer renderer implements the rendering logic for a layer view.
  */
 public class LayerRenderer implements GLSurfaceView.Renderer {
     private static final String LOGTAG = "GeckoLayerRenderer";
     private static final String PROFTAG = "GeckoLayerRendererProf";
 
@@ -98,17 +98,17 @@ public class LayerRenderer implements GL
     private final ScrollbarLayer mVertScrollLayer;
     private final FadeRunnable mFadeRunnable;
     private ByteBuffer mCoordByteBuffer;
     private FloatBuffer mCoordBuffer;
     private RenderContext mLastPageContext;
     private int mMaxTextureSize;
     private int mBackgroundColor;
 
-    private ArrayList<Layer> mExtraLayers = new ArrayList<Layer>();
+    private CopyOnWriteArrayList<Layer> mExtraLayers = new CopyOnWriteArrayList<Layer>();
 
     // Dropped frames display
     private int[] mFrameTimings;
     private int mCurrentFrame, mFrameTimingsSum, mDroppedFrames;
 
     // Render profiling output
     private int mFramesRendered;
     private float mCompleteFramesRendered;
@@ -287,29 +287,29 @@ public class LayerRenderer implements GL
 
     public int getMaxTextureSize() {
         return mMaxTextureSize;
     }
 
     public void addLayer(Layer layer) {
         LayerController controller = mView.getController();
 
-        synchronized (controller) {
+        synchronized (mExtraLayers) {
             if (mExtraLayers.contains(layer)) {
                 mExtraLayers.remove(layer);
             }
 
             mExtraLayers.add(layer);
         }
     }
 
     public void removeLayer(Layer layer) {
         LayerController controller = mView.getController();
 
-        synchronized (controller) {
+        synchronized (mExtraLayers) {
             mExtraLayers.remove(layer);
         }
     }
 
     /**
      * Called whenever a new frame is about to be drawn.
      */
     public void onDrawFrame(GL10 gl) {