memory leak from showSoftInput |
|||||||||
Issue descriptionWhen calling showSoftInput() with a ResultReceiver object, the object is held by the Android framework and doesn't get released. The result is that WebView object does not get released even when the view gets removed. The reason behind having ResultReceiver is as follows: - OSK triggers resize of the viewport - if we scroll to the input form at the same time viewport resizes, flickering can happen - therefore, we delay scrolling until viewport resize completes Originally filed as b/27658034
,
Mar 17 2016
,
Mar 17 2016
Example fix: https://codereview.chromium.org/1809013002/
,
Mar 17 2016
BTW, this logic was originally introduced a long time ago: https://chromiumcodereview.appspot.com/10911012/ https://chromiumcodereview.appspot.com/11081003/ Actually, the rationale for delayed scrolling was completely my assumption. I just did some testing and could not find such a flickering issue. Alex, do you know why it was added 4 years ago? Do you think we can safely remove the delay logic without waiting for issue 404315?
,
Mar 17 2016
Ok, I did a bit more testing and found that scrolling logic does not work correctly when input form is at the bottom and going to be hidden by input method window. We should apply the scrolling logic only after input method window shows up on the screen. This is regardless of issue 404315. I'll try to find a way to weakreference inside ResultReceiver instead.
,
Mar 17 2016
Is this issue severe enough that we want to cherry-pick the workaround to M50? If for M51 only, we might have more options that can take advantage of ymalik@'s just landed patch https://codereview.chromium.org/1386403003/. > Ok, I did a bit more testing and found that scrolling logic does not work correctly when input form is at the bottom and going to be hidden by input method window. Right, but this is a problem we saw in Chrome. I'm not sure whether the delaying actually does anything useful for WebView, which has very different viewporting environment. It's possible we could simply strip out the logic for WebView with no ill effect.
,
Mar 17 2016
So from b/27658034, weak reference is the right solution. This looks severe enough to warrant merging back to m50 at least.
,
Mar 18 2016
Re #6, as bo said, this seems like a severe problem even though it is not a recent regression. I'll take the weak-reference approach for now, but hopefully we wouldn't need the logic in the near future.
,
Mar 18 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/fcc3fbf1652285b2a89eabd092d35d0fdf199ac2 commit fcc3fbf1652285b2a89eabd092d35d0fdf199ac2 Author: changwan <changwan@chromium.org> Date: Fri Mar 18 04:55:47 2016 Fix webview memory leak when keyboard was shown Android framework does not seem to release ResultReceiver passed in InputMethodManager#showSoftInput() after use. As a result, WebView will not be garbage collected after it's removed, if keyboard shows up on the screen once. ResultReceiver cannot be avoided since we want to scroll to the editable node only after input method window shows up. This is a fix to weak-reference CVC object (and thus WebView as well) from ResultReceiver. Unfortunately, ResultReceiver will still be leaked, but the leak can be significantly reduced. A test is added to AwContentsGarbageCollectionTest to test that references to WebView can be removed even when showSoftInput() is called before garbage collection. Also, I've manually tested that the new test can catch the memory leak issue when we strong-reference CVC. BUG= 595613 Review URL: https://codereview.chromium.org/1809013002 Cr-Commit-Position: refs/heads/master@{#381891} [modify] https://crrev.com/fcc3fbf1652285b2a89eabd092d35d0fdf199ac2/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java [modify] https://crrev.com/fcc3fbf1652285b2a89eabd092d35d0fdf199ac2/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
,
Mar 18 2016
requesting merge of #9 to m50
,
Mar 18 2016
Your change meets the bar and is auto-approved for M50 (branch: 2661)
,
Mar 18 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/03b18f07ad4cee19f59d9a494a9c7f354a2a09b6 commit 03b18f07ad4cee19f59d9a494a9c7f354a2a09b6 Author: Changwan Ryu <changwan@google.com> Date: Fri Mar 18 05:34:31 2016 Fix webview memory leak when keyboard was shown Android framework does not seem to release ResultReceiver passed in InputMethodManager#showSoftInput() after use. As a result, WebView will not be garbage collected after it's removed, if keyboard shows up on the screen once. ResultReceiver cannot be avoided since we want to scroll to the editable node only after input method window shows up. This is a fix to weak-reference CVC object (and thus WebView as well) from ResultReceiver. Unfortunately, ResultReceiver will still be leaked, but the leak can be significantly reduced. A test is added to AwContentsGarbageCollectionTest to test that references to WebView can be removed even when showSoftInput() is called before garbage collection. Also, I've manually tested that the new test can catch the memory leak issue when we strong-reference CVC. BUG= 595613 Review URL: https://codereview.chromium.org/1809013002 Cr-Commit-Position: refs/heads/master@{#381891} (cherry picked from commit fcc3fbf1652285b2a89eabd092d35d0fdf199ac2) Review URL: https://codereview.chromium.org/1810273002 . Cr-Commit-Position: refs/branch-heads/2661@{#281} Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081} [modify] https://crrev.com/03b18f07ad4cee19f59d9a494a9c7f354a2a09b6/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java [modify] https://crrev.com/03b18f07ad4cee19f59d9a494a9c7f354a2a09b6/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
,
Mar 18 2016
,
Mar 18 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/d3b30c870443e36906d97cbff96830f8570f9862 commit d3b30c870443e36906d97cbff96830f8570f9862 Author: hush <hush@chromium.org> Date: Fri Mar 18 18:23:03 2016 Suppress findbugs warning about USELESS_OBJECT. BUG= 595613 Review URL: https://codereview.chromium.org/1815143003 Cr-Commit-Position: refs/heads/master@{#382017} [modify] https://crrev.com/d3b30c870443e36906d97cbff96830f8570f9862/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsGarbageCollectionTest.java
,
Mar 28 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/fccdae63cab073c8076d42edf15c4a8424a33a2c commit fccdae63cab073c8076d42edf15c4a8424a33a2c Author: changwan <changwan@chromium.org> Date: Mon Mar 28 23:48:09 2016 Clarify ShowKeyboardResultReceiver comment in ContentViewCore Clarify the comment added at https://codereview.chromium.org/1809013002/ which is somewhat misleading since objects are not permanently leaked. BUG= 595613 Review URL: https://codereview.chromium.org/1838773002 Cr-Commit-Position: refs/heads/master@{#383612} [modify] https://crrev.com/fccdae63cab073c8076d42edf15c4a8424a33a2c/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by changwan@chromium.org
, Mar 17 2016