Commit 2c5d8300 authored by Tommy Steimel's avatar Tommy Steimel Committed by Commit Bot

[Media Controls] Prevent DCHECK when removing video acting as audio

This CL prevents the is_acting_as_audio_controls_ state from updating
during an HTMLMediaElement's removal from the document. This fixes an
issue where a DCHECK was firing on the controls inserting elements into
the panel during a removal.

Bug: 851374
Change-Id: I28a4cd31dd4e0197b8fcad8cfaa9401dbf5aea61
Reviewed-on: https://chromium-review.googlesource.com/1098306Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567689}
parent f27798f4
<!DOCTYPE html>
<html>
<title>Test that removing a video that is acting as audio does not crash</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../media-controls.js"></script>
<video controls preload=metadata>
<source src="../content/test.oga" />
</video>
<script>
async_test(t => {
const video = document.querySelector('video');
video.addEventListener('loadedmetadata', t.step_func_done(() => {
video.src=null;
video.parentNode.removeChild(video);
}));
});
</script>
</html>
......@@ -924,7 +924,13 @@ void MediaControlsImpl::Hide() {
timeline_->OnControlsHidden();
UpdateCSSClassFromState();
UpdateActingAsAudioControls();
// Hide is called when the HTMLMediaElement is removed from a document. If we
// stop acting as audio controls during this removal, we end up inserting
// nodes during the removal, firing a DCHECK. To avoid this, only update here
// when the media element is connected.
if (MediaElement().isConnected())
UpdateActingAsAudioControls();
}
bool MediaControlsImpl::IsVisible() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment