diff options
| author | John Reck <jreck@google.com> | 2011-09-01 11:45:35 -0700 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2011-09-01 11:50:19 -0700 |
| commit | 45576fae46bae16bbd703b26f8cd99457a4ca138 (patch) | |
| tree | 487efe987751ccaf8ebede299b9ae65b721ce4c0 /core/java/android | |
| parent | 6c859576ad5ae5e870e3e96b650f015024b6c49e (diff) | |
Fix destroy race condition
Bug: 5246901
Change-Id: I97a211b23afb17314d7a37779593556529be7e32
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 3ca3eaad3c1c..9aef547d8efd 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -1040,6 +1040,7 @@ public final class WebViewCore { // Flag for blocking messages. This is used during DESTROY to avoid // posting more messages to the EventHub or to WebView's event handler. private boolean mBlockMessages; + private boolean mDestroying; private int mTid; private int mSavedPriority; @@ -1071,12 +1072,20 @@ public final class WebViewCore { + " arg1=" + msg.arg1 + " arg2=" + msg.arg2 + " obj=" + msg.obj); } - if (mWebView == null + if (mWebView == null || mNativeClass == 0) { + if (DebugFlags.WEB_VIEW_CORE) { + Log.w(LOGTAG, "Rejecting message " + msg.what + + " because we are destroyed"); + } + return; + } + if (mDestroying == true && msg.what != EventHub.RESUME_TIMERS - && msg.what != EventHub.PAUSE_TIMERS) { + && msg.what != EventHub.PAUSE_TIMERS + && msg.what != EventHub.DESTROY) { if (DebugFlags.WEB_VIEW_CORE) { Log.v(LOGTAG, "Rejecting message " + msg.what - + " because we are destroyed"); + + " because we are being destroyed"); } return; } @@ -1780,7 +1789,8 @@ public final class WebViewCore { // or RESUME_TIMERS messages, which we must still handle as they // are per process. DESTROY will instead trigger a white list in // mEventHub, skipping any remaining messages in the queue - mEventHub.sendMessageAtFrontOfQueue( + mEventHub.mDestroying = true; + mEventHub.sendMessage( Message.obtain(null, EventHub.DESTROY)); mEventHub.blockMessages(); } |
