• Aaron Colwell's avatar
    Fix NestedMessagePumpAndroid to avoid nested calls into the looper. · 48c4d507
    Aaron Colwell authored
    This fixes flakiness in a variety of browser tests on Android caused
    by nested calls to Java_NestedSystemMessageHandler_dispatchOneMessage().
    This method calls into looper code that is not reentrant safe which
    results in crashes. This change refactors the MessagePumpUI &
    NestedMessagePumpAndroid logic so that work can be dispatched without
    the looper code on the call stack. The code detects whether work events
    are being dispatched while inside the looper and defers that work until
    the Java_NestedSystemMessageHandler_dispatchOneMessage() call returns.
    This allows us to avoid making reentrant calls into the looper while
    still allowing nested RunLoops to work properly.
    
    - Splits MessagePumpUI::OnDelayedLooperCallback() and
      MessagePumpUI::OnNonDelayedLooperCallback() into 2 pieces so the
      dispatching of work can be separated from the looper callback.
    - Added deferred work tracking logic to NestedMessagePumpAndroid so
      that it can keep track of what events occurred while the looper was
      running and dispatch work once the looper returns.
    - Added logic to save/restore the delegate and quit status so that
      quitting one Run() level does not quit all levels. This makes the
      code more consistent with other MessagePump implementations.
    - Enable tests on Android that were previously disabled because of
      flakiness caused by crashing in the looper.
    
    
    Bug: 1110497, 1129592
    Change-Id: I4cfb8804275045b6fb4ab2b0d89cdc20fdb8ea4c
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511790Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
    Reviewed-by: default avatardanakj <danakj@chromium.org>
    Commit-Queue: Aaron Colwell <acolwell@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#827283}
    48c4d507
test_support_android.cc 6.93 KB