diff options
author | Owen Lin <owenlin@google.com> | 2012-08-29 16:36:08 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-08-29 16:50:29 +0800 |
commit | fb6aafde995cfaeb57f3009f10a4c0c843993162 (patch) | |
tree | d8d8d0a79a7f94fffbf0244df37de86d464a70cf | |
parent | 894300ca4d2da44e9c4fb5d8ec7d7a5d8662da51 (diff) | |
download | android_packages_apps_Snap-fb6aafde995cfaeb57f3009f10a4c0c843993162.tar.gz android_packages_apps_Snap-fb6aafde995cfaeb57f3009f10a4c0c843993162.tar.bz2 android_packages_apps_Snap-fb6aafde995cfaeb57f3009f10a4c0c843993162.zip |
Fix OOM in TileImageView.
The problem is we keep too many decoded images in the upload queue.
Those images will be free after it getting uploaded.
However, there is a bug which suspend the uploading sometimes.
Change-Id: Id97c04eba974cc77e5d8c50588b0cbef776f79da
fix: 6995091
-rw-r--r-- | src/com/android/gallery3d/ui/TextureUploader.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/TileImageView.java | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/ui/TextureUploader.java b/src/com/android/gallery3d/ui/TextureUploader.java index 714b09795..9a8c47fc6 100644 --- a/src/com/android/gallery3d/ui/TextureUploader.java +++ b/src/com/android/gallery3d/ui/TextureUploader.java @@ -29,7 +29,7 @@ public class TextureUploader implements OnGLIdleListener { private final ArrayDeque<UploadedTexture> mBgTextures = new ArrayDeque<UploadedTexture>(INIT_CAPACITY); private final GLRoot mGLRoot; - private transient boolean mIsQueued = false; + private volatile boolean mIsQueued = false; public TextureUploader(GLRoot root) { mGLRoot = root; diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index fc61efd64..9eb4f4787 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -270,6 +270,7 @@ public class TileImageView extends GLView { protected synchronized void invalidateTiles() { mDecodeQueue.clean(); mUploadQueue.clean(); + // TODO disable decoder int n = mActiveTiles.size(); for (int i = 0; i < n; i++) { @@ -553,21 +554,23 @@ public class TileImageView extends GLView { @Override public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) { - if (renderRequested) return false; + // Skips uploading if there is a pending rendering request. + // Returns true to keep uploading in next rendering loop. + if (renderRequested) return true; int quota = UPLOAD_LIMIT; - Tile tile; - while (true) { + Tile tile = null; + while (quota > 0) { synchronized (TileImageView.this) { tile = mUploadQueue.pop(); } - if (tile == null || quota <= 0) break; + if (tile == null) break; if (!tile.isContentValid()) { Utils.assertTrue(tile.mTileState == STATE_DECODED); tile.updateContent(canvas); --quota; } } - mActive.set(tile != null); + if (tile == null) mActive.set(false); return tile != null; } } |