Commit 80a33cc0 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Deprecate WebAudio Media nodes on an OfflineAudioContext

Print a deprecation message when WebAudio Media nodes
(MediaElementAudioSourceNode, MediaStreamAudioDestinationNode,
MediaStreamAudioSourceNode) are created on an OfflineAudioContext.
Doing so is not allowed in the WebAudio spec.

Intent: https://groups.google.com/a/chromium.org/d/msg/blink-dev/H29uXnsIN54/BKXDqxoJAQAJ
Chrome feature entry: https://www.chromestatus.com/feature/5258622686724096

Bug: 845913
Change-Id: I5247d67456afa11582099f4d52d65a76f788639d
Reviewed-on: https://chromium-review.googlesource.com/1091656
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568124}
parent ffe80a57
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
// Some arbitrary sample rate for the offline context. // Some arbitrary sample rate for the offline context.
let sampleRate = 48000; let sampleRate = 48000;
// The actual offline context // The actual contexts to use
let context; let offlineContext;
let onlineContext;
// The set of all methods that we've tested for verifying that we tested // The set of all methods that we've tested for verifying that we tested
// all of the necessary objects. // all of the necessary objects.
...@@ -31,8 +32,11 @@ ...@@ -31,8 +32,11 @@
let audit = Audit.createTaskRunner(); let audit = Audit.createTaskRunner();
// Array describing the tests that should be run. // Array describing the tests that should be run. |testOfflineConfigs| is
let testConfigs = [ // for tests that can use an offline context. |testOnlineConfigs| is for
// tests that need to use an online context. Offline contexts are
// preferred when possible.
let testOfflineConfigs = [
{ {
// The name of the method to create the particular node to be tested. // The name of the method to create the particular node to be tested.
creator: 'createGain', creator: 'createGain',
...@@ -186,27 +190,44 @@ ...@@ -186,27 +190,44 @@
creator: 'createChannelMerger', creator: 'createChannelMerger',
args: [], args: [],
}, },
];
let testOnlineConfigs = [
{creator: 'createMediaElementSource', args: [new Audio()]}, {creator: 'createMediaElementSource', args: [new Audio()]},
{creator: 'createMediaStreamDestination', args: []} {creator: 'createMediaStreamDestination', args: []}
// Can't currently test MediaStreamSource because we're using an offline // Can't currently test MediaStreamSource because we're using an offline
// context. // context.
]; ];
// Create the context so we can use it in the following test. // Create the contexts so we can use it in the following test.
audit.define('initialize', (task, should) => { audit.define('initialize', (task, should) => {
// Just any context so that we can create the nodes. // Just any context so that we can create the nodes.
should(() => { should(() => {
context = new OfflineAudioContext(1, 1, sampleRate); offlineContext = new OfflineAudioContext(1, 1, sampleRate);
}, 'Create context for tests').notThrow(); }, 'Create offline context for tests').notThrow();
should(() => {
onlineContext = new AudioContext();
}, 'Create online context for tests').notThrow();
task.done(); task.done();
}); });
// Create a task for each entry in testConfigs // Create a task for each entry in testOfflineConfigs
for (let test in testConfigs) { for (let test in testOfflineConfigs) {
let config = testConfigs[test] let config = testOfflineConfigs[test]
audit.define(config.creator, (function(c) { audit.define('Offline ' + config.creator, (function(c) {
return (task, should) => {
let node = offlineContext[c.creator](...c.args);
testLimits(should, c.creator, node, c.limits);
task.done();
};
})(config));
}
for (let test in testOnlineConfigs) {
let config = testOnlineConfigs[test]
audit.define('Online ' + config.creator, (function(c) {
return (task, should) => { return (task, should) => {
let node = context[c.creator](...c.args); let node = onlineContext[c.creator](...c.args);
testLimits(should, c.creator, node, c.limits); testLimits(should, c.creator, node, c.limits);
task.done(); task.done();
}; };
...@@ -215,7 +236,7 @@ ...@@ -215,7 +236,7 @@
// Test the AudioListener params that were added for the automated Panner // Test the AudioListener params that were added for the automated Panner
audit.define('AudioListener', (task, should) => { audit.define('AudioListener', (task, should) => {
testLimits(should, '', context.listener, { testLimits(should, '', offlineContext.listener, {
positionX: { positionX: {
minValue: -mostPositiveFloat, minValue: -mostPositiveFloat,
maxValue: mostPositiveFloat, maxValue: mostPositiveFloat,
...@@ -261,8 +282,8 @@ ...@@ -261,8 +282,8 @@
audit.define('verifyTests', (task, should) => { audit.define('verifyTests', (task, should) => {
let allNodes = new Set(); let allNodes = new Set();
// Create the set of all "create" methods from the context. // Create the set of all "create" methods from the context.
for (let method in context) { for (let method in offlineContext) {
if (typeof context[method] === 'function' && if (typeof offlineContext[method] === 'function' &&
method.substring(0, 6) === 'create') { method.substring(0, 6) === 'create') {
allNodes.add(method); allNodes.add(method);
} }
...@@ -295,7 +316,7 @@ ...@@ -295,7 +316,7 @@
// Just use a DelayNode for testing because the audio param has finite // Just use a DelayNode for testing because the audio param has finite
// limits. // limits.
should(() => { should(() => {
let d = context.createDelay(); let d = offlineContext.createDelay();
// The console output should have the warnings that we're interested // The console output should have the warnings that we're interested
// in. // in.
......
CONSOLE WARNING: line 22: The Web Audio autoplay policy will be re-enabled in Chrome 70 (October 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
Tests garbage collection of MediaElementAudioSourceNode. Tests garbage collection of MediaElementAudioSourceNode.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
} }
audioElement = document.createElement('audio'); audioElement = document.createElement('audio');
context = new OfflineAudioContext(1, 1000, 44100); context = new AudioContext();
source = context.createMediaElementSource(audioElement); source = context.createMediaElementSource(audioElement);
audioElement = null; audioElement = null;
context = null; context = null;
......
...@@ -1939,6 +1939,9 @@ enum WebFeature { ...@@ -1939,6 +1939,9 @@ enum WebFeature {
kTextToSpeech_SpeakCrossOrigin = 2472, kTextToSpeech_SpeakCrossOrigin = 2472,
kTextToSpeech_SpeakDisallowedByAutoplay = 2473, kTextToSpeech_SpeakDisallowedByAutoplay = 2473,
kStaleWhileRevalidateEnabled = 2474, kStaleWhileRevalidateEnabled = 2474,
kMediaElementSourceOnOfflineContext = 2475,
kMediaStreamDestinationOnOfflineContext = 2476,
kMediaStreamSourceOnOfflineContext = 2477,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -567,6 +567,25 @@ DeprecationInfo GetDeprecationInfo(WebFeature feature) { ...@@ -567,6 +567,25 @@ DeprecationInfo GetDeprecationInfo(WebFeature feature) {
WillBeRemoved("Anonymous named getter of HTMLFrameSetElement", WillBeRemoved("Anonymous named getter of HTMLFrameSetElement",
kM70, "5235521668251648")}; kM70, "5235521668251648")};
case WebFeature::kMediaElementSourceOnOfflineContext:
return {"MediaElementAudioSourceNode", kM70,
WillBeRemoved("Creating a MediaElementAudioSourceNode on an "
"OfflineAudioContext",
kM70, "5258622686724096")};
case WebFeature::kMediaStreamDestinationOnOfflineContext:
return {"MediaStreamAudioDestinationNode", kM70,
WillBeRemoved("Creating a MediaStreamAudioDestinationNode on an "
"OfflineAudioContext",
kM70, "5258622686724096")};
case WebFeature::kMediaStreamSourceOnOfflineContext:
return {
"MediaStreamAudioSourceNode", kM70,
WillBeRemoved(
"Creating a MediaStreamAudioSourceNode on an OfflineAudioContext",
kM70, "5258622686724096")};
// Features that aren't deprecated don't have a deprecation message. // Features that aren't deprecated don't have a deprecation message.
default: default:
return {"NotDeprecated", kUnknown, ""}; return {"NotDeprecated", kUnknown, ""};
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "third_party/blink/renderer/modules/webaudio/media_element_audio_source_node.h" #include "third_party/blink/renderer/modules/webaudio/media_element_audio_source_node.h"
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h" #include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_output.h" #include "third_party/blink/renderer/modules/webaudio/audio_node_output.h"
...@@ -249,6 +250,11 @@ MediaElementAudioSourceNode* MediaElementAudioSourceNode::Create( ...@@ -249,6 +250,11 @@ MediaElementAudioSourceNode* MediaElementAudioSourceNode::Create(
media_element.SetAudioSourceNode(node); media_element.SetAudioSourceNode(node);
// context keeps reference until node is disconnected // context keeps reference until node is disconnected
context.NotifySourceNodeStartedProcessing(node); context.NotifySourceNodeStartedProcessing(node);
if (!context.HasRealtimeConstraint()) {
Deprecation::CountDeprecation(
node->GetExecutionContext(),
WebFeature::kMediaElementSourceOnOfflineContext);
}
} }
return node; return node;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "third_party/blink/renderer/modules/webaudio/media_stream_audio_destination_node.h" #include "third_party/blink/renderer/modules/webaudio/media_stream_audio_destination_node.h"
#include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h" #include "third_party/blink/public/platform/web_rtc_peer_connection_handler.h"
#include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_input.h" #include "third_party/blink/renderer/modules/webaudio/audio_node_input.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_options.h" #include "third_party/blink/renderer/modules/webaudio/audio_node_options.h"
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h" #include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
...@@ -181,6 +182,12 @@ MediaStreamAudioDestinationNode* MediaStreamAudioDestinationNode::Create( ...@@ -181,6 +182,12 @@ MediaStreamAudioDestinationNode* MediaStreamAudioDestinationNode::Create(
node->HandleChannelOptions(options, exception_state); node->HandleChannelOptions(options, exception_state);
if (!context->HasRealtimeConstraint()) {
Deprecation::CountDeprecation(
node->GetExecutionContext(),
WebFeature::kMediaStreamDestinationOnOfflineContext);
}
return node; return node;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "third_party/blink/renderer/modules/webaudio/media_stream_audio_source_node.h" #include "third_party/blink/renderer/modules/webaudio/media_stream_audio_source_node.h"
#include <memory> #include <memory>
#include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/modules/webaudio/audio_node_output.h" #include "third_party/blink/renderer/modules/webaudio/audio_node_output.h"
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h" #include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include "third_party/blink/renderer/modules/webaudio/media_stream_audio_source_options.h" #include "third_party/blink/renderer/modules/webaudio/media_stream_audio_source_options.h"
...@@ -165,6 +166,12 @@ MediaStreamAudioSourceNode* MediaStreamAudioSourceNode::Create( ...@@ -165,6 +166,12 @@ MediaStreamAudioSourceNode* MediaStreamAudioSourceNode::Create(
// context keeps reference until node is disconnected // context keeps reference until node is disconnected
context.NotifySourceNodeStartedProcessing(node); context.NotifySourceNodeStartedProcessing(node);
if (!context.HasRealtimeConstraint()) {
Deprecation::CountDeprecation(
node->GetExecutionContext(),
WebFeature::kMediaStreamSourceOnOfflineContext);
}
return node; return node;
} }
......
...@@ -19006,6 +19006,9 @@ Called by update_net_error_codes.py.--> ...@@ -19006,6 +19006,9 @@ Called by update_net_error_codes.py.-->
<int value="2472" label="TextToSpeech_SpeakCrossOrigin"/> <int value="2472" label="TextToSpeech_SpeakCrossOrigin"/>
<int value="2473" label="TextToSpeech_SpeakDisallowedByAutoplay"/> <int value="2473" label="TextToSpeech_SpeakDisallowedByAutoplay"/>
<int value="2474" label="StaleWhileRevalidateEnabled"/> <int value="2474" label="StaleWhileRevalidateEnabled"/>
<int value="2475" label="MediaElementSourceOnOfflineContext"/>
<int value="2476" label="MediaStreamDestinationOnOfflineContext"/>
<int value="2477" label="MediaStreamSourceOnOfflineContext"/>
</enum> </enum>
<enum name="FeedbackSource"> <enum name="FeedbackSource">
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