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

Issue 581423002: [aw] Ensure that WebView APIs do not crash if called after destruction. (Closed)

Created:
6 years, 3 months ago by Ignacio Solla
Modified:
6 years, 3 months ago
Reviewers:
benm (inactive), boliu
CC:
chromium-reviews, android-webview-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

[aw] Ensure that WebView APIs do not crash if called after destruction. The documentation for WebView#destroy() reads "This method should be called after this WebView has been removed from the view system. No other methods may be called on this WebView after destroy". However, some apps do not respect that restriction so this change ensures that we fail gracefully in that case and do not crash. BUG=415666 Committed: https://crrev.com/781fc47c526db3aabbf86dfca15edaaa018fc67d Cr-Commit-Position: refs/heads/master@{#296029}

Patch Set 1 #

Patch Set 2 : Also fix APIs that do not use mContentViewCore, mWebContents or mNavigationController directly. #

Total comments: 4

Patch Set 3 : Log errors if things are / are not null when they shouldn't / should. #

Total comments: 15

Patch Set 4 : Address Bo's comments #

Patch Set 5 : Add missing file, AwcontentViewClient #

Total comments: 3

Patch Set 6 : Fix findbugs warning. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+175 lines, -101 lines) Patch
M android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java View 1 2 3 4 1 chunk +4 lines, -1 line 0 comments Download
M android_webview/java/src/org/chromium/android_webview/AwContents.java View 1 2 3 4 5 54 chunks +123 lines, -99 lines 0 comments Download
M android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java View 1 2 3 3 chunks +48 lines, -1 line 0 comments Download

Messages

Total messages: 23 (4 generated)
Ignacio Solla
benm@chromium.org: Please review changes in boliu@chromium.org: Please review changes in
6 years, 3 months ago (2014-09-19 13:23:47 UTC) #2
Ignacio Solla
benm@chromium.org: Please review changes in boliu@chromium.org: Please review changes in
6 years, 3 months ago (2014-09-19 13:23:48 UTC) #3
boliu
Also need to check where mContentViewCore/mWebContents/mNavigationController is passed into and held by other objects, either ...
6 years, 3 months ago (2014-09-19 15:47:19 UTC) #4
Ignacio Solla
On 2014/09/19 15:47:19, boliu wrote: > Also need to check where mContentViewCore/mWebContents/mNavigationController is > passed ...
6 years, 3 months ago (2014-09-19 17:26:06 UTC) #5
Ignacio Solla
https://codereview.chromium.org/581423002/diff/20001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/20001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode255 android_webview/java/src/org/chromium/android_webview/AwContents.java:255: private boolean mIsDestroyed = false; On 2014/09/19 15:47:19, boliu ...
6 years, 3 months ago (2014-09-19 17:26:20 UTC) #6
boliu
On 2014/09/19 17:26:06, Ignacio Solla wrote: > On 2014/09/19 15:47:19, boliu wrote: > > Also ...
6 years, 3 months ago (2014-09-19 17:33:40 UTC) #7
Ignacio Solla
On 2014/09/19 17:33:40, boliu wrote: > On 2014/09/19 17:26:06, Ignacio Solla wrote: > > On ...
6 years, 3 months ago (2014-09-22 11:24:04 UTC) #8
Ignacio Solla
https://codereview.chromium.org/581423002/diff/20001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/20001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode255 android_webview/java/src/org/chromium/android_webview/AwContents.java:255: private boolean mIsDestroyed = false; On 2014/09/19 17:33:39, boliu ...
6 years, 3 months ago (2014-09-22 11:24:54 UTC) #9
boliu
https://codereview.chromium.org/581423002/diff/40001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/40001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode645 android_webview/java/src/org/chromium/android_webview/AwContents.java:645: View enterFullScreen() { I think we need to check ...
6 years, 3 months ago (2014-09-22 16:23:14 UTC) #10
Ignacio Solla
https://codereview.chromium.org/581423002/diff/40001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/40001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode645 android_webview/java/src/org/chromium/android_webview/AwContents.java:645: View enterFullScreen() { On 2014/09/22 16:23:13, boliu wrote: > ...
6 years, 3 months ago (2014-09-22 17:04:17 UTC) #11
boliu
lgtm https://codereview.chromium.org/581423002/diff/40001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/40001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode900 android_webview/java/src/org/chromium/android_webview/AwContents.java:900: private boolean isDestroyed() { On 2014/09/22 17:04:16, Ignacio ...
6 years, 3 months ago (2014-09-22 17:08:28 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/581423002/80001
6 years, 3 months ago (2014-09-22 17:10:53 UTC) #14
commit-bot: I haz the power
Try jobs failed on following builders: android_clang_dbg_recipe on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_clang_dbg_recipe/builds/6031)
6 years, 3 months ago (2014-09-22 18:09:54 UTC) #16
boliu
https://codereview.chromium.org/581423002/diff/80001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/80001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode1939 android_webview/java/src/org/chromium/android_webview/AwContents.java:1939: return isDestroyed() ? null : mContentViewCore.supportsAccessibilityAction(action); Woh, findbugs is ...
6 years, 3 months ago (2014-09-22 18:20:09 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/581423002/100001
6 years, 3 months ago (2014-09-22 18:35:57 UTC) #19
Ignacio Solla
https://codereview.chromium.org/581423002/diff/80001/android_webview/java/src/org/chromium/android_webview/AwContents.java File android_webview/java/src/org/chromium/android_webview/AwContents.java (right): https://codereview.chromium.org/581423002/diff/80001/android_webview/java/src/org/chromium/android_webview/AwContents.java#newcode1939 android_webview/java/src/org/chromium/android_webview/AwContents.java:1939: return isDestroyed() ? null : mContentViewCore.supportsAccessibilityAction(action); On 2014/09/22 18:20:09, ...
6 years, 3 months ago (2014-09-22 18:38:39 UTC) #20
commit-bot: I haz the power
Committed patchset #6 (id:100001) as b7afbe833a264b25fca1464a2481d7da1fa6a380
6 years, 3 months ago (2014-09-22 19:57:20 UTC) #21
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/781fc47c526db3aabbf86dfca15edaaa018fc67d Cr-Commit-Position: refs/heads/master@{#296029}
6 years, 3 months ago (2014-09-22 19:57:59 UTC) #22
boliu
6 years, 3 months ago (2014-09-22 20:00:23 UTC) #23
Message was sent while issue was closed.
https://codereview.chromium.org/581423002/diff/80001/android_webview/java/src...
File android_webview/java/src/org/chromium/android_webview/AwContents.java
(right):

https://codereview.chromium.org/581423002/diff/80001/android_webview/java/src...
android_webview/java/src/org/chromium/android_webview/AwContents.java:1939:
return isDestroyed() ? null :
mContentViewCore.supportsAccessibilityAction(action);
On 2014/09/22 18:38:39, Ignacio Solla wrote:
> On 2014/09/22 18:20:09, boliu wrote:
> > Woh, findbugs is useful sometimes :) This should be false rather than null.
> > 
> > What exactly did this compile to?! Did it compile to 
> > 
> > (isDestroyed() ? null :
mContentViewCore).supportsAccessibilityAction(action);
> > 
> > That's kinda scary...
> 
> I'm surprised it compiles, it is scary. This is a good reason to always write
> "condition ? exp : null" instead of "condition ? null : exp". I will always
use
> the first form from now on.

Credit goes to newt who spotted this first.

So the ternary expression is obtained from the two terms (null, and boolean)
with the expected type (boolean). And one type actually works, ie the Boolean
class that's auto boxed/unboxed.

That's why findbugs is complainig about null, because it's trying to unbox null
as a Boolean.

Powered by Google App Engine
This is Rietveld 408576698