RESOLVED INVALID137025
HTMLMediaElement::removedFrom is not clearing the player and causes lock up of video resource
https://bugs.webkit.org/show_bug.cgi?id=137025
Summary HTMLMediaElement::removedFrom is not clearing the player and causes lock up o...
thouraya
Reported 2014-09-23 06:45:55 PDT
Hi, Calling HTMLMediaElement::removedFrom() function in "Source/WebCore/html/HTMLMediaElement.cpp" file will only pause the video. But this leads to lock up of video resource when we are playing video in Hardware mode. We should explicitly call m_player.clear() to clear the mediaplayer as follows. diff --git a/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp b/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp index 314a85d..1e706f1 100644 --- a/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp +++ b/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp @@ -540,6 +540,7 @@ void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) pause(); if (m_isFullscreen) exitFullscreen(); + m_player.clear(); } HTMLElement::removedFrom(insertionPoint); Is this the right way to do it? otherwise, how to fix the issue? Regards, Thouraya.
Attachments
Eric Carlson
Comment 1 2014-09-24 10:45:51 PDT
(In reply to comment #0) > Hi, > > Calling HTMLMediaElement::removedFrom() function in > "Source/WebCore/html/HTMLMediaElement.cpp" file will only pause the video. > > But this leads to lock up of video resource when we are playing video in Hardware mode. > We should explicitly call m_player.clear() to clear the mediaplayer as follows. > > diff --git a/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp b/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp > index 314a85d..1e706f1 100644 > --- a/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp > +++ b/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp > @@ -540,6 +540,7 @@ void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) > pause(); > if (m_isFullscreen) > exitFullscreen(); > + m_player.clear(); > } > > HTMLElement::removedFrom(insertionPoint); > > Is this the right way to do it? > otherwise, how to fix the issue? > Clearing the player makes it lose all state and HTMLMediaElement::removedFrom is called when moving an element to a different place in the DOM, so I think this is not the correct way to fix this.
thouraya
Comment 2 2014-10-01 08:59:55 PDT
Hi Eric, > > Clearing the player makes it lose all state and HTMLMediaElement::removedFrom is called when moving an element to a different place in the DOM, so I think this is not the correct way to fix this. Do you have any suggestion how to fix the issue? Regards, Thouraya.
Eric Carlson
Comment 3 2014-10-01 09:14:39 PDT
(In reply to comment #2) > > Do you have any suggestion how to fix the issue? > What exactly is the situation in which you want a media element to release its hardware resources?
thouraya
Comment 4 2014-10-02 01:39:02 PDT
Hi, We are running an application that plays a list of videos. We are able to play only the first video, because we are running videos on a set-top box and we have to close the device before running a new one. The application is written in JavaScript. To stop playing a video and start playing a new one, the application is calling removedFrom function. (In reply to comment #3) > (In reply to comment #2) > > > > Do you have any suggestion how to fix the issue? > > > > What exactly is the situation in which you want a media element to release its hardware resources? Regards, Thouraya.
Eric Carlson
Comment 5 2014-10-02 07:27:24 PDT
(In reply to comment #4) > > We are running an application that plays a list of videos. > > We are able to play only the first video, because we are running videos on a set-top box and we have to close the device before running a new one. > > The application is written in JavaScript. > > To stop playing a video and start playing a new one, the application is calling > removedFrom function. > > So the problem is that the element is not being garbage collected before the next one is set up. You can't change this, but you can force the media player to be cleared by changing video.src. Note that if you set it to an empty string, eg. video.src="", you will also need to call video.load(). Do this before removing the <video> element from the DOM and the media player will be cleared before you create the new one.
thouraya
Comment 6 2014-10-02 08:35:17 PDT
Hi Eric, > > > So the problem is that the element is not being garbage collected before the next one is set up. You can't change this, but you can force the media player to be cleared by changing video.src. Note that if you set it to an empty string, eg. video.src="", you will also need to call video.load(). > > Do this before removing the <video> element from the DOM and the media player will be cleared before you create the new one. thank you for the answer.
thouraya
Comment 7 2014-10-03 01:35:02 PDT
Hi, (In reply to comment #5) > (In reply to comment #4) > > > > We are running an application that plays a list of videos. > > > > We are able to play only the first video, because we are running videos on a set-top box and we have to close the device before running a new one. > > > > The application is written in JavaScript. > > > > To stop playing a video and start playing a new one, the application is calling > > removedFrom function. > > > > > So the problem is that the element is not being garbage collected before the next one is set up. You can't change this, but you can force the media player to be cleared by changing video.src. Note that if you set it to an empty string, eg. video.src="", you will also need to call video.load(). > > Do this before removing the <video> element from the DOM and the media player will be cleared before you create the new one. Calling the stop() function in HTMLMediaElement::removedFrom() instead of pause() couldn't be a solution for the issue? Regards, Thouraya.
Eric Carlson
Comment 8 2014-10-04 05:35:20 PDT
(In reply to comment #7) > Calling the stop() function in HTMLMediaElement::removedFrom() instead of pause() couldn't be a solution for the issue? > No, see comment #1.
Note You need to log in before you can comment on or make changes to this bug.