• Jun Mukai's avatar
    Don't check mismatches in content::responsiveness::Watcher · 2c73c7f3
    Jun Mukai authored
    content::responsiveness::Watcher can cause crashes of DCHECK
    for checking mismatched events when tab-dragging is involved.
    
    This is happening because Watcher watches both MessageLoopUI
    and WindowEventDispatcher (through NativeEventObserver), but
    OnWindowEventDispatcherFinishedProcessingEvent can be called
    unexpectedly. When the dragged tab is attached to another
    window, it means its WindowTreeHost and WindowEventDispatcher
    is destructed, which causes FinishedProcessingEvent in a way
    that Watcher thinks unmatched. More specifically:
    . MessageLoopUI processes an event, Watcher::WillRunTaskOnUIThread
       is called.
    2. WindowEventDispatcher::OnWindowEventDispatcherStartedProcessing
    3. the event is to start dragging, creates a nested message loop.
    4. MessageLoopUI processes another event, Watcher::WillRunTaskOnUIThread
    5. if this causes attaching of the dragged tab, it closes the
       dragged browser window
    6. close causes WindowEventDispatcher::OnWindowEventDispatcherFinishedProcessing
       on remaining events (for 2., in this case)
    7. On Watcher::DidRunEventOnUIThread, it receives the identifier
       from 6 (i.e. the event for 2), but the last metadata_ui is
       from 4 (i.e. the task of messageloopUI), so mismatch happens
    
    Absolutely the problem is the timing for 6, but it can happen
    on other scenarios. This CL simply ignore mismatches on ChromeOS
    with WindowService, and clears currently_running_metadata_ui_.
    This will lose some data points for a short period of time, but
    that can be acceptable for now.
    
    Bug: 929813
    Test: manually
    Change-Id: I5f98d084bcbf7674ed62e790ccfbb804cd9cd3e7
    Reviewed-on: https://chromium-review.googlesource.com/c/1474688Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
    Commit-Queue: Jun Mukai <mukai@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#632748}
    2c73c7f3
watcher.cc 10.6 KB