<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>137025</bug_id>
          
          <creation_ts>2014-09-23 06:45:55 -0700</creation_ts>
          <short_desc>HTMLMediaElement::removedFrom is not clearing the player and causes lock up of video resource</short_desc>
          <delta_ts>2014-10-04 05:35:20 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="thouraya">thouraya.andolsi</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>eric.carlson</cc>
    
    <cc>jer.noble</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1036708</commentid>
    <comment_count>0</comment_count>
    <who name="thouraya">thouraya.andolsi</who>
    <bug_when>2014-09-23 06:45:55 -0700</bug_when>
    <thetext>Hi,

Calling HTMLMediaElement::removedFrom() function in
&quot;Source/WebCore/html/HTMLMediaElement.cpp&quot; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1036988</commentid>
    <comment_count>1</comment_count>
    <who name="Eric Carlson">eric.carlson</who>
    <bug_when>2014-09-24 10:45:51 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; Hi,
&gt; 
&gt; Calling HTMLMediaElement::removedFrom() function in
&gt; &quot;Source/WebCore/html/HTMLMediaElement.cpp&quot; file will only pause the video.
&gt; 
&gt; But this leads to lock up of video resource when we are playing video in Hardware mode.
&gt; We should explicitly call m_player.clear() to clear the mediaplayer as follows.
&gt; 
&gt; diff --git a/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp b/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp
&gt; index 314a85d..1e706f1 100644
&gt; --- a/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp
&gt; +++ b/qtwebkit/Source/WebCore/html/HTMLMediaElement.cpp
&gt; @@ -540,6 +540,7 @@ void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint)
&gt;              pause();
&gt;          if (m_isFullscreen)
&gt;              exitFullscreen();
&gt; +        m_player.clear();
&gt;      }
&gt; 
&gt;      HTMLElement::removedFrom(insertionPoint);
&gt; 
&gt; Is this the right way to do it?
&gt; otherwise, how to fix the issue?
&gt; 

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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1038557</commentid>
    <comment_count>2</comment_count>
    <who name="thouraya">thouraya.andolsi</who>
    <bug_when>2014-10-01 08:59:55 -0700</bug_when>
    <thetext>Hi Eric,

&gt; 
&gt; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1038564</commentid>
    <comment_count>3</comment_count>
    <who name="Eric Carlson">eric.carlson</who>
    <bug_when>2014-10-01 09:14:39 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; 
&gt; Do you have any suggestion how to fix the issue?
&gt; 

What exactly is the situation in which you want a media element to release its hardware resources?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1038813</commentid>
    <comment_count>4</comment_count>
    <who name="thouraya">thouraya.andolsi</who>
    <bug_when>2014-10-02 01:39:02 -0700</bug_when>
    <thetext>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)
&gt; (In reply to comment #2)
&gt; &gt; 
&gt; &gt; Do you have any suggestion how to fix the issue?
&gt; &gt; 
&gt; 
&gt; What exactly is the situation in which you want a media element to release its hardware resources?

Regards,
Thouraya.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1038859</commentid>
    <comment_count>5</comment_count>
    <who name="Eric Carlson">eric.carlson</who>
    <bug_when>2014-10-02 07:27:24 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; 
&gt; We are running an application that plays a list of videos.
&gt; 
&gt; 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.
&gt; 
&gt; The application is written in JavaScript.
&gt; 
&gt; To stop playing a video and start playing a new one, the application is calling 
&gt; removedFrom function.
&gt; 
&gt; 
So the problem is that the element is not being garbage collected before the next one is set up. You can&apos;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=&quot;&quot;, you will also need to call video.load(). 

Do this before removing the &lt;video&gt; element from the DOM and the media player will be cleared before you create the new one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1038868</commentid>
    <comment_count>6</comment_count>
    <who name="thouraya">thouraya.andolsi</who>
    <bug_when>2014-10-02 08:35:17 -0700</bug_when>
    <thetext>Hi Eric,


&gt; &gt; 
&gt; So the problem is that the element is not being garbage collected before the next one is set up. You can&apos;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=&quot;&quot;, you will also need to call video.load(). 
&gt; 
&gt; Do this before removing the &lt;video&gt; element from the DOM and the media player will be cleared before you create the new one.

thank you for the answer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1039162</commentid>
    <comment_count>7</comment_count>
    <who name="thouraya">thouraya.andolsi</who>
    <bug_when>2014-10-03 01:35:02 -0700</bug_when>
    <thetext>Hi,

(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; 
&gt; &gt; We are running an application that plays a list of videos.
&gt; &gt; 
&gt; &gt; 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.
&gt; &gt; 
&gt; &gt; The application is written in JavaScript.
&gt; &gt; 
&gt; &gt; To stop playing a video and start playing a new one, the application is calling 
&gt; &gt; removedFrom function.
&gt; &gt; 
&gt; &gt; 
&gt; So the problem is that the element is not being garbage collected before the next one is set up. You can&apos;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=&quot;&quot;, you will also need to call video.load(). 
&gt; 
&gt; Do this before removing the &lt;video&gt; 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&apos;t be a solution for the issue?


Regards,
Thouraya.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1039499</commentid>
    <comment_count>8</comment_count>
    <who name="Eric Carlson">eric.carlson</who>
    <bug_when>2014-10-04 05:35:20 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Calling the stop() function in HTMLMediaElement::removedFrom() instead of pause() couldn&apos;t be a solution for the issue?
&gt; 

No, see comment #1.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>