Fix and instrument Mac crash in TabSwitchTimeRecorder.
Crash reports indicate that TabSwitchTimeRecorder::RecordHistogramsAndTraceEvents is occasionnally called with |tab_switch_start_state_| being nullopt. However: - TabWasShown() sets |tab_switch_start_state_| and issues a RecordHistogramsAndTraceEvents() callback. - RecordHistogramsAndTraceEvents() expects |tab_switch_start_state_| to be set, and resets it before returning. - TabWasHidden() invokes RecordHistogramsAndTraceEvents() directly and invalidates previous callbacks issued by TabWasShown(). For the crash to happen, there must be multiple calls to TabWasShown() without the tab being hidden in between, which shouldn't happen. This CL makes the following changes: - Dump without crashing when TabWasShown() is called and |tab_switch_start_state_| is set (indicates that neither TabWasHidden() nor the RecordHistogramsAndTraceEvents() were invoked since the last call to TabWasShown()). - Invalidate previous callbacks issued by TabWasShown(), to prevent the crash from happening. A version of this CL without the call to DumpWithoutCrashing() should be merged to M76 branch before it is promoted to stable. Bug: 981757 Change-Id: Ic67c696022a73eb21c2ad48577f5e22c176f7987 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695747Reviewed-by:Jonathan Ross <jonross@chromium.org> Reviewed-by:
Antoine Labour <piman@chromium.org> Commit-Queue: François Doray <fdoray@chromium.org> Cr-Commit-Position: refs/heads/master@{#676540}
Showing
Please register or sign in to comment