Closed Bug 1157994 Opened 9 years ago Closed 9 years ago

Assertion failure: "Invalid AudioContextState transition" with suspend, close

Categories

(Core :: Web Audio, defect)

defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: jruderman, Assigned: padenot)

References

Details

(Keywords: assertion, testcase)

Attachments

(3 files, 1 obsolete file)

Attached file testcase
Assertion failure: (mAudioContextState == AudioContextState::Suspended && aNewState == AudioContextState::Running) || (mAudioContextState == AudioContextState::Running && aNewState == AudioContextState::Suspended) || (mAudioContextState == AudioContextState::Running && aNewState == AudioContextState::Closed) || (mAudioContextState == AudioContextState::Suspended && aNewState == AudioContextState::Closed) || (mAudioContextState == aNewState) (Invalid AudioContextState transition), at dom/media/webaudio/AudioContext.cpp:790

This assertion is part of code added in https://hg.mozilla.org/mozilla-central/rev/82bbdffc624b
Attached file stack
Blocks: 1094764
This caused a transition from closed to suspended, which was caught by the
assert.
Attachment #8597233 - Flags: review?(roc)
Assignee: nobody → padenot
Status: NEW → ASSIGNED
Comment on attachment 8597233 [details] [diff] [review]
Ensure AudioContext operations are started and resolved in the same order. r=

Review of attachment 8597233 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/media/GraphDriver.cpp
@@ +1083,5 @@
>    }
>  
> +  // We're going to iterate backward on the array, because we need to remove the
> +  // elements, but we also need to conserve the order of events, so we reverse
> +  // the array before iterating backward.

I hope there's a simpler way to "iterate & remove" than reverse-in-place followed by iterating backwards. Is there a consuming iterator you can use, perhaps after swapping out array?

@@ +1087,5 @@
> +  // the array before iterating backward.
> +  uint32_t length = array.Length();
> +  for (uint32_t i = 0; i < length / 2; i++) {
> +    std::swap(array[i], array[length - i - 1]);
> +  }

Do you feel like fixing bug 1061459? ;)

::: dom/media/test/crashtests/1157994.html
@@ +8,5 @@
> +    var ac = new AudioContext();
> +    setTimeout(function() {
> +        ac.suspend();
> +        ac.close();
> +    }, 100);

Do you know how the crashtest could be transformed into something that doesn't use setTimeout 100ms? Is there an event it could listen for instead? (I think I tried setTimeout 0 and it didn't assert.)

If we can't eliminate the setTimeout, the crashtest needs to do the reftest-wait dance like in https://dxr.mozilla.org/mozilla-central/source/docshell/base/crashtests/369126-1.html#1,7. (Otherwise the test can be unloaded before the timeout fires.)
Comment on attachment 8597233 [details] [diff] [review]
Ensure AudioContext operations are started and resolved in the same order. r=

Review of attachment 8597233 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/media/GraphDriver.cpp
@@ +1086,5 @@
> +  // elements, but we also need to conserve the order of events, so we reverse
> +  // the array before iterating backward.
> +  uint32_t length = array.Length();
> +  for (uint32_t i = 0; i < length / 2; i++) {
> +    std::swap(array[i], array[length - i - 1]);

How about just iterating forward and explicitly subtracting 1 from the index when we remove an element? That seems simplest.
Attachment #8597233 - Flags: review?(roc) → review-
This is simpler, I'm not sure why I did it that way the first time.
Attachment #8598064 - Flags: review?(roc)
Attachment #8597233 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/0a9693ebe7f5
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: