Merge "Fix destroy race condition"

This commit is contained in:
John Reck
2011-09-01 13:47:50 -07:00
committed by Android (Google) Code Review

View File

@@ -1041,6 +1041,7 @@ public final class WebViewCore {
// Flag for blocking messages. This is used during DESTROY to avoid // Flag for blocking messages. This is used during DESTROY to avoid
// posting more messages to the EventHub or to WebView's event handler. // posting more messages to the EventHub or to WebView's event handler.
private boolean mBlockMessages; private boolean mBlockMessages;
private boolean mDestroying;
private int mTid; private int mTid;
private int mSavedPriority; private int mSavedPriority;
@@ -1072,12 +1073,20 @@ public final class WebViewCore {
+ " arg1=" + msg.arg1 + " arg2=" + msg.arg2 + " arg1=" + msg.arg1 + " arg2=" + msg.arg2
+ " obj=" + msg.obj); + " 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.RESUME_TIMERS
&& msg.what != EventHub.PAUSE_TIMERS) { && msg.what != EventHub.PAUSE_TIMERS
&& msg.what != EventHub.DESTROY) {
if (DebugFlags.WEB_VIEW_CORE) { if (DebugFlags.WEB_VIEW_CORE) {
Log.v(LOGTAG, "Rejecting message " + msg.what Log.v(LOGTAG, "Rejecting message " + msg.what
+ " because we are destroyed"); + " because we are being destroyed");
} }
return; return;
} }
@@ -1781,7 +1790,8 @@ public final class WebViewCore {
// or RESUME_TIMERS messages, which we must still handle as they // or RESUME_TIMERS messages, which we must still handle as they
// are per process. DESTROY will instead trigger a white list in // are per process. DESTROY will instead trigger a white list in
// mEventHub, skipping any remaining messages in the queue // mEventHub, skipping any remaining messages in the queue
mEventHub.sendMessageAtFrontOfQueue( mEventHub.mDestroying = true;
mEventHub.sendMessage(
Message.obtain(null, EventHub.DESTROY)); Message.obtain(null, EventHub.DESTROY));
mEventHub.blockMessages(); mEventHub.blockMessages();
} }