Bug 1884016 - part6 : avoid re-initialize the video bridge. r=gerard-majax

There is a timing issue where we would re-initialize the video bridge
causing an assertion, which is discovered by
`browser_utility_multipleAudio.js`.

Differential Revision: https://phabricator.services.mozilla.com/D203518
This commit is contained in:
alwu
2024-03-07 00:29:15 +00:00
parent 14428696f5
commit df64af2da5
2 changed files with 7 additions and 11 deletions

View File

@@ -110,15 +110,10 @@ mozilla::ipc::IPCResult
UtilityAudioDecoderChild::RecvCompleteCreatedVideoBridge() { UtilityAudioDecoderChild::RecvCompleteCreatedVideoBridge() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM); MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
mHasCreatedVideoBridge = true; mHasCreatedVideoBridge = State::Created;
return IPC_OK(); return IPC_OK();
} }
bool UtilityAudioDecoderChild::HasCreatedVideoBridge() const {
MOZ_ASSERT(NS_IsMainThread());
return mHasCreatedVideoBridge;
}
void UtilityAudioDecoderChild::OnVarChanged(const gfx::GfxVarUpdate& aVar) { void UtilityAudioDecoderChild::OnVarChanged(const gfx::GfxVarUpdate& aVar) {
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM); MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
SendUpdateVar(aVar); SendUpdateVar(aVar);
@@ -127,7 +122,7 @@ void UtilityAudioDecoderChild::OnVarChanged(const gfx::GfxVarUpdate& aVar) {
void UtilityAudioDecoderChild::OnCompositorUnexpectedShutdown() { void UtilityAudioDecoderChild::OnCompositorUnexpectedShutdown() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM); MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
mHasCreatedVideoBridge = false; mHasCreatedVideoBridge = State::None;
CreateVideoBridge(); CreateVideoBridge();
} }
@@ -135,9 +130,11 @@ bool UtilityAudioDecoderChild::CreateVideoBridge() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM); MOZ_ASSERT(mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM);
if (HasCreatedVideoBridge()) { // Creating or already created, avoiding reinit a bridge.
if (mHasCreatedVideoBridge != State::None) {
return true; return true;
} }
mHasCreatedVideoBridge = State::Creating;
// Build content device data first; this ensure that the GPU process is fully // Build content device data first; this ensure that the GPU process is fully
// ready. // ready.

View File

@@ -96,8 +96,6 @@ class UtilityAudioDecoderChild final : public PUtilityAudioDecoderChild
#ifdef MOZ_WMF_MEDIA_ENGINE #ifdef MOZ_WMF_MEDIA_ENGINE
mozilla::ipc::IPCResult RecvCompleteCreatedVideoBridge(); mozilla::ipc::IPCResult RecvCompleteCreatedVideoBridge();
bool HasCreatedVideoBridge() const;
void OnVarChanged(const gfx::GfxVarUpdate& aVar) override; void OnVarChanged(const gfx::GfxVarUpdate& aVar) override;
void OnCompositorUnexpectedShutdown() override; void OnCompositorUnexpectedShutdown() override;
@@ -120,7 +118,8 @@ class UtilityAudioDecoderChild final : public PUtilityAudioDecoderChild
#ifdef MOZ_WMF_MEDIA_ENGINE #ifdef MOZ_WMF_MEDIA_ENGINE
// True if the utility process has created a video bridge with the GPU prcess. // True if the utility process has created a video bridge with the GPU prcess.
// Currently only used for media egine cdm. Main thread only. // Currently only used for media egine cdm. Main thread only.
bool mHasCreatedVideoBridge = false; enum class State { None, Creating, Created };
State mHasCreatedVideoBridge = State::None;
#endif #endif
TimeStamp mAudioDecoderChildStart; TimeStamp mAudioDecoderChildStart;