WebView should catch android.view.WindowManager$BadTokenException in default JS dialog implementation |
||
Issue descriptionWhen the default JS dialog implementation in WebView is called, it should wrap the framework calls that show the dialog in a try-catch block to catch android.view.WindowManager$BadTokenException. This exception can happen if the Activity associated with the webview has already had its window closed, but the GC has not yet run to collect the Activity and WebView instances so the JS engine is still "live" (in any app which doesn't explicitly call destroy() on the WebView in Activity.onDestroy). We should at most just log a single-line warning saying that a dialog would have been shown but the parent window is already destroyed in this case. See internal bug b/68394200 for one example of where this can happen in the captive portal login activity on android. Ideally apps should explicitly destroy the WebView to avoid this case being possible, but we know that many apps do not and we generally try to make this work as well as possible. This won't solve the issue for any apps which override the JS dialog callbacks and implement it themselves, but that's probably fine (it's their own bug in that case).
,
Nov 30 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/eb767ea45759a15d2fd7e38739afbdbcfc970256 commit eb767ea45759a15d2fd7e38739afbdbcfc970256 Author: Tobias Sargeant <tobiasjs@google.com> Date: Thu Nov 30 16:23:41 2017 Squash JS dialog exceptions caused by the WebView outliving its Activity. Bug: 789977 Change-Id: Ic262f45d2617d426b52666e67edaa783a1a603ab Reviewed-on: https://chromium-review.googlesource.com/800850 Reviewed-by: Richard Coles <torne@chromium.org> Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org> Cr-Commit-Position: refs/heads/master@{#520566} [modify] https://crrev.com/eb767ea45759a15d2fd7e38739afbdbcfc970256/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
,
Nov 30 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by tobiasjs@chromium.org
, Nov 30 2017Status: Assigned (was: Available)