Skip to content

Fix hang while waiting for state changes. - #857

Open
aosmond wants to merge 1 commit into
mozilla:masterfrom
aosmond:ao_bug1831033
Open

Fix hang while waiting for state changes.#857
aosmond wants to merge 1 commit into
mozilla:masterfrom
aosmond:ao_bug1831033

Conversation

@aosmond

@aosmond aosmond commented Aug 26, 2026

Copy link
Copy Markdown

In wait_for_state_change, it loops until the new state matches the desired state. Sometimes the state machine would skip the expected state to another. This would happen in aaudio_stream_start_locked, where we were in STARTING, expected to move to STARTED, and then it would transition into STOPPING/STOPPED/DISCONNECTED instead. This will cause the thread to block forever.

This patch replaces wait_for_state_change into two new methods, with the existing callers updated appropriately:

wait_for_stable_state, which doesn't verify what state we expect to move into, but simply until we leave the transitional state to a stable state.

refresh_state, which updates the internal state and reports it without blocking.

--

This should fix bug 1831033, where the MediaDecoderStateMachine was hung waiting on a response from the remoted cubeb forever. It fixes a slew of intermittent failures for test_autoplay_* variants under dom/media/autoplay/test/mochitest.

In wait_for_state_change, it loops until the new state matches the
desired state. Sometimes the state machine would skip the expected
state to another. This would happen in aaudio_stream_start_locked,
where we were in STARTING, expected to move to STARTED, and then it
would transition into STOPPING/STOPPED/DISCONNECTED instead. This
will cause the thread to block forever.

This patch replaces wait_for_state_change into two new methods,
with the existing callers updated appropriately:

wait_for_stable_state, which doesn't verify what state we expect to
move into, but simply until we leave the transitional state to a
stable state.

refresh_state, which updates the internal state and reports it
without blocking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant