From f1069d5dd46990f07cda7dddfa818f360e01bba8 Mon Sep 17 00:00:00 2001 From: Kedi Xu Date: Mon, 26 Sep 2016 19:53:51 +0800 Subject: SnapdragonGallery: Fix PhotoView leak Fast entry and exit PhotoPage, will lead to OOM. Change-Id: I1f43ce224d4bbe6e49b49b3affeaffae7a9722e2 CRs-Fixed: 1070587 --- src/com/android/gallery3d/app/PhotoPage.java | 3 ++- src/com/android/gallery3d/filtershow/FilterShowActivity.java | 1 + src/com/android/gallery3d/filtershow/filters/ImageFilter.java | 7 +++---- src/com/android/gallery3d/ui/EdgeView.java | 4 ++++ src/com/android/gallery3d/ui/PhotoView.java | 5 +++++ 5 files changed, 15 insertions(+), 5 deletions(-) mode change 100644 => 100755 src/com/android/gallery3d/ui/EdgeView.java (limited to 'src') diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index e8dd13fac..cdd5742fd 100755 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -1660,7 +1660,8 @@ public abstract class PhotoPage extends ActivityState implements } mActivity.getGLRoot().setOrientationSource(null); if (mBottomControls != null) mBottomControls.cleanup(); - + mPhotoView.destroy(); + mPhotoView = null; // Remove all pending messages. mHandler.removeCallbacksAndMessages(null); super.onDestroy(); diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 452f4014c..8ada5af9b 100755 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -291,6 +291,7 @@ DialogInterface.OnDismissListener, PopupMenu.OnDismissListener{ * see this happen. */ mBoundService = null; + ImageFilter.resetStatics(); MasterImage.setMaster(null); } }; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index 4918bee86..bf3d02c12 100755 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -22,6 +22,7 @@ import android.graphics.Matrix; import android.renderscript.Allocation; import android.widget.Toast; +import com.android.gallery3d.app.GalleryAppImpl; import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils; import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.pipeline.FilterEnvironment; @@ -57,7 +58,7 @@ public abstract class ImageFilter implements Cloneable { @Override public void run() { if (sActivity != null && (!msg.equals(lastMsg) || sToast == null)) { - sToast = Toast.makeText(sActivity.getApplicationContext(), msg, duration); + sToast = Toast.makeText(GalleryAppImpl.getContext(), msg, duration); lastMsg = msg; } if (sToast != null) { @@ -69,9 +70,7 @@ public abstract class ImageFilter implements Cloneable { } void showToast(int resID, int duration) { - if (sActivity != null) { - showToast(sActivity.getResources().getString(resID), duration); - } + showToast(GalleryAppImpl.getContext().getString(resID), duration); } public void freeResources() {} diff --git a/src/com/android/gallery3d/ui/EdgeView.java b/src/com/android/gallery3d/ui/EdgeView.java old mode 100644 new mode 100755 index 051de18fa..dc648b457 --- a/src/com/android/gallery3d/ui/EdgeView.java +++ b/src/com/android/gallery3d/ui/EdgeView.java @@ -49,6 +49,10 @@ public class EdgeView extends GLView { } } + public void release () { + mEffect = null; + } + @Override protected void onLayout( boolean changeSize, int left, int top, int right, int bottom) { diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 7ee799c03..68ce55f91 100755 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -1384,6 +1384,11 @@ public class PhotoView extends GLView { hideUndoBar(); } + public void destroy() { + mEdgeView.release(); + mEdgeView = null; + } + public void resume() { mTileView.prepareTextures(); mPositionController.skipToFinalPosition(); -- cgit v1.2.3