<?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>168404</bug_id>
          
          <creation_ts>2017-02-15 19:48:27 -0800</creation_ts>
          <short_desc>REGRESSION (r212311): NULL-dereference in HTMLMediaElement::prepareToPlay()</short_desc>
          <delta_ts>2017-02-21 17:39:14 -0800</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>WebKit 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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jer Noble">jer.noble</reporter>
          <assigned_to name="Jer Noble">jer.noble</assigned_to>
          <cc>ap</cc>
    
    <cc>bweinstein</cc>
    
    <cc>commit-queue</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1277462</commentid>
    <comment_count>0</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-15 19:48:27 -0800</bug_when>
    <thetext>REGRESSION (r212311): NULL-dereference in HTMLMediaElement::prepareToPlay()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1277463</commentid>
    <comment_count>1</comment_count>
      <attachid>301691</attachid>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-15 19:52:52 -0800</bug_when>
    <thetext>Created attachment 301691
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1277464</commentid>
    <comment_count>2</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-15 19:53:20 -0800</bug_when>
    <thetext>rdar://problem/30547188</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1277467</commentid>
    <comment_count>3</comment_count>
      <attachid>301691</attachid>
    <who name="Brian Weinstein">bweinstein</who>
    <bug_when>2017-02-15 19:59:03 -0800</bug_when>
    <thetext>Comment on attachment 301691
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301691&amp;action=review

&gt; Source/WebCore/ChangeLog:10
&gt; +        prepareToPlay().  r212311 began calling prepareToPlay() on a subsequent run-loop iteration

Extra space between sentences.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1277468</commentid>
    <comment_count>4</comment_count>
      <attachid>301691</attachid>
    <who name="Brian Weinstein">bweinstein</who>
    <bug_when>2017-02-15 19:59:25 -0800</bug_when>
    <thetext>Comment on attachment 301691
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301691&amp;action=review

&gt;&gt; Source/WebCore/ChangeLog:10
&gt;&gt; +        prepareToPlay().  r212311 began calling prepareToPlay() on a subsequent run-loop iteration
&gt; 
&gt; Extra space between sentences.

Extra space between sentences.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1277481</commentid>
    <comment_count>5</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-15 20:27:13 -0800</bug_when>
    <thetext>Committed r212420: &lt;http://trac.webkit.org/changeset/212420&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1278116</commentid>
    <comment_count>6</comment_count>
      <attachid>301691</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-02-16 21:43:28 -0800</bug_when>
    <thetext>Comment on attachment 301691
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301691&amp;action=review

&gt; Source/WebCore/html/HTMLMediaElement.cpp:2562
&gt;      m_havePreparedToPlay = true;
&gt; -    m_player-&gt;prepareToPlay();
&gt; +    if (m_player)
&gt; +        m_player-&gt;prepareToPlay();

Shouldn&apos;t setting m_havePreparedToPlay be inside the &quot;if&quot; too?

This looks like it fixes the crash, but keeps the incorrect behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1278119</commentid>
    <comment_count>7</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-16 22:03:52 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; Comment on attachment 301691 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=301691&amp;action=review
&gt; 
&gt; &gt; Source/WebCore/html/HTMLMediaElement.cpp:2562
&gt; &gt;      m_havePreparedToPlay = true;
&gt; &gt; -    m_player-&gt;prepareToPlay();
&gt; &gt; +    if (m_player)
&gt; &gt; +        m_player-&gt;prepareToPlay();
&gt; 
&gt; Shouldn&apos;t setting m_havePreparedToPlay be inside the &quot;if&quot; too?
&gt; 
&gt; This looks like it fixes the crash, but keeps the incorrect behavior.

No. The behavior is correct. If m_havePreparedToPlay is set, we will call m_player-&gt;prepareToPlay() next time the MediaPlayer is created.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1278123</commentid>
    <comment_count>8</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-16 22:10:40 -0800</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #6)
&gt; &gt; Comment on attachment 301691 [details]
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; View in context:
&gt; &gt; https://bugs.webkit.org/attachment.cgi?id=301691&amp;action=review
&gt; &gt; 
&gt; &gt; &gt; Source/WebCore/html/HTMLMediaElement.cpp:2562
&gt; &gt; &gt;      m_havePreparedToPlay = true;
&gt; &gt; &gt; -    m_player-&gt;prepareToPlay();
&gt; &gt; &gt; +    if (m_player)
&gt; &gt; &gt; +        m_player-&gt;prepareToPlay();
&gt; &gt; 
&gt; &gt; Shouldn&apos;t setting m_havePreparedToPlay be inside the &quot;if&quot; too?
&gt; &gt; 
&gt; &gt; This looks like it fixes the crash, but keeps the incorrect behavior.
&gt; 
&gt; No. The behavior is correct. If m_havePreparedToPlay is set, we will call
&gt; m_player-&gt;prepareToPlay() next time the MediaPlayer is created.

Double-checking; it&apos;s actually the opposite. m_havePreparedToPlay is cleared whenever a MediaPlayer is created. Same deal though: the behavior is exactly the same whether setting m_havePreparedToPlay is inside the null check our outside.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1278124</commentid>
    <comment_count>9</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-02-16 22:15:47 -0800</bug_when>
    <thetext>Hmm.

If the behaviour is correct, then the naming is not. The code says &quot;have prepared to play&quot; without doing the &quot;prepare to play&quot; now. It used to be straightforward before the fix, but now it immediately raises a red flag.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1279688</commentid>
    <comment_count>10</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-02-21 17:35:20 -0800</bug_when>
    <thetext>Is this exercised by tests?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1279691</commentid>
    <comment_count>11</comment_count>
    <who name="Jer Noble">jer.noble</who>
    <bug_when>2017-02-21 17:39:14 -0800</bug_when>
    <thetext>(In reply to comment #10)
&gt; Is this exercised by tests?

This code is hit by every autoplay test.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>301691</attachid>
            <date>2017-02-15 19:52:52 -0800</date>
            <delta_ts>2017-02-15 20:25:34 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-168404-20170215195016.patch</filename>
            <type>text/plain</type>
            <size>1595</size>
            <attacher name="Jer Noble">jer.noble</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjog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id="323475"
          type_id="1"
          status="+"
          setter="bweinstein"
    />
          </attachment>
      

    </bug>

</bugzilla>