OSDN Git Service

Fix ANR in webkit
authorNicolas Roard <nicolasroard@google.com>
Mon, 8 Aug 2011 22:57:28 +0000 (15:57 -0700)
committerNicolas Roard <nicolasroard@google.com>
Mon, 8 Aug 2011 23:01:53 +0000 (16:01 -0700)
bug:5128336
Change-Id: I591882eb9bd96a04fd34299a8bf76d35a9462d94

Source/WebCore/platform/graphics/android/GLWebViewState.cpp
Source/WebCore/platform/graphics/android/LayerAndroid.cpp
Source/WebCore/platform/graphics/android/PaintTileOperation.cpp
Source/WebCore/platform/graphics/android/PaintTileOperation.h
Source/WebCore/platform/graphics/android/PaintedSurface.h
Source/WebCore/platform/graphics/android/TexturesGenerator.cpp
Source/WebCore/platform/graphics/android/TexturesGenerator.h
Source/WebCore/platform/graphics/android/TiledTexture.cpp
Source/WebCore/platform/graphics/android/TilesManager.cpp
Source/WebCore/platform/graphics/android/TilesManager.h

index 4155461..748c5e9 100644 (file)
@@ -554,10 +554,8 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
     // the BaseTiles' texture.
     TilesManager::instance()->transferQueue()->updateDirtyBaseTiles();
 
-    if (compositedRoot != m_previouslyUsedRoot) {
+    if (compositedRoot != m_previouslyUsedRoot)
         TilesManager::instance()->swapLayersTextures(m_previouslyUsedRoot, compositedRoot);
-        TilesManager::instance()->cleanupTilesTextures();
-    }
 
     bool ret = baseLayer->drawGL(compositedRoot, rect, viewport, webViewRect,
                                  titleBarHeight, clip, scale, pagesSwapped, color);
index 00db27c..97ff692 100644 (file)
@@ -164,6 +164,7 @@ LayerAndroid::~LayerAndroid()
 {
     if (m_texture)
         m_texture->removeLayer(this);
+    SkSafeUnref(m_texture);
     removeChildren();
     delete m_extra;
     delete m_contentsImage;
@@ -719,6 +720,7 @@ void LayerAndroid::assignTexture(LayerAndroid* oldTree)
         if (oldLayer && oldLayer->texture()) {
             oldLayer->texture()->replaceLayer(this);
             m_texture = oldLayer->texture();
+            SkSafeRef(m_texture);
         }
     }
 
index d5623df..064ffb9 100644 (file)
 #include "config.h"
 #include "PaintTileOperation.h"
 #include "LayerAndroid.h"
+#include "PaintedSurface.h"
 
 namespace WebCore {
 
-PaintTileOperation::PaintTileOperation(BaseTile* tile, LayerAndroid* layer)
+PaintTileOperation::PaintTileOperation(BaseTile* tile, PaintedSurface* surface)
     : QueuedOperation(QueuedOperation::PaintTile, tile->page())
     , m_tile(tile)
-    , m_layer(layer)
+    , m_surface(surface)
+    , m_layer(0)
 {
     if (m_tile)
         m_tile->setRepaintPending(true);
+    if (m_surface)
+        m_layer = surface->layer();
+    SkSafeRef(m_surface);
     SkSafeRef(m_layer);
 }
 
@@ -45,6 +50,7 @@ PaintTileOperation::~PaintTileOperation()
         m_tile->setRepaintPending(false);
         m_tile = 0;
     }
+    SkSafeUnref(m_surface);
     SkSafeUnref(m_layer);
 }
 
index 4d1bb1a..72a4125 100644 (file)
 namespace WebCore {
 
 class LayerAndroid;
+class PaintedSurface;
 
 class PaintTileOperation : public QueuedOperation {
 public:
-    PaintTileOperation(BaseTile* tile, LayerAndroid* layer = 0);
+    PaintTileOperation(BaseTile* tile, PaintedSurface* surface = 0);
     virtual ~PaintTileOperation();
     virtual bool operator==(const QueuedOperation* operation);
     virtual void run();
@@ -44,6 +45,7 @@ public:
 
 private:
     BaseTile* m_tile;
+    PaintedSurface* m_surface;
     LayerAndroid* m_layer;
 };
 
index 39d6154..84fe64c 100644 (file)
@@ -30,6 +30,7 @@
 #include "ClassTracker.h"
 #include "IntRect.h"
 #include "LayerAndroid.h"
+#include "SkRefCnt.h"
 #include "TextureOwner.h"
 #include "TiledTexture.h"
 #include "TilesManager.h"
@@ -40,7 +41,7 @@ class SkCanvas;
 
 namespace WebCore {
 
-class PaintedSurface : public TilePainter {
+class PaintedSurface : public SkRefCnt, TilePainter {
 public:
     PaintedSurface(LayerAndroid* layer)
         : m_layer(layer)
index 9780336..3f7d6a3 100644 (file)
@@ -70,11 +70,6 @@ void TexturesGenerator::removePaintOperationsForPage(TiledPage* page, bool waitF
     removeOperationsForFilter(new PagePaintFilter(page), waitForRunning);
 }
 
-void TexturesGenerator::removeOperationsForPainter(TilePainter* painter, bool waitForRunning)
-{
-    removeOperationsForFilter(new TilePainterFilter(painter), waitForRunning);
-}
-
 void TexturesGenerator::removeOperationsForFilter(OperationFilter* filter)
 {
     removeOperationsForFilter(filter, true);
index bac198c..19ab1af 100644 (file)
@@ -49,7 +49,6 @@ public:
     virtual status_t readyToRun();
 
     void removeOperationsForPage(TiledPage* page);
-    void removeOperationsForPainter(TilePainter* painter, bool waitForRunning);
     void removePaintOperationsForPage(TiledPage* page, bool waitForRunning);
     void removeOperationsForFilter(OperationFilter* filter);
     void removeOperationsForFilter(OperationFilter* filter, bool waitForRunning);
index a49c6c6..d975825 100644 (file)
@@ -139,7 +139,7 @@ void TiledTexture::prepareTile(bool repaint, int x, int y)
 
     LayerAndroid* layer = m_surface->layer();
     if (schedule && layer && !tile->isRepaintPending()) {
-        PaintTileOperation *operation = new PaintTileOperation(tile, layer);
+        PaintTileOperation *operation = new PaintTileOperation(tile, m_surface);
         TilesManager::instance()->scheduleOperation(operation);
     }
 }
@@ -228,7 +228,6 @@ void TiledTexture::endPaint()
 
 void TiledTexture::removeTiles()
 {
-    TilesManager::instance()->removeOperationsForPainter(this, true);
     for (unsigned int i = 0; i < m_tiles.size(); i++) {
         delete m_tiles[i];
     }
index bf14c61..ba48111 100644 (file)
@@ -198,40 +198,6 @@ void TilesManager::addPaintedSurface(PaintedSurface* surface)
     m_paintedSurfaces.append(surface);
 }
 
-void TilesManager::cleanupTilesTextures()
-{
-    // release existing surfaces without layers
-    WTF::Vector<PaintedSurface*> collect;
-    for (unsigned int i = 0; i < m_paintedSurfaces.size(); i++) {
-        PaintedSurface* surface = m_paintedSurfaces[i];
-        if (!surface->layer() && !surface->busy())
-            collect.append(surface);
-    }
-    XLOG("remove %d / %d PaintedSurfaces", collect.size(), m_paintedSurfaces.size());
-    for (unsigned int i = 0; i < collect.size(); i++) {
-        m_paintedSurfaces.remove(m_paintedSurfaces.find(collect[i]));
-        TilePainter* painter = collect[i]->texture();
-        // Mark the current painter to destroy!!
-        m_pixmapsGenerationThread->removeOperationsForPainter(painter, true);
-        XLOG("destroy %x (%x)", collect[i], painter);
-        delete collect[i];
-    }
-    for (unsigned int i = 0; i < m_tilesTextures.size(); i++) {
-        BaseTileTexture* texture = m_tilesTextures[i];
-        texture->setUsedLevel(-1);
-        if (texture->owner()) {
-            bool keep = false;
-            for (unsigned int j = 0; j < m_paintedSurfaces.size(); j++) {
-                if (m_paintedSurfaces[j]->owns(texture))
-                    keep = true;
-            }
-            if (!keep) {
-                texture->release(texture->owner());
-            }
-        }
-    }
-}
-
 BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
 {
     android::Mutex::Autolock lock(m_texturesLock);
index 3541422..8f0ac7f 100644 (file)
@@ -66,11 +66,6 @@ public:
         m_pixmapsGenerationThread->removeOperationsForPage(page);
     }
 
-    void removeOperationsForPainter(TilePainter* painter, bool waitForCompletion)
-    {
-        m_pixmapsGenerationThread->removeOperationsForPainter(painter, waitForCompletion);
-    }
-
     void removePaintOperationsForPage(TiledPage* page, bool waitForCompletion)
     {
         m_pixmapsGenerationThread->removePaintOperationsForPage(page, waitForCompletion);
@@ -90,8 +85,6 @@ public:
 
     BaseTileTexture* getAvailableTexture(BaseTile* owner);
 
-    void cleanupTilesTextures();
-
     void markGeneratorAsReady()
     {
         {