Commit 4d3e5a28 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: fix crash in Tab

ComposedBrowserControlsVisibilityDelegate (by way of ObservableSupplierImpl)
may post a task to notify the observer (the Tab in this case). If the Tab is
destroyed before the task runs, then when the task runs we get a crash as
the Tab has been destroyed (specifically mNativeTab is 0, which means the jni
call DCHECKs).

I would like a test for this, but it proved slightly tricky.

BUG=1057657
TEST=none

Change-Id: I85534c464fe11121fb9f65710fc3fb69b48b0d68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083813Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746113}
parent cfa6fd42
......@@ -492,6 +492,10 @@ public final class TabImpl extends ITab.Stub {
mNewTabCallbackProxy.destroy();
mNewTabCallbackProxy = null;
}
// ObservableSupplierImpl.addObserver() posts a task to notify the observer, ensure the
// callback isn't run after destroy() is called (otherwise we'll get crashes as the native
// tab has been deleted).
mBrowserControlsVisibility.removeObserver(mConstraintsUpdatedCallback);
hideFindInPageUiAndNotifyClient();
mFindInPageCallbackClient = null;
mNavigationController = null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment