<?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>23955</bug_id>
          
          <creation_ts>2013-12-02 19:04:44 +0000</creation_ts>
          <short_desc>Add optional MediaKeys.loadSession(DOMString sessionId) method</short_desc>
          <delta_ts>2014-03-25 21:51:56 +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>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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>17199</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="David Dorwin">ddorwin</reporter>
          <assigned_to name="Adrian Bateman [MSFT]">adrianba</assigned_to>
          <cc>adrianba</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-media</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>96969</commentid>
    <comment_count>0</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-12-02 19:04:44 +0000</bug_when>
    <thetext>Various use cases involving loading data from storage have been discussed. While I still think it’s best for interop (and UA implementors) to avoid this as much as possible, it’s probably better to provide a logical mechanism than to have non-standard hacks using createSession() parameters or implicit loading. It also allows the spec to guide such use cases, such as requiring that same origin be enforced. Defining something (even tentatively) will also allow us to focus discussion and explore related issues.

I propose adding an optional loadSession(DOMString sessionId) method that is a peer to createSession(). When supported, it creates a MediaKeySession object for the previously created session - specified by |sessionId| - and populates it with data from CDM storage. The new session object follows the same state transitions as other sessions, including possibly firing a message event or moving directly to READY.

Since this method is not required for most use cases, it is optional and need not be implemented by user agents or CDMs. Feature detection is simple:
* If the user agent does not support loading sessions or knows the keySystem does not, throw NOT_SUPPORTED_ERR.
* If the CDM does not support loading sessions (but the user agent did not know this above) fire an error event with NOT_SUPPORTED_ERR at the new session.

If the sessionId is not found within the current origin, fire an error event with “NotFoundError” at the new session.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97068</commentid>
    <comment_count>1</comment_count>
    <who name="Joe Steele">steele</who>
    <bug_when>2013-12-03 18:17:50 +0000</bug_when>
    <thetext>What is the workflow you are proposing for loading previously loaded keys then? Would the application have to keep track of each sessionID it has seen and then try to load them later? I am not sure how this is intended to solve the general problem of CDM data storage. Is that the intent?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97333</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Watson">watsonm</who>
    <bug_when>2013-12-09 15:41:08 +0000</bug_when>
    <thetext>This looks good to me and would enable us to close the key release bug.

To answer Joe&apos;s question, yes, applications would need to track previously created sessions and their ids and then use that information to reload a previously established session if needed.

I think this explicit knowledge / control of session storage is cleaner than having the CDM do this transparently. The application can store this information in IndexedDB / WebStorage. If that is cleared, the stored sessions in the CDM should probably be cleared anyway.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97556</commentid>
    <comment_count>3</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2013-12-12 23:54:09 +0000</bug_when>
    <thetext>(In reply to Joe Steele from comment #1)
&gt; What is the workflow you are proposing for loading previously loaded keys
&gt; then? Would the application have to keep track of each sessionID it has seen
&gt; and then try to load them later? I am not sure how this is intended to solve
&gt; the general problem of CDM data storage. Is that the intent?

The proposal for loadSession implies that CDMs will be able to store keys between browsing sessions. Calling loadSession with a sessionID that would be stored locally in some JavaScript enabled mechanism (e.g. localstorage or IndexedDB) would ask the CDM to reconstitute the MediaKeySession from whatever it stored.

I think this means that the goal of avoiding general CDM data storage has been dropped.

I think this is a good approach. The implementation of the method is optional (not the method itself) - it will throw if this isn&apos;t supported by the CDM.

Assigning to David.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97823</commentid>
    <comment_count>4</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2013-12-20 01:09:25 +0000</bug_when>
    <thetext>To be resolved: Can the same session (ID) be loaded multiple times without closing the previous MediaKeySession?
(Note that applications cannot force a MediaKeySession to be closed while keeping it &quot;stored&quot; since release() frees the stored session.)

If not allowed, should a &quot;QuotaExceededError&quot; MediaKeyError be fired on subsequent attempts?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97890</commentid>
    <comment_count>5</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2013-12-30 17:04:11 +0000</bug_when>
    <thetext>(In reply to David Dorwin from comment #4)
&gt; To be resolved: Can the same session (ID) be loaded multiple times without
&gt; closing the previous MediaKeySession?
&gt; (Note that applications cannot force a MediaKeySession to be closed while
&gt; keeping it &quot;stored&quot; since release() frees the stored session.)
&gt; 
&gt; If not allowed, should a &quot;QuotaExceededError&quot; MediaKeyError be fired on
&gt; subsequent attempts?

When I was thinking about text for this I wondered if it was required that a loaded session always got the same session ID as the original or might it be allowable for a CDM to create a session that gets a new ID.

Since we don&apos;t currently have implementations for loadSession I think we should describe it as narrowly as possible (for example, you can only load a session once, it always gets the same session ID as the original). Then, if we find an implementation that has a requirement to relax the rules we can do that but this way we keep the surface area as small as possible until we know we need more.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98084</commentid>
    <comment_count>6</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2014-01-07 15:45:18 +0000</bug_when>
    <thetext>I added a first pass at this to the spec.
https://dvcs.w3.org/hg/html-media/rev/154207f5ed25</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102866</commentid>
    <comment_count>7</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2014-03-25 00:53:28 +0000</bug_when>
    <thetext>This looks good to me. Thanks.

I made some minor changes in https://dvcs.w3.org/hg/html-media/rev/1c0406dd179f</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102898</commentid>
    <comment_count>8</comment_count>
    <who name="David Dorwin">ddorwin</who>
    <bug_when>2014-03-25 21:51:56 +0000</bug_when>
    <thetext>Added origin checks: https://dvcs.w3.org/hg/html-media/rev/65700f185389</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>