Bug 1884719 - part1 : init gfxVar when creating a UtilityAudioDecoderParent. r=gerard-majax

Move initializing gfxVar from creating a video bridge to the moment we
create UtilityAudioDecoderParent in order to ensure that we can always
get correct value from gfxVar.

Differential Revision: https://phabricator.services.mozilla.com/D204292
This commit is contained in:
alwu 2024-03-13 17:58:03 +00:00
Родитель f4ce4f5c95
Коммит 973db5e9bc
8 изменённых файлов: 63 добавлений и 41 удалений

Просмотреть файл

@ -30,7 +30,6 @@ parent:
#ifdef MOZ_WMF_MEDIA_ENGINE
async InitVideoBridge(Endpoint<PVideoBridgeChild> endpoint,
GfxVarUpdate[] updates,
ContentDeviceData contentDeviceData);
async UpdateVar(GfxVarUpdate var);

Просмотреть файл

@ -21,6 +21,8 @@ include protocol PSandboxTesting;
include "mozilla/ipc/ByteBufUtils.h";
include GraphicsMessages;
using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h";
// Telemetry
@ -98,7 +100,7 @@ child:
async TestTelemetryProbes();
async StartUtilityAudioDecoderService(Endpoint<PUtilityAudioDecoderParent> aEndpoint);
async StartUtilityAudioDecoderService(Endpoint<PUtilityAudioDecoderParent> aEndpoint, GfxVarUpdate[] updates);
async StartJSOracleService(Endpoint<PJSOracleChild> aEndpoint);

Просмотреть файл

@ -56,6 +56,40 @@ UtilityAudioDecoderChild::UtilityAudioDecoderChild(SandboxingKind aKind)
}
}
nsresult UtilityAudioDecoderChild::BindToUtilityProcess(
RefPtr<UtilityProcessParent> aUtilityParent) {
Endpoint<PUtilityAudioDecoderChild> utilityAudioDecoderChildEnd;
Endpoint<PUtilityAudioDecoderParent> utilityAudioDecoderParentEnd;
nsresult rv = PUtilityAudioDecoder::CreateEndpoints(
aUtilityParent->OtherPid(), base::GetCurrentProcId(),
&utilityAudioDecoderParentEnd, &utilityAudioDecoderChildEnd);
if (NS_FAILED(rv)) {
MOZ_ASSERT(false, "Protocol endpoints failure");
return NS_ERROR_FAILURE;
}
nsTArray<gfx::GfxVarUpdate> updates;
#ifdef MOZ_WMF_MEDIA_ENGINE
// Only MFCDM process needs gfxVars
if (mSandbox == SandboxingKind::MF_MEDIA_ENGINE_CDM) {
updates = gfx::gfxVars::FetchNonDefaultVars();
}
#endif
if (!aUtilityParent->SendStartUtilityAudioDecoderService(
std::move(utilityAudioDecoderParentEnd), std::move(updates))) {
MOZ_ASSERT(false, "StartUtilityAudioDecoder service failure");
return NS_ERROR_FAILURE;
}
Bind(std::move(utilityAudioDecoderChildEnd));
PROFILER_MARKER_UNTYPED("UtilityAudioDecoderChild::BindToUtilityProcess", IPC,
MarkerOptions(MarkerTiming::IntervalUntilNowFrom(
mAudioDecoderChildStart)));
return NS_OK;
}
void UtilityAudioDecoderChild::ActorDestroy(ActorDestroyReason aReason) {
MOZ_ASSERT(NS_IsMainThread());
#ifdef MOZ_WMF_MEDIA_ENGINE
@ -167,11 +201,10 @@ bool UtilityAudioDecoderChild::CreateVideoBridge() {
return false;
}
nsTArray<gfx::GfxVarUpdate> updates = gfx::gfxVars::FetchNonDefaultVars();
gpuManager->InitVideoBridge(
std::move(parentPipe),
layers::VideoBridgeSource::MFMediaEngineCDMProcess);
SendInitVideoBridge(std::move(childPipe), updates, contentDeviceData);
SendInitVideoBridge(std::move(childPipe), contentDeviceData);
return true;
}
#endif

Просмотреть файл

@ -58,32 +58,7 @@ class UtilityAudioDecoderChild final : public PUtilityAudioDecoderChild
UtilityActorName GetActorName() { return GetAudioActorName(mSandbox); }
nsresult BindToUtilityProcess(RefPtr<UtilityProcessParent> aUtilityParent) {
Endpoint<PUtilityAudioDecoderChild> utilityAudioDecoderChildEnd;
Endpoint<PUtilityAudioDecoderParent> utilityAudioDecoderParentEnd;
nsresult rv = PUtilityAudioDecoder::CreateEndpoints(
aUtilityParent->OtherPid(), base::GetCurrentProcId(),
&utilityAudioDecoderParentEnd, &utilityAudioDecoderChildEnd);
if (NS_FAILED(rv)) {
MOZ_ASSERT(false, "Protocol endpoints failure");
return NS_ERROR_FAILURE;
}
if (!aUtilityParent->SendStartUtilityAudioDecoderService(
std::move(utilityAudioDecoderParentEnd))) {
MOZ_ASSERT(false, "StartUtilityAudioDecoder service failure");
return NS_ERROR_FAILURE;
}
Bind(std::move(utilityAudioDecoderChildEnd));
PROFILER_MARKER_UNTYPED(
"UtilityAudioDecoderChild::BindToUtilityProcess", IPC,
MarkerOptions(
MarkerTiming::IntervalUntilNowFrom(mAudioDecoderChildStart)));
return NS_OK;
}
nsresult BindToUtilityProcess(RefPtr<UtilityProcessParent> aUtilityParent);
void ActorDestroy(ActorDestroyReason aReason) override;

Просмотреть файл

@ -42,7 +42,8 @@
namespace mozilla::ipc {
UtilityAudioDecoderParent::UtilityAudioDecoderParent()
UtilityAudioDecoderParent::UtilityAudioDecoderParent(
nsTArray<gfx::GfxVarUpdate>&& aUpdates)
: mKind(GetCurrentSandboxingKind()),
mAudioDecoderParentStart(TimeStamp::Now()) {
#ifdef MOZ_WMF_MEDIA_ENGINE
@ -51,6 +52,9 @@ UtilityAudioDecoderParent::UtilityAudioDecoderParent()
profiler_set_process_name(nsCString("MF Media Engine CDM"));
gfx::gfxConfig::Init();
gfx::gfxVars::Initialize();
for (auto& update : aUpdates) {
gfx::gfxVars::ApplyUpdate(update);
}
gfx::DeviceManagerDx::Init();
return;
}
@ -141,7 +145,6 @@ UtilityAudioDecoderParent::RecvNewContentRemoteDecoderManager(
#ifdef MOZ_WMF_MEDIA_ENGINE
mozilla::ipc::IPCResult UtilityAudioDecoderParent::RecvInitVideoBridge(
Endpoint<PVideoBridgeChild>&& aEndpoint,
nsTArray<gfx::GfxVarUpdate>&& aUpdates,
const ContentDeviceData& aContentDeviceData) {
MOZ_ASSERT(mKind == SandboxingKind::MF_MEDIA_ENGINE_CDM);
if (!RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess(
@ -149,10 +152,6 @@ mozilla::ipc::IPCResult UtilityAudioDecoderParent::RecvInitVideoBridge(
return IPC_FAIL_NO_REASON(this);
}
for (const auto& update : aUpdates) {
gfx::gfxVars::ApplyUpdate(update);
}
gfx::gfxConfig::Inherit(
{
gfx::Feature::HW_COMPOSITING,
@ -175,6 +174,17 @@ mozilla::ipc::IPCResult UtilityAudioDecoderParent::RecvInitVideoBridge(
IPCResult UtilityAudioDecoderParent::RecvUpdateVar(
const GfxVarUpdate& aUpdate) {
MOZ_ASSERT(mKind == SandboxingKind::MF_MEDIA_ENGINE_CDM);
auto scopeExit = MakeScopeExit(
[self = RefPtr<UtilityAudioDecoderParent>{this},
location = GetRemoteDecodeInFromKind(mKind),
couldUseHWDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding()] {
if (couldUseHWDecoder != gfx::gfxVars::CanUseHardwareVideoDecoding()) {
// The capabilities of the system may have changed, force a refresh by
// re-initializing the PDM.
Unused << self->SendUpdateMediaCodecsSupported(
location, PDMFactory::Supported(true /* force refresh */));
}
});
gfx::gfxVars::ApplyUpdate(aUpdate);
return IPC_OK();
}

Просмотреть файл

@ -25,7 +25,8 @@ class UtilityAudioDecoderParent final : public PUtilityAudioDecoderParent {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UtilityAudioDecoderParent, override);
UtilityAudioDecoderParent();
explicit UtilityAudioDecoderParent(
nsTArray<mozilla::gfx::GfxVarUpdate>&& aUpdates);
static void GenericPreloadForSandbox();
static void WMFPreloadForSandbox();
@ -39,7 +40,6 @@ class UtilityAudioDecoderParent final : public PUtilityAudioDecoderParent {
#ifdef MOZ_WMF_MEDIA_ENGINE
mozilla::ipc::IPCResult RecvInitVideoBridge(
Endpoint<PVideoBridgeChild>&& aEndpoint,
nsTArray<mozilla::gfx::GfxVarUpdate>&& aUpdates,
const ContentDeviceData& aContentDeviceData);
IPCResult RecvUpdateVar(const mozilla::gfx::GfxVarUpdate& aUpdate);

Просмотреть файл

@ -261,11 +261,13 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvTestTelemetryProbes() {
mozilla::ipc::IPCResult
UtilityProcessChild::RecvStartUtilityAudioDecoderService(
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint) {
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint,
nsTArray<gfx::GfxVarUpdate>&& aUpdates) {
PROFILER_MARKER_UNTYPED(
"UtilityProcessChild::RecvStartUtilityAudioDecoderService", MEDIA,
MarkerOptions(MarkerTiming::IntervalUntilNowFrom(mChildStartTime)));
mUtilityAudioDecoderInstance = new UtilityAudioDecoderParent();
mUtilityAudioDecoderInstance =
new UtilityAudioDecoderParent(std::move(aUpdates));
if (!mUtilityAudioDecoderInstance) {
return IPC_FAIL(this, "Failed to create UtilityAudioDecoderParent");
}

Просмотреть файл

@ -63,7 +63,8 @@ class UtilityProcessChild final : public PUtilityProcessChild {
mozilla::ipc::IPCResult RecvTestTelemetryProbes();
mozilla::ipc::IPCResult RecvStartUtilityAudioDecoderService(
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint);
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint,
nsTArray<gfx::GfxVarUpdate>&& aUpdates);
mozilla::ipc::IPCResult RecvStartJSOracleService(
Endpoint<dom::PJSOracleChild>&& aEndpoint);