• Henrik Boström's avatar
    RTCRtpReceiverInternal destructor traits ensuring delete on main thread. · 0ec0e885
    Henrik Boström authored
    The internal class owns AdapterRefs which have to be destructed on the
    main thread. As such, the last reference to the internal class had to
    be freed on the main thread. In flaky cases, when tasks were posted to
    the signaling thread, an operation performed and a task posted back to
    the main thread - the main thread would finish before the signaling
    thread task and the last reference to the internal class would be
    released on the signaling thread, causing DCHECK crashes at
    ~AdapterRef for being on the wrong thread.
    
    With destructor traits, if we are not already on the main thread we
    post to the main thread and delete RTCRtpReceiverInternal there.
    
    The TearDown of RTCRtpReceiverTest is updated to ensure that any pending
    tasks get a chance to execute, in case the signaling thread was not
    finished yet or else the destructor posted to the main thread does not
    get a chance to execute and the test would flakily leak.
    
    Before this CL: Flake's symptoms could be reproduced by adding a thread
    sleep at RTCRtpReceiverInternal::GetStatsOnSignalingThread. After this CL:
    Unable to repro flake.
    
    Bug: 827450
    Change-Id: Icdfdd3e22c3e86308ee7911e67eff43590fde581
    Reviewed-on: https://chromium-review.googlesource.com/1013492
    Commit-Queue: Henrik Boström <hbos@chromium.org>
    Reviewed-by: default avatarWez <wez@chromium.org>
    Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#553675}
    0ec0e885
rtc_rtp_sender.cc 16 KB