Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b677eb6 authored by Ray Chen's avatar Ray Chen
Browse files

Fix 6208468 21 ANR(s) in: com.google.android.gallery3d on crespo during monkey runs for JRM80

b:6208468

Both getDataManager and getImageCacheService use the same lock but the latter method is blocked on
RandomAccessFile's open syscall. The lock should be separated because they're independent and
getDataManager is very frequently used too.

Change-Id: I4d44cfc949f45a31c7200c8327115bc4b7fde60f
parent add4514f
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class GalleryAppImpl extends Application implements GalleryApp {
    private static final long DOWNLOAD_CAPACITY = 64 * 1024 * 1024; // 64M

    private ImageCacheService mImageCacheService;
    private Object mLock = new Object();
    private DataManager mDataManager;
    private ThreadPool mThreadPool;
    private DownloadCache mDownloadCache;
@@ -60,12 +61,15 @@ public class GalleryAppImpl extends Application implements GalleryApp {
        return mDataManager;
    }

    public synchronized ImageCacheService getImageCacheService() {
    public ImageCacheService getImageCacheService() {
        // This method may block on file I/O so a dedicated lock is needed here.
        synchronized (mLock) {
            if (mImageCacheService == null) {
                mImageCacheService = new ImageCacheService(getAndroidContext());
            }
            return mImageCacheService;
        }
    }

    public synchronized ThreadPool getThreadPool() {
        if (mThreadPool == null) {