[Bug 26575] Separate creation of the MediaKeySession from "message" event generation

https://www.w3.org/Bugs/Public/show_bug.cgi?id=26575

Shinya Maruyama <Shinya.Maruyama@jp.sony.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Shinya.Maruyama@jp.sony.com

--- Comment #14 from Shinya Maruyama <Shinya.Maruyama@jp.sony.com> ---
The bug seems to be introduced by this change in example '8.5. Stored License'.

  // Called if the application does not have a stored sessionId for the media
resource.
  function makeNewRequest(mediaKeys, initDataType, initData) {
    var keySession = mediaKeys.createSession("persistent");
    keySession.addEventListener("message", handleMessage, false);
    keySession.closed.then(
      function() {
        console.log("Session " + this.sessionId + " closed");
      }.bind(keySession)        
    );
    // Store keySession.sessionId in the application.
    keySession.generateRequest(initDataType, initData).catch(
      console.error.bind(console, "Unable to create or initialize a persistable
key session")
    );
  }

"Store keySession.sessionId in the application" needs to be moved after
generateRequest is resolved because sessionId attribute is not available at the
timing above.
Essentially this seems to be the API design issue. I believe application should
store the sessionId before the session data is persisted within update() to
avoid application losing the sessionId. However, as the generateRequest is
asynchronous, the API can no longer expect that sessionId is made available to
the application before update() unless the application takes a special care for
the timing.
For the reason, the API which sets the sessionId attribute should be separate
from generateRequest and load methods, for example, adding init() method;
 mediakeysession.init(optional sessionId)
  - if sessionId was not provided, create a new sessionId
  - set the sessionId to sessionId attribute
 mediakeysession.load() // sessionId parameter is removed

Alternatively, we may have to get back to the separate loadSession(sessionId).
In that case, the sessionId attribute is set by either createSession() or
loadSession(). Then, the sessionId parameter is removed from the
mediakeysession.load(). If load() method takes optional initData parameter,
this is useful for someone who prefer to use initData for loading persistent
license. Meaning load() method can be used with both createSession and
loadSession. Once license is persisted, the application can load the persistent
license by; createSession(sessionType=persistent) followed by
load(initDataType, initData) instead of loadSession(sessionId). It maybe helps
resolve the discussion on
http://lists.w3.org/Archives/Public/public-html-media/2014Aug/0016.html. 

In addition, probably it's not the bug introduced by this change but there
seems to be the bug in 8.5 Stored License regarding the removal of sessionId.

  // Called when the application wants to remove the stored license.
  // The stored session data has not been completely removed until the promise
returned by remove() is fulfilled.
  // The remove() call may initiate a series of messages to/from the server
that must be completed before this occurs.
  function removeStoredSession(keySession) {
    keySession.remove().then(
      function() {
        console.log("Session " + this.sessionId + " removed");
        // The application should remove its record of this.sessionId.
      }.bind(keySession)
    ).catch(
      console.error.bind(console, "Failed to remove the session")
    );
  }

The sessionId should not be removed at the timing if remove() requires message
exchange(s).

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 27 August 2014 07:40:19 UTC