The issue is visible when reconfiguring the screen arrangement while sharing the displays. Can sometimes be seen right after starting the screen sharing. Indeed CaptureFrame can be called at any time so TakeLatestFrameForDisplay should always return a valid frame and the call should not empty the internal container. Also add missing teardown in the provider on failure case. Bug: webrtc:8652 Change-Id: Ice151c1da92b9ad2b86ca9368d30d9d21114e53e Reviewed-on: https://webrtc-review.googlesource.com/69420 Commit-Queue: Zijie He <zijiehe@chromium.org> Reviewed-by: Zijie He <zijiehe@chromium.org> Cr-Commit-Position: refs/heads/master@{#22846}