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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>16553</bug_id>
          
          <creation_ts>2012-03-28 00:58:03 +0000</creation_ts>
          <short_desc>Consider not firing a needkey event when a potentially encrypted stream is encountered if the key is already known</short_desc>
          <delta_ts>2014-01-18 01:48:03 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>Encrypted Media Extensions</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>21855</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>24323</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="David Dorwin">ddorwin</reporter>
          <assigned_to name="David Dorwin">ddorwin</assigned_to>
          <cc>eric.carlson</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-html-media</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>steele</cc>
    
    <cc>watsonm</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>66172</commentid>
    <comment_count>0</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2012-03-28 00:58:03 +0000</bug_when>
    <thetext>From step 8 of section 5.2. Potentially Encrypted Stream Encountered in v0.1:
This could be skipped if the key has already been set, but always sending the event seems easier.


We need to decided whether this adds to many complexities for applications and is worth requiring user agents to track whether to send the event.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72007</commentid>
    <comment_count>1</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2012-08-10 02:28:37 +0000</bug_when>
    <thetext>Depending on the container, the indication that the stream may be encrypted may not include any type of key identifier that would allow the user agent to determine whether it has the key.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72926</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2012-08-28 20:56:39 +0000</bug_when>
    <thetext>Assigned to David for follow-up.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73185</commentid>
    <comment_count>3</comment_count>
    <who name="Joe Steele">steele</who>
    <bug_when>2012-09-04 16:31:35 +0000</bug_when>
    <thetext>The way I read step#5 of the createSession() method, a keymessage event will always be fired. This is going to be unnecessary overhead in cases where the key is already known, either because it was previously acquired and is still live or because it was embedded in the initData. Can we simply not fire that message if the key is already available?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73226</commentid>
    <comment_count>4</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2012-09-05 13:51:31 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; The way I read step#5 of the createSession() method, a keymessage event will
&gt; always be fired. This is going to be unnecessary overhead in cases where the
&gt; key is already known, either because it was previously acquired and is still
&gt; live or because it was embedded in the initData. Can we simply not fire that
&gt; message if the key is already available?

This is related to the algorithm in 5.2, which results in a &quot;needkey&quot; event. The &quot;keymessage&quot; event you refer to is not directly related. Since createSession() is always called by the application, the application is causing the keymessage events, which it needs in order to request a license. The application can avoid calling createSession() in response to a needkey event regardless of the outcome of this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73236</commentid>
    <comment_count>5</comment_count>
    <who name="Joe Steele">steele</who>
    <bug_when>2012-09-05 15:59:18 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; The way I read step#5 of the createSession() method, a keymessage event will
&gt; &gt; always be fired. This is going to be unnecessary overhead in cases where the
&gt; &gt; key is already known, either because it was previously acquired and is still
&gt; &gt; live or because it was embedded in the initData. Can we simply not fire that
&gt; &gt; message if the key is already available?
&gt; 
&gt; This is related to the algorithm in 5.2, which results in a &quot;needkey&quot; event.
&gt; The &quot;keymessage&quot; event you refer to is not directly related. Since
&gt; createSession() is always called by the application, the application is causing
&gt; the keymessage events, which it needs in order to request a license. The
&gt; application can avoid calling createSession() in response to a needkey event
&gt; regardless of the outcome of this bug.

Let me restate to make sure I understand. You are saying that according to 5.2 if the CDM determines that the key needed is already present, it will not cause the needkey event to be fired. Since the needkey event is not received by the media element, the app never calls createSession()?

If that is the case, then all of the aspects which are managed via MediaKeySession become problematic I think. For example - key related errors, key lifetime, adding new keys. I think I am mis-interpreting the model somehow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77486</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2012-10-31 08:01:09 +0000</bug_when>
    <thetext>Do we assume that the CDM may have licenses which are not attached to a MediaKeySession ?

For example, might a CDM retain a license after the MediaKeySession in which it was delivered is destroyed ? Perhaps some CDMs will keep licenses across page unload/reload ?

If yes, then it must be possible to obtain a new MediaKeySession associated with one of these cached licenses. That need not involve interaction with the license server.

The needkey -&gt; createSession sequence is the only way that a new MediaKeySession is created. At least in such a way that it could be associated with a pre-existing license, because that can only be done with correct initData.

So, I&apos;d conclude that needkey should always be sent, whether or not a license already exists for the content.

[I would not expect a keymessage to result from creating the session, though, but apparently there&apos;s a different bug for that]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77513</commentid>
    <comment_count>7</comment_count>
    <who name="Joe Steele">steele</who>
    <bug_when>2012-10-31 15:38:08 +0000</bug_when>
    <thetext>I agree with this 100%. And I raised the issue of whether keys/licenses are allowed to be retained in another bug. I think it is obviously a useful thing to have the capability to retain licenses across sessions, pages, and browser instantiations. 

(In reply to comment #6)
&gt; Do we assume that the CDM may have licenses which are not attached to a
&gt; MediaKeySession ?
&gt; 
&gt; For example, might a CDM retain a license after the MediaKeySession in which
&gt; it was delivered is destroyed ? Perhaps some CDMs will keep licenses across
&gt; page unload/reload ?
&gt; 
&gt; If yes, then it must be possible to obtain a new MediaKeySession associated
&gt; with one of these cached licenses. That need not involve interaction with
&gt; the license server.
&gt; 
&gt; The needkey -&gt; createSession sequence is the only way that a new
&gt; MediaKeySession is created. At least in such a way that it could be
&gt; associated with a pre-existing license, because that can only be done with
&gt; correct initData.
&gt; 
&gt; So, I&apos;d conclude that needkey should always be sent, whether or not a
&gt; license already exists for the content.
&gt; 
&gt; [I would not expect a keymessage to result from creating the session,
&gt; though, but apparently there&apos;s a different bug for that]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77630</commentid>
    <comment_count>8</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2012-11-01 00:51:49 +0000</bug_when>
    <thetext>It appears we are already doing what this bug originally suggested and have been doing it since the original draft. Step 5 of http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html#algorithms-encrypted-stream uses the &quot;cdm to determine whether the key is known&quot; and skips firing the event if the key is known.

However, it&apos;s unclear whether this is possible with all containers and what to do if initData represents more than one key. As an example of the first issue, the ISO PSSH does not necessarily identify all keys that might be obtained using it.

So, it seems we need to decide whether to remove the existing text rather than adding text as suggested by the title.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77690</commentid>
    <comment_count>9</comment_count>
    <who name="Joe Steele">steele</who>
    <bug_when>2012-11-01 17:47:44 +0000</bug_when>
    <thetext>I think removing the existing text makes sense (thus always firing needkey).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84195</commentid>
    <comment_count>10</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-03-10 05:28:23 +0000</bug_when>
    <thetext>I am also in favor of removing the existing text and always firing a needkey, relying on the application to handle duplicate Initialization Data.
 
One of the most important reasons is that there is no guarantee that the user agent can determine whether all the keys associated with the Initialization Data have already been received. For example, there is no guarantee that the CENC PSSH lists all key IDs it represents.

One thing the user agent could do is avoid sending duplicate needkey events for the same Initialization Data. For example, if the PSSH is exactly the same for audio and video or for two video streams in adaptive streaming. A single bit difference, would nullify this, though, so it might be best to leave to the application/server.


I think the main question is how much burden is it on an application to compare (and possibly track) Initialization Data to avoid calling createSession() multiple times for the same data? Also, is the common logic that each application might need to include worth complicating the user agents and possibly restricting use cases?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86701</commentid>
    <comment_count>11</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-04-24 18:00:06 +0000</bug_when>
    <thetext>This was discussed at the March 12 telecon, but we did not reach a conclusion. There was a good discussion of the various issues, which can be referenced at http://www.w3.org/2013/03/12-html-media-minutes.html#item05

It seems that the core issue is avoiding the creation of duplicate sessions and unnecessary network transactions that may occur as a result of the needkey event. The specific issue of whether to fire a needkey event may be a detail of the larger solution. Bug 19208 is related to this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86895</commentid>
    <comment_count>12</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-04-26 21:37:42 +0000</bug_when>
    <thetext>We will address the general issue in bug 21855.

*** This bug has been marked as a duplicate of bug 21855 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95783</commentid>
    <comment_count>13</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-11-05 01:44:40 +0000</bug_when>
    <thetext>(In reply to David Dorwin from comment #8)
&gt; It appears we are already doing what this bug originally suggested and have
&gt; been doing it since the original draft. Step 5 of
&gt; http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-
&gt; media.html#algorithms-encrypted-stream uses the &quot;cdm to determine whether
&gt; the key is known&quot; and skips firing the event if the key is known.
&gt; 
...
&gt; So, it seems we need to decide whether to remove the existing text rather
&gt; than adding text as suggested by the title.

I removed this text in https://dvcs.w3.org/hg/html-media/rev/84be32b27d5d as discussed in this bug and consistent with the decision in bug 21855.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>