Bug 1544023 Comment 9 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

So the problem here was caused by the incorrect suspended count. When we do `AudioContext::GetAllStreams()`, we only append the stream of AudioParam which has been connected to AudioNode. If the AudioParam doesn't connect with any other node, then we can't get its stream and opereate its suspended count.

For this crash, the things was that,
1. `source.connect(oscillator.frequency)` 
- created the stream for AudioParam, and connected it to the `mOutputParams`
- stream became active later, suspended count changed from `1`(initial value) to `0`
2. `source.disconnect()`
- removed the stream from `mOutputParams`
3. `SuspendFromChrome` occured (not sure why this should happen)
- we couldn't get the stream because the node had disconnected.
- therefore, we *DID NOT* change suspended count here, which caused incorrect counting
4.  `processor.connect(oscillator.frequency)`
- added the stream to the `mOutputParams` again
5. `ResumeFromChrome` occured
- we got the stream from `mOutputParams`, so its suspended count changed from `0` to `-1` (wrong!)
6. `Suspend` operation occured in StreamGraphThread (it was triggered by `context.suspend().then(function (arg1) { })`)
- the stream's suspended count changed from `-1` to `0`
- and added it to `mSuspendedStreams`
7. when all stuffs were going to shutdown, the stream would be detroyed and disconnected, so the `AudioNodeStream::RemoveInput()` ran and finally it would trigger `MediaStreamGraphImpl::IncrementSuspendCount()`
- the stream's suspended count changed from `0` to `1`
- but it was in the ``mSuspendedStreams`, which caused assertion failed.
So the problem here was caused by the incorrect suspended count. When we do `AudioContext::GetAllStreams()`, we only append the stream of AudioParam which has been connected to AudioNode. If the AudioParam doesn't connect with any other node, then we can't get its stream and opereate its suspended count.

For this crash, the things was that,
1. `source.connect(oscillator.frequency)` 
- created the stream for AudioParam, and connected it to the `mOutputParams`
- stream became active later, suspended count changed from `1`(initial value) to `0`
2. `source.disconnect()`
- removed the stream from `mOutputParams`
3. `SuspendFromChrome` occured (not sure why this should happen)
- we couldn't get the stream because the node had disconnected.
- therefore, we *DID NOT* change suspended count here, which caused incorrect counting
4.  `processor.connect(oscillator.frequency)`
- added the stream to the `mOutputParams` again
5. `ResumeFromChrome` occured
- we got the stream from `mOutputParams`, so its suspended count changed from `0` to `-1` (wrong!)
6. `Suspend` operation occured in StreamGraphThread (it was triggered by `context.suspend().then(function (arg1) { })`)
- the stream's suspended count changed from `-1` to `0`
- and added it to `mSuspendedStreams`
7. when all stuffs were going to shutdown, the stream would be detroyed and disconnected, so the `AudioNodeStream::RemoveInput()` ran and finally it would trigger `MediaStreamGraphImpl::IncrementSuspendCount()`
- the stream's suspended count changed from `0` to `1`
- but the stream was in the `mSuspendedStreams`, not in `mStream`, which caused assertion failed.

Back to Bug 1544023 Comment 9