Commit faf1e5f7 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Remove limit on the number of concurrent AudioContexts

There's no reason to have a limit on the number of concurrent
AudioContexts.  If the user creates too many, we'll just run out of
resources and stop.

Bug: 777342
Test: audiocontext-max-contexts.html removed
Change-Id: I55ac01e42cc1ffc313db5b93e49db1c4a36a585b
Reviewed-on: https://chromium-review.googlesource.com/875192Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532561}
parent 274e376d
<!DOCTYPE html>
<html>
<head>
<title>
audiocontext-max-contexts.html
</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
<script src="../resources/audit.js"></script>
</head>
<body>
<script id="layout-test-code">
let audit = Audit.createTaskRunner();
let contextsToCreate = 10;
function reachHardwareContextsLimit() {
let context = [];
for (let i = 0; i < contextsToCreate; ++i)
context[i] = new AudioContext();
}
audit.define(
{
label: 'hardware-context-limit',
description:
'AudioContext throws when hardware context limit is reached'
},
function(task, should) {
should(
function() {
reachHardwareContextsLimit();
},
'Create ' + contextsToCreate + ' concurrent AudioContext\'s')
.throw('NotSupportedError');
task.done();
});
audit.run();
</script>
</body>
</html>
...@@ -26,10 +26,12 @@ ...@@ -26,10 +26,12 @@
namespace blink { namespace blink {
// Don't allow more than this number of simultaneous AudioContexts // Number of AudioContexts still alive. It's incremented when an
// talking to hardware. // AudioContext is created and decremented when the context is closed.
const unsigned kMaxHardwareContexts = 6;
static unsigned g_hardware_context_count = 0; static unsigned g_hardware_context_count = 0;
// A context ID that is incremented for each context that is created.
// This initializes the internal id for the context.
static unsigned g_context_id = 0; static unsigned g_context_id = 0;
AudioContext* AudioContext::Create(Document& document, AudioContext* AudioContext::Create(Document& document,
...@@ -40,15 +42,6 @@ AudioContext* AudioContext::Create(Document& document, ...@@ -40,15 +42,6 @@ AudioContext* AudioContext::Create(Document& document,
UseCounter::CountCrossOriginIframe( UseCounter::CountCrossOriginIframe(
document, WebFeature::kAudioContextCrossOriginIframe); document, WebFeature::kAudioContextCrossOriginIframe);
if (g_hardware_context_count >= kMaxHardwareContexts) {
exception_state.ThrowDOMException(
kNotSupportedError,
ExceptionMessages::IndexExceedsMaximumBound(
"number of hardware contexts", g_hardware_context_count,
kMaxHardwareContexts));
return nullptr;
}
WebAudioLatencyHint latency_hint(WebAudioLatencyHint::kCategoryInteractive); WebAudioLatencyHint latency_hint(WebAudioLatencyHint::kCategoryInteractive);
if (context_options.latencyHint().IsAudioContextLatencyCategory()) { if (context_options.latencyHint().IsAudioContextLatencyCategory()) {
latency_hint = WebAudioLatencyHint( latency_hint = WebAudioLatencyHint(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment