New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 690664 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

EME: close() will return undefined if already closed

Project Member Reported by modma...@google.com, Feb 9 2017

Issue description

Chrome Version: 56.0.2924.87 and 58.0.3004.3
OS: Linux

What steps will reproduce the problem?
(1) Create EME session and generate request.
(2) Close session, wait until closed.
(3) Call session.close() again.

What is the expected result?
Second call to close() (when already closed) should return a resolved Promise.

What happens instead?
Returns undefined.

Repro: https://jsfiddle.net/4qd6jrgv/
 
Labels: M-58
Owner: jrumm...@chromium.org
Status: Assigned (was: Untriaged)
Status: Started (was: Assigned)
There is already an existing test (encrypted-media-session-multiple-close.html) that calls close() multiple times, but does so as:
  return Promise.all([mediaKeySession.close(), mediaKeySession.close(), mediaKeySession.close()]);
There doesn't appear to be a test that calls them sequentially.
Cc: haraken@chromium.org yhirano@chromium.org
I changed the code in the repro to end with:
    .then(() => { var p = session.close(); console.log(p); return p; })
    .then(() => { var p = session.close(); console.log(p); return p; })
    .then(() => { var p = session.close(); console.log(p); return p; });
In the console I see:
   Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
   undefined
   undefined
So it acts like a resolved promise, even if it doesn't look like one. 

The code in MediaKeySession.cpp, if the session is already closed, simply uses ScriptPromise::cast() to create a resolved promise:
    return ScriptPromise::cast(scriptState, ScriptValue());
I changed it to create and resolve one of the EME promise wrappers directly:
    SimpleResultPromise* result = new SimpleResultPromise(scriptState, this);
    ScriptPromise promise = result->promise();
    result->complete();
    return promise;
Running that I now see:
    Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
    Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: undefined}
    Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: undefined}

yhirano, haraken: Should ScriptPromise::cast() not return an object that looks like a promise?

(Note: running the repro on ToT requires the second parameter to requestMediaKeySystemAccess() to be "[{audioCapabilities: [{contentType: 'audio/webm; codecs=vorbis'}]}]", as otherwise it fails with "None of the requested configurations were supported.")
Please don't pass an empty ScriptValue to ScriptPromise::cast. You can use ScriptPromise::castUndefined.
yhirano: Thanks. That fixes it.
Status: Fixed (was: Started)

Sign in to add a comment