Commit 867b1034 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Prevent WebStateList crash

A prior fix early exited the observer method |didDetachWebState| if
the WebStateList is nil. We also logged a histogram to see how often
we see that WebStateList is nil. The histogram shows that the
WebStateList is never nil at that point. However, we are still seeing
these real world crashes in a free function one frame lower in the
call stack. This CL adds an early exit and histogram log to the
free function, which is where the crash has always been occurring.

Bug: 877792
Change-Id: Icd099af3e399a748fa744674cc6756cfac09cf4e
Reviewed-on: https://chromium-review.googlesource.com/c/1384791
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618319}
parent a2f290c1
......@@ -64,6 +64,14 @@ NSArray* CreateItems(WebStateList* web_state_list) {
// Returns the ID of the active tab in |web_state_list|.
NSString* GetActiveTabId(WebStateList* web_state_list) {
// TODO(crbug.com/877792) : Real-world crashes have been caused by
// |web_state_list| being nil in this function. Capture histogram to retain
// visibility of issue severity.
UMA_HISTOGRAM_BOOLEAN("IOS.TabGridMediator.GetActiveTabIDNilWebStateList",
!web_state_list);
if (!web_state_list)
return nil;
web::WebState* web_state = web_state_list->GetActiveWebState();
if (!web_state)
return nil;
......
......@@ -42973,6 +42973,21 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="IOS.TabGridMediator.GetActiveTabIDNilWebStateList"
enum="BooleanNil" expires_after="2019-05-01">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<summary>
WebStateList should be guaranteed to be non-nil during a
WebStateListObserver callback. This histogram counts the frequency of this
invariant holding when GetActiveTabID() is invoked in TabGridMediator.
Violations of this invariant is the cause of real-world crashes
(https://crbug.com/877792), which were not currently reproducible in
testing. This histogram is used to retain visibility of the severity of this
issue, while preventing the crashes with a no-op.
</summary>
</histogram>
<histogram name="IOS.TabSwitcher.PageChangeInteraction"
enum="IOSTabSwitcherPageChangeInteraction">
<owner>marq@chromium.org</owner>
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