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

Nothing to do if state isn't changing

In the test case in 835713, the page calls context.resume()
twice. Once on load and once on a user gesture.  The first call to
resume has a promise pending that gets resolved when the second
promise is resolved when the context is finally allowed to start.

As part of the resolution of the promise, the context state is set to
"running", which happens in the first promise.  The second promise
does this again.  But SetContextState checks for valid state
transitions, and running->running isn't one of them.  However, if the
state isn't changing, there's nothing that needs to be done, so
SetContextStae can return early.

Bug: 835713
Test: repro case no longer DCHECKs
Change-Id: Iccfc88ce1caedc3cdf7cdfcf3e8ed4a84d4010e4
Reviewed-on: https://chromium-review.googlesource.com/1026082Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553591}
parent 03fc3da4
......@@ -628,6 +628,12 @@ String BaseAudioContext::state() const {
void BaseAudioContext::SetContextState(AudioContextState new_state) {
DCHECK(IsMainThread());
// If there's no change in the current state, there's nothing that needs to be
// done.
if (new_state == context_state_) {
return;
}
// Validate the transitions. The valid transitions are Suspended->Running,
// Running->Suspended, and anything->Closed.
switch (new_state) {
......@@ -642,11 +648,6 @@ void BaseAudioContext::SetContextState(AudioContextState new_state) {
break;
}
if (new_state == context_state_) {
// DCHECKs above failed; just return.
return;
}
context_state_ = new_state;
// Notify context that state changed
......
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