Closed Bug 1062293 Opened 10 years ago Closed 10 years ago

Fix MediaStreamGraph shutdown sequence

Categories

(Core :: Audio/Video, defect)

32 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla35
Tracking Status
firefox32 --- unaffected
firefox33 --- unaffected
firefox34 + fixed
firefox35 --- fixed

People

(Reporter: padenot, Assigned: padenot)

References

Details

Attachments

(3 files)

      No description provided.
As noted in the comment, it is very useful to have this interleaved with the ADB
logcat on Android/b2g, because this way we can correlate gecko state with the
state of the Android HAL.
Attachment #8483484 - Flags: review?(rjesup)
This basically gets a grip on the graph while doing driver switches operations
on another thread (system thread or audio thread), because those can take time.
Because the graph is refcounted, it'll be freed when the last operation
finishes, which is what we want.

This patch also only allows driver switching when the graph is in state
LIFECYCLE_RUNNING, which is what we want anyway.
Attachment #8483487 - Flags: review?(rjesup)
This ensures the callback won't be called when draining is done.

I've seen a bunch of cases on slow, mono-core machines where we call the
playhead state handler for the drain right before the next callback after having
set `stm->draining = 1`, so we actually stop draining by resetting
`stm->draining` to 0 and keep calling the user-provided callback.

This caused a bunch of UAF / deadlocks on Android and B2G.
Attachment #8483490 - Flags: review?(kinetik)
Comment on attachment 8483484 [details] [diff] [review]
Add specialized logging to track the lifetime state change of MediaStreamGraphs r=

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

::: content/media/GraphDriver.cpp
@@ +18,5 @@
>  #endif
>  
> +// We don't use NSPR log here because we want this interleaved with adb logcat
> +// on Android/B2G
> +#define ENABLE_LIFECYCLE_LOG

are we ever going to disable this?

::: content/media/MediaStreamGraph.cpp
@@ +44,5 @@
>  #else
>  #define STREAM_LOG(type, msg)
>  #endif
>  
> +#define ENABLE_LIFECYCLE_LOG

Are we ever going to disable this?  If so, file a bug.  If we don't want it in release builds, maybe something like
#if defined(DEBUG) || !defined(SOME_RELEASE_BUILD_DEFINE)

@@ +1576,5 @@
> +    "LIFECYCLE_THREAD_NOT_STARTED",
> +    "LIFECYCLE_RUNNING",
> +    "LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP",
> +    "LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN",
> +    "LIFECYCLE_WAITING_FOR_STREAM_DESTRUCTION"

Add a note where the states are defined saying if you change it to update this.
Attachment #8483484 - Flags: review?(rjesup) → review+
Attachment #8483487 - Flags: review?(rjesup) → review+
Attachment #8483490 - Flags: review?(kinetik) → review+
Depends on: 1064713
We need this on Aurora, as it fixes a bunch of intermittents
Comment on attachment 8483484 [details] [diff] [review]
Add specialized logging to track the lifetime state change of MediaStreamGraphs r=

Approval Request Comment
[Feature/regressing bug #]: MSG refactoring (bug 848954)
[User impact if declined]: crashes
[Describe test coverage new/current, TBPL]: this  fixes a lot of intermittents
[Risks and why]: it's been on inbound and central for some days
[String/UUID change made/needed]: none
Attachment #8483484 - Flags: approval-mozilla-aurora?
Comment on attachment 8483487 [details] [diff] [review]
Ensure the graph stays alive when doing driver switches and audio stream shutdown operations. r=

Approval Request Comment
[Feature/regressing bug #]: MSG refactoring (bug 848954)
[User impact if declined]: crashes
[Describe test coverage new/current, TBPL]: this  fixes a lot of intermittents
[Risks and why]: it's been on inbound and central for some days
[String/UUID change made/needed]: none
Comment on attachment 8483487 [details] [diff] [review]
Ensure the graph stays alive when doing driver switches and audio stream shutdown operations. r=

Approval Request Comment
[Feature/regressing bug #]: MSG refactoring (bug 848954)
[User impact if declined]: crashes
[Describe test coverage new/current, TBPL]: this  fixes a lot of intermittents
[Risks and why]: it's been on inbound and central for some days
[String/UUID change made/needed]: none
Comment on attachment 8483490 [details] [diff] [review]
Fix opensl's cubeb backend draining. r=

Approval Request Comment
[Feature/regressing bug #]: MSG refactoring (bug 848954)
[User impact if declined]: crashes
[Describe test coverage new/current, TBPL]: this  fixes a lot of intermittents
[Risks and why]: it's been on inbound and central for some days
[String/UUID change made/needed]: none
Whiteboard: [webrtc-uplift]
Attachment #8483487 - Flags: approval-mozilla-aurora?
Attachment #8483490 - Flags: approval-mozilla-aurora?
padenot put approval requests for the other two patches in here, but didn't set the bits on the patches
Comment on attachment 8483484 [details] [diff] [review]
Add specialized logging to track the lifetime state change of MediaStreamGraphs r=

Aurora+
Attachment #8483484 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Attachment #8483487 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Attachment #8483490 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Depends on: 1070457
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: