New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 771550 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug



Sign in to add a comment

<video> element not garbage collected when a source is set

Project Member Reported by felixe@chromium.org, Oct 4 2017

Issue description

Chrome Version: M-61+

What steps will reproduce the problem?
(1) Load https://jsfiddle.net/op914008/1/
(2) Press the "Setup new video element" button
(3) Repeat from (2)

What is the expected result?
When the <video> element is removed and references to it are dropped it should later be garbage collected. 

What happens instead?
The <video> element is kept alive indefinitely which after a while make Chrome run into an internal limit of ~50 open streams.

It's especially easy to see this behavior on Chrome OS when looking at open "Num active streams" in the result of 'cras_test_client --dump_s'.

Setting videoElement.src = '' fixes the issue
 
Cc: foolip@chromium.org
Components: Blink>MediaStream Blink>Media
Status: Assigned (was: Untriaged)
I've only actually observed that the streams remain active in CRAS, the part about garbage collection not happening and the possibility of a reference loop between the stream and the video element is just speculation.
Do you see the same problem if you use srcObject instead of src and URLs?

Never mind, the jsfiddle uses srcObject.

Comment 5 by felixe@google.com, Oct 4 2017

Description: Show this description

Comment 6 by felixe@google.com, Oct 4 2017

For the records: The bug appears both when using video.src and video.srcObject consistently for setting up and tearing down the video object.

I updated the jsfiddle code to be consistent.
Cc: mlamouri@chromium.org
Components: -Blink>Media
Labels: -Pri-3 Stability-Memory Pri-1
Is this specific to streams coming from gUM?

Comment 8 by guidou@chromium.org, Oct 30 2017

I'll take a look and will get back to the Blink>Media team if it's not specific to streams coming from gUM.

Comment 9 by guidou@chromium.org, Nov 14 2017

Cc: guidou@chromium.org
Owner: orphis@chromium.org
Any update on this issue?
Patch is in review since yesterday actually! https://chromium-review.googlesource.com/c/chromium/src/+/867374
What's the current state? Is the patch ready?
Ping.
Issue 701758 has been merged into this issue.
Cc: orphis@chromium.org
Owner: guidou@chromium.org
Project Member

Comment 16 by bugdroid1@chromium.org, May 15 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fc2ee900e6e026e6c7ab0f804e64cec185959d2a

commit fc2ee900e6e026e6c7ab0f804e64cec185959d2a
Author: Guido Urdaneta <guidou@chromium.org>
Date: Tue May 15 10:10:46 2018

Correctly update the networkState on media elements playing MediaStreams

With this patch, the network state of elements playing inactive streams
is NETWORK_IDLE and the state of elements playing active streams is
NETWORK_LOADING.

Before this CL, the network state was always NETWORK_LOADING, which
prevented media elements from being garbage collected, which was a
source of JavaScript memory leaks and made it easy to reach limits in
the number of active low-level audio streams.

Drive-by: Fix the case of addition of stopped tracks to a stream.

Bug:  771550 
Change-Id: Id0d8e27fc30c9850e5ad43d7a3887c03a9415a18
Reviewed-on: https://chromium-review.googlesource.com/1057808
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558655}
[modify] https://crrev.com/fc2ee900e6e026e6c7ab0f804e64cec185959d2a/content/renderer/media/stream/webmediaplayer_ms.cc
[modify] https://crrev.com/fc2ee900e6e026e6c7ab0f804e64cec185959d2a/content/renderer/media/stream/webmediaplayer_ms.h
[add] https://crrev.com/fc2ee900e6e026e6c7ab0f804e64cec185959d2a/third_party/WebKit/LayoutTests/fast/mediastream/MediaStream-MediaElement-networkState.html
[modify] https://crrev.com/fc2ee900e6e026e6c7ab0f804e64cec185959d2a/third_party/blink/public/platform/web_media_stream.h
[modify] https://crrev.com/fc2ee900e6e026e6c7ab0f804e64cec185959d2a/third_party/blink/renderer/platform/mediastream/media_stream_descriptor.cc
[modify] https://crrev.com/fc2ee900e6e026e6c7ab0f804e64cec185959d2a/third_party/blink/renderer/platform/mediastream/media_stream_descriptor.h

Status: Fixed (was: Assigned)
[bulk-edit: disregard if N/A] Can the owner please set milestone to this bug if applicable?

Sign in to add a comment