summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
diff options
context:
space:
mode:
authorRay Chen <raychen@google.com>2012-05-02 15:31:38 +0800
committerRay Chen <raychen@google.com>2012-05-02 15:31:38 +0800
commit6fc8d72ce0814a70c74be71fb9d0775b8d7ca768 (patch)
tree2b7c3f54e4516b0b93f4e823a0cd6b14a31bfe9a /src/com/android/gallery3d
parent814360ae97d59e333440076b5517fff0c6be5ca9 (diff)
downloadandroid_packages_apps_Gallery2-6fc8d72ce0814a70c74be71fb9d0775b8d7ca768.tar.gz
android_packages_apps_Gallery2-6fc8d72ce0814a70c74be71fb9d0775b8d7ca768.tar.bz2
android_packages_apps_Gallery2-6fc8d72ce0814a70c74be71fb9d0775b8d7ca768.zip
Fix 6341866 ANR in com.google.android.gallery3d due to com.android.gallery3d.ui.TileImageViewAdapter.setScreenNail
RegionDecoder is run in a lower priority thread but it uses the same lock as setScreenNail while decoding, so a priority inversion causes this ANR. The change tries to separate the lock so setScreenNail doesn't have to wait on the decoding process so the ANR could be avoided. Change-Id: I02cc26fa0535adaa57cdcf94b819970e179311d1 b:6341866
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/ui/TileImageViewAdapter.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/ui/TileImageViewAdapter.java b/src/com/android/gallery3d/ui/TileImageViewAdapter.java
index f4c6e658a..0400de6f3 100644
--- a/src/com/android/gallery3d/ui/TileImageViewAdapter.java
+++ b/src/com/android/gallery3d/ui/TileImageViewAdapter.java
@@ -100,10 +100,8 @@ public class TileImageViewAdapter implements TileImageView.Model {
}
@Override
- public synchronized Bitmap getTile(int level, int x, int y, int tileSize,
+ public Bitmap getTile(int level, int x, int y, int tileSize,
int borderSize) {
- if (mRegionDecoder == null) return null;
-
// wantRegion is the rectangle on the original image we want. askRegion
// is the rectangle on the original image that we will ask from
// mRegionDecoder. Both are in the coordinates of the original image,
@@ -115,8 +113,14 @@ public class TileImageViewAdapter implements TileImageView.Model {
wantRegion.set(x - b, y - b, x + (tileSize << level) + b,
y + (tileSize << level) + b);
- // askRegion is the intersection of wantRegion and the original image.
- askRegion.set(0, 0, mImageWidth, mImageHeight);
+ BitmapRegionDecoder regionDecoder = null;
+ synchronized (this) {
+ regionDecoder = mRegionDecoder;
+ if (regionDecoder == null) return null;
+ // askRegion is the intersection of wantRegion and the original image.
+ askRegion.set(0, 0, mImageWidth, mImageHeight);
+ }
+
Utils.assertTrue(askRegion.intersect(wantRegion));
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -127,8 +131,8 @@ public class TileImageViewAdapter implements TileImageView.Model {
Bitmap bitmap;
// In CropImage, we may call the decodeRegion() concurrently.
- synchronized (mRegionDecoder) {
- bitmap = mRegionDecoder.decodeRegion(askRegion, options);
+ synchronized (regionDecoder) {
+ bitmap = regionDecoder.decodeRegion(askRegion, options);
}
if (bitmap == null) {