diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java index 11edda17a..562fdff61 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java @@ -100,6 +100,8 @@ public class ReactAppTestActivity extends FragmentActivity implements if (mReactInstanceManager != null) { mReactInstanceManager.destroy(); } + + mScreenshotingFrameLayout.clean(); } public void waitForDestroy(long timeoutMs) throws InterruptedException { @@ -129,6 +131,7 @@ public class ReactAppTestActivity extends FragmentActivity implements } mReactRootView = new ReactRootView(this); mScreenshotingFrameLayout.removeAllViews(); + mScreenshotingFrameLayout.clean(); mScreenshotingFrameLayout.addView(mReactRootView); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ScreenshotingFrameLayout.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ScreenshotingFrameLayout.java index ffc648e79..8d4da285b 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ScreenshotingFrameLayout.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ScreenshotingFrameLayout.java @@ -47,6 +47,14 @@ public class ScreenshotingFrameLayout extends FrameLayout { canvas.drawBitmap(mBitmap, 0, 0, null); } + public void clean() { + if (mBitmap != null) { + mBitmap.recycle(); + mBitmap = null; + } + mCanvas.setBitmap(null); + } + private static Bitmap createNewBitmap(Canvas canvas) { return Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); }