Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1720)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java

Issue 1809013002: Fix webview memory leak when keyboard was shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java
index c865f4b043f1aed8287e65586ebacb4b3ace5c0e..07ae6c61e310421fdfad93989aea048bf03da09c 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java
@@ -4,13 +4,14 @@
package org.chromium.android_webview.test;
+import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
+
import android.content.Context;
import android.content.ContextWrapper;
+import android.os.ResultReceiver;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
-import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
-
import org.chromium.android_webview.AwContents;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.util.Feature;
@@ -60,7 +61,7 @@ public class AwContentsGarbageCollectionTest extends AwTestBase {
}
private static class GcTestDependencyFactory extends TestDependencyFactory {
- private StrongRefTestContext mContext;
+ private final StrongRefTestContext mContext;
public GcTestDependencyFactory(StrongRefTestContext context) {
mContext = context;
@@ -106,6 +107,42 @@ public class AwContentsGarbageCollectionTest extends AwTestBase {
@DisableHardwareAccelerationForTest
@SmallTest
@Feature({"AndroidWebView"})
+ public void testHoldKeyboardResultReceiver() throws Throwable {
+ gcAndCheckAllAwContentsDestroyed();
+
+ TestAwContentsClient client = new TestAwContentsClient();
+ AwTestContainerView containerViews[] = new AwTestContainerView[MAX_IDLE_INSTANCES + 1];
+ ResultReceiver resultReceivers[] = new ResultReceiver[MAX_IDLE_INSTANCES + 1];
+ for (int i = 0; i < containerViews.length; i++) {
+ final AwTestContainerView containerView = createAwTestContainerViewOnMainSync(client);
+ containerViews[i] = containerView;
+ loadUrlAsync(containerView.getAwContents(), "about:blank");
+ // When we call showSoftInput(), we pass a ResultReceiver object as a parameter.
+ // Android framework will hold the object reference until the matching
+ // ResultReceiver in InputMethodService (IME app) gets garbage-collected.
+ // WebView object wouldn't get gc'ed once OSK shows up because of this.
+ // It is difficult to show keyboard and wait until input method window shows up.
+ // Instead, we simply emulate Android's behavior by keeping strong references.
+ // See crbug.com/595613 for details.
+ resultReceivers[i] = runTestOnUiThreadAndGetResult(new Callable<ResultReceiver>() {
+ @Override
+ public ResultReceiver call() throws Exception {
+ return containerView.getContentViewCore().getNewShowKeyboardReceiver();
+ }
+ });
+ }
+
+ for (int i = 0; i < containerViews.length; i++) {
+ containerViews[i] = null;
+ }
+ containerViews = null;
+ removeAllViews();
+ gcAndCheckAllAwContentsDestroyed();
+ }
+
+ @DisableHardwareAccelerationForTest
+ @SmallTest
+ @Feature({"AndroidWebView"})
public void testReferenceFromClient() throws Throwable {
gcAndCheckAllAwContentsDestroyed();
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698