Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify generateRequest() failures caused by lack of resources #483

Closed
xhwang-chromium opened this issue Apr 6, 2021 · 1 comment · Fixed by #485
Closed

Specify generateRequest() failures caused by lack of resources #483

xhwang-chromium opened this issue Apr 6, 2021 · 1 comment · Fixed by #485
Assignees
Labels

Comments

@xhwang-chromium
Copy link
Contributor

When using hardware-backed CDMs, it's common that there's a limit on how many sessions the CDM can open, mostly because each session is backed by some hardware resource (e.g. in TEE), and there's a limit on such resource. The limit is often global for the device, so a JS player can hit this issue even if it only opens a few sessions, e.g. if other native applications or other sites on the same browser have outstanding sessions open.

Currently the spec doesn't say what the user agent should do for this case. The closest one is in generateRequest(), step 10.10.1:

If any of the preceding steps failed, reject promise with a new DOMException whose name is the appropriate error name.

In practice, implementations could choose any exception it chooses. For example, Chromium on Android chooses NOT_SUPPORTED_ERROR, and on Windows it could return INVALID_STATE_ERROR.

I propose that we add an explicit step for generateRequest() in the spec:

  • If generateRequest() failed due to lack of resources, return a promise rejected with a newly created QuotaExceededError.
  • Also update QuotaExceededError under 6.5 Exceptions to include this case.

Note that the CDM implementation could choose to actively evict older sessions as an alternative solution to this issue. In that case, generateRequest() on new session will succeed, but an older session will be closed automatically. This is covered under 6.4.4 Session Closed algorithm:

The CDM may close a session at any point, such as when the session is no longer needed or when system resources are lost. In that case, the Monitor for CDM Changes algorithm detects the change and runs this algorithm.

Issue 473 further proposes to add a Reason to the closed attribute so the exact reason for the closure can be returned.

@joeyparrish
Copy link
Member

SGTM to explicitly specify QuotaExceededError.

@joeyparrish joeyparrish self-assigned this Apr 13, 2021
joeyparrish added a commit to joeyparrish/encrypted-media that referenced this issue May 11, 2021
This was already possible under the very general specification of
"reject promise with a new DOMException whose name is the appropriate
error name."  However, it is better to explicitly state a common case
where QuotaExceededError should be used.

Closes w3c#483
gregwfreedman pushed a commit that referenced this issue May 12, 2021
This was already possible under the very general specification of
"reject promise with a new DOMException whose name is the appropriate
error name."  However, it is better to explicitly state a common case
where QuotaExceededError should be used.

Closes #483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants