<?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>61742</bug_id>
          
          <creation_ts>2011-05-30 11:32:31 -0700</creation_ts>
          <short_desc>[chromium] Give WebVideoFrame a virtual destructor</short_desc>
          <delta_ts>2011-06-13 14:47:47 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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="Nico Weber">thakis</reporter>
          <assigned_to name="Nico Weber">thakis</assigned_to>
          <cc>akalin</cc>
    
    <cc>commit-queue</cc>
    
    <cc>fishd</cc>
    
    <cc>hclam</cc>
    
    <cc>scherkus</cc>
    
    <cc>vrk</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>412306</commentid>
    <comment_count>0</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-05-30 11:32:31 -0700</bug_when>
    <thetext>[chromium] Give WebVideoFrame a virtual destructor</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>412308</commentid>
    <comment_count>1</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-05-30 11:33:01 -0700</bug_when>
    <thetext>*** Bug 61741 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>412309</commentid>
    <comment_count>2</comment_count>
      <attachid>95358</attachid>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-05-30 11:34:51 -0700</bug_when>
    <thetext>Created attachment 95358
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>412310</commentid>
    <comment_count>3</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-05-30 11:35:14 -0700</bug_when>
    <thetext>See also http://code.google.com/p/chromium/issues/detail?id=84424</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>412978</commentid>
    <comment_count>4</comment_count>
      <attachid>95358</attachid>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2011-05-31 16:33:00 -0700</bug_when>
    <thetext>Comment on attachment 95358
Patch

The comments in WebMediaPlayer.h say:

    // This function returns a pointer to a WebVideoFrame, which is
    // a WebKit wrapper for a video frame in chromium. This places a lock
    // on the frame in chromium, and calls to this method should always be
    // followed with a call to putCurrentFrame(). The ownership of this object
    // is not transferred to the caller, and the caller should not free the
    // returned object.
    virtual WebVideoFrame* getCurrentFrame() { return 0; }

That tells me that WebVideoFrame should actually have a protected destructor.
It seems like the Chromium code is violating the API contract in other words.

Or, the comment is wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>412992</commentid>
    <comment_count>5</comment_count>
    <who name="Victoria Kirst">vrk</who>
    <bug_when>2011-05-31 16:51:03 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (From update of attachment 95358 [details])
&gt; The comments in WebMediaPlayer.h say:
&gt; 
&gt;     // This function returns a pointer to a WebVideoFrame, which is
&gt;     // a WebKit wrapper for a video frame in chromium. This places a lock
&gt;     // on the frame in chromium, and calls to this method should always be
&gt;     // followed with a call to putCurrentFrame(). The ownership of this object
&gt;     // is not transferred to the caller, and the caller should not free the
&gt;     // returned object.
&gt;     virtual WebVideoFrame* getCurrentFrame() { return 0; }
&gt; 
&gt; That tells me that WebVideoFrame should actually have a protected destructor.
&gt; It seems like the Chromium code is violating the API contract in other words.
&gt; 
&gt; Or, the comment is wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>412995</commentid>
    <comment_count>6</comment_count>
    <who name="Victoria Kirst">vrk</who>
    <bug_when>2011-05-31 16:56:34 -0700</bug_when>
    <thetext>Whoops didn&apos;t mean to submit last comment! Sorry for spam.

As far as I can tell, darin is right and the comment in WebVideoFrame is right, so yes, the WebVideoFrame destructor should be protected. I think we could change webkit/glue/webmediaplayer_impl.cc to have a scoped_refptr&lt;WebVideoFrame&gt; current_frame_ field that gets set/reset every call to getCurrentFrame() and putCurrentFrame().

@scherkus/hclam thoughts?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>413001</commentid>
    <comment_count>7</comment_count>
    <who name="Andrew Scherkus">scherkus</who>
    <bug_when>2011-05-31 17:03:15 -0700</bug_when>
    <thetext>What&apos;s the bug we&apos;re fixing?

In any case a protected destructor sounds OK to me + scoped_ptr&lt;WebVideoFrameImpl&gt; inside webmediaplayer_impl.cc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>413089</commentid>
    <comment_count>8</comment_count>
      <attachid>95358</attachid>
    <who name="James Robinson">jamesr</who>
    <bug_when>2011-05-31 19:36:35 -0700</bug_when>
    <thetext>Comment on attachment 95358
Patch

Err sorry, missed the discussion.  This shouldn&apos;t be public.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>414176</commentid>
    <comment_count>9</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-06-02 09:09:27 -0700</bug_when>
    <thetext>&gt; That tells me that WebVideoFrame should actually have a protected destructor.

fishd, can you comment on http://codereview.chromium.org/7094005/ ? The protected non-virtual destructor pattern is technically only correct if implementing classes are marked as final, but folks on that review feel that that&apos;s too complicated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>414970</commentid>
    <comment_count>10</comment_count>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2011-06-03 10:01:45 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; &gt; That tells me that WebVideoFrame should actually have a protected destructor.
&gt; 
&gt; fishd, can you comment on http://codereview.chromium.org/7094005/ ? The protected non-virtual destructor pattern is technically only correct if implementing classes are marked as final, but folks on that review feel that that&apos;s too complicated.

Note:  The issue of whether or not this destructor should be virtual or non-virtual is not the main issue in _this_ bug.  The main issue here is that no one should be deleting a WebVideoFrame pointer.  We can enforce that by giving WebVideoFrame a protected destructor.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415134</commentid>
    <comment_count>11</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-06-03 13:33:57 -0700</bug_when>
    <thetext>fishd, vrk, scherkus: Making the destructor protected is not trivial. Here&apos;s the method where the delete happens ( http://google.com/codesearch/p?hl=en#hfE6470xZHk/webkit/glue/webmediaplayer_impl.cc&amp;q=webmediaplayerimpl&amp;d=2&amp;l=599 ):

void WebMediaPlayerImpl::putCurrentFrame(
    WebKit::WebVideoFrame* web_video_frame) {
  if (web_video_frame) {
    scoped_refptr&lt;media::VideoFrame&gt; video_frame =
        WebVideoFrameImpl::toVideoFrame(web_video_frame);
    proxy_-&gt;PutCurrentFrame(video_frame);
    delete web_video_frame;  // &lt;- XXX HERE XXX
  }
}

Since this overrides a method of WebMediaPlayer with the following interface ( http://codesearch.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h&amp;q=webmediaplayer.h&amp;exact_package=chromium&amp;sa=N&amp;cd=1&amp;ct=rc )

    virtual void putCurrentFrame(WebVideoFrame*) { }

the argument type must be WebVideoFrame, not WebVideoFrameImpl. WebMediaPlayerImpl could do a static_cast to WebVideoFrameImpl, but that seems worse than to just make this destructor virtual.

Let me know what you want me to do here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415193</commentid>
    <comment_count>12</comment_count>
      <attachid>95358</attachid>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-06-03 14:12:03 -0700</bug_when>
    <thetext>Comment on attachment 95358
Patch

(see my last comment)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415344</commentid>
    <comment_count>13</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-06-03 18:09:46 -0700</bug_when>
    <thetext>vrk, scherkus: Ping. This CL as is fixes a real bug, and unblocks me from rolling clang. If you want me to do something else, please tell me what.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415346</commentid>
    <comment_count>14</comment_count>
    <who name="">akalin</who>
    <bug_when>2011-06-03 18:14:12 -0700</bug_when>
    <thetext>Chatted with scherkus, he doesn&apos;t really care how it is fixed.  He&apos;s okay with a virtual base class destructor.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415349</commentid>
    <comment_count>15</comment_count>
    <who name="Andrew Scherkus">scherkus</who>
    <bug_when>2011-06-03 18:30:17 -0700</bug_when>
    <thetext>Yup I don&apos;t really care.

Code will likely change at some point anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415867</commentid>
    <comment_count>16</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-06-06 09:46:54 -0700</bug_when>
    <thetext>The commit-queue encountered the following flaky tests while processing attachment 95358:

http/tests/websocket/tests/error-detect.html bug 54012 (author: abarth@webkit.org)
The commit-queue is continuing to process your patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415868</commentid>
    <comment_count>17</comment_count>
      <attachid>95358</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-06-06 09:48:23 -0700</bug_when>
    <thetext>Comment on attachment 95358
Patch

Clearing flags on attachment: 95358

Committed r88170: &lt;http://trac.webkit.org/changeset/88170&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>415869</commentid>
    <comment_count>18</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2011-06-06 09:48:29 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>417679</commentid>
    <comment_count>19</comment_count>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2011-06-08 16:37:22 -0700</bug_when>
    <thetext>You guys forgot to update the comments in WebMediaPlayer.h!  (See comment #4.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>417684</commentid>
    <comment_count>20</comment_count>
    <who name="Nico Weber">thakis</who>
    <bug_when>2011-06-08 16:41:23 -0700</bug_when>
    <thetext>scherkus, vrk: Can you update the comment? I don&apos;t know what&apos;s correct there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>419892</commentid>
    <comment_count>21</comment_count>
    <who name="Andrew Scherkus">scherkus</who>
    <bug_when>2011-06-13 14:47:47 -0700</bug_when>
    <thetext>I&apos;ve lost some context on this (went on vacation, flushed out cache, etc..) but is there any reason why we can&apos;t have a virtual-yet-protected dtor?

the comment is correct but the code in chromium is a bit kludgy:

void WebMediaPlayerImpl::putCurrentFrame(
    WebKit::WebVideoFrame* web_video_frame) {
  if (web_video_frame) {
    scoped_refptr&lt;media::VideoFrame&gt; video_frame(
        WebVideoFrameImpl::toVideoFrame(web_video_frame));
    proxy_-&gt;PutCurrentFrame(video_frame);
    delete web_video_frame;
  }
}

...I believe a combo of that change + a static_cast&lt;WebVideoFrameImpl&gt; inside chromium land (as jamesr/fishd mentioned) be the correct course of action here so that we delete the Impl version of the pointer.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>95358</attachid>
            <date>2011-05-30 11:34:51 -0700</date>
            <delta_ts>2011-06-06 09:48:23 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-61742-20110530203448.patch</filename>
            <type>text/plain</type>
            <size>1389</size>
            <attacher name="Nico Weber">thakis</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogODc2MjcKZGlmZiAtLWdpdCBhL1NvdXJjZS9XZW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