diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index d75373527abe2..aa775db9f914e 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1323,6 +1323,7 @@ void ContentChild::InitXPCOM( DataStorage::SetCachedStorageEntries(aXPCOMInit.dataStorage()); + PDMFactory::SetSupported(aXPCOMInit.codecsSupported()); // Initialize the RemoteDecoderManager thread and its associated PBackground // channel. RemoteDecoderManagerChild::Init(); @@ -4452,14 +4453,6 @@ IPCResult ContentChild::RecvFlushFOGData(FlushFOGDataResolver&& aResolver) { return IPC_OK(); } -IPCResult ContentChild::RecvUpdateMediaCodecsSupported( - RemoteDecodeIn aLocation, - const PDMFactory::MediaCodecsSupported& aSupported) { - RemoteDecoderManagerChild::SetSupported(aLocation, aSupported); - - return IPC_OK(); -} - } // namespace dom #if defined(__OpenBSD__) && defined(MOZ_SANDBOX) diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 61268002514d2..8eb110d970982 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -837,10 +837,6 @@ class ContentChild final : public PContentChild, private: mozilla::ipc::IPCResult RecvFlushFOGData(FlushFOGDataResolver&& aResolver); - mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported( - RemoteDecodeIn aLocation, - const PDMFactory::MediaCodecsSupported& aSupported); - #ifdef NIGHTLY_BUILD virtual PContentChild::Result OnMessageReceived(const Message& aMsg) override; #else diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 91c44e436c961..b397de10bbd6f 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -30,7 +30,6 @@ # include "mozilla/a11y/AccessibleWrap.h" # include "mozilla/a11y/Compatibility.h" #endif -#include #include #include "BrowserParent.h" @@ -38,6 +37,7 @@ #include "Geolocation.h" #include "GfxInfoBase.h" #include "MMPrinter.h" +#include "PDMFactory.h" #include "PreallocatedProcessManager.h" #include "ProcessPriorityManager.h" #include "SandboxHal.h" @@ -66,7 +66,6 @@ #include "mozilla/PresShell.h" #include "mozilla/ProcessHangMonitor.h" #include "mozilla/ProcessHangMonitorIPC.h" -#include "mozilla/RDDProcessManager.h" #include "mozilla/ScopeExit.h" #include "mozilla/ScriptPreloader.h" #include "mozilla/Services.h" @@ -368,9 +367,6 @@ namespace dom { LazyLogModule gProcessLog("Process"); -static std::map - sCodecsSupported; - /* static */ LogModule* ContentParent::GetLog() { return gProcessLog; } @@ -1505,16 +1501,6 @@ void ContentParent::BroadcastThemeUpdate(widget::ThemeChangeKind aKind) { } } -/*static */ -void ContentParent::BroadcastMediaCodecsSupportedUpdate( - RemoteDecodeIn aLocation, - const PDMFactory::MediaCodecsSupported& aSupported) { - sCodecsSupported[aLocation] = aSupported; - for (auto* cp : AllProcesses(eAll)) { - Unused << cp->SendUpdateMediaCodecsSupported(aLocation, aSupported); - } -} - const nsACString& ContentParent::GetRemoteType() const { return mRemoteType; } void ContentParent::Init() { @@ -2802,9 +2788,9 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) { // Send the dynamic scalar definitions to the new process. TelemetryIPC::GetDynamicScalarDefinitions(xpcomInit.dynamicScalarDefs()); - for (auto const& [location, supported] : sCodecsSupported) { - Unused << SendUpdateMediaCodecsSupported(location, supported); - } + // Pre-calculate the various PlatformDecoderModule (PDM) supported on this + // machine. + xpcomInit.codecsSupported() = PDMFactory::Supported(); // Must send screen info before send initialData ScreenManager& screenManager = ScreenManager::GetSingleton(); @@ -2903,12 +2889,6 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) { gpm->AddListener(this); - if (StaticPrefs::media_rdd_process_enabled()) { - // Ensure the RDD process has been started. - RDDProcessManager* rdd = RDDProcessManager::Get(); - rdd->LaunchRDDProcess(); - } - nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance(); if (sheetService) { // This looks like a lot of work, but in a normal browser session we just diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index a7d56ea53797c..4ce71ad6f6671 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -257,10 +257,6 @@ class ContentParent final static void BroadcastThemeUpdate(widget::ThemeChangeKind); - static void BroadcastMediaCodecsSupportedUpdate( - RemoteDecodeIn aLocation, - const PDMFactory::MediaCodecsSupported& aSupported); - const nsACString& GetRemoteType() const override; virtual void DoGetRemoteType(nsACString& aRemoteType, diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index b36570ea0e327..18c8fa3bdb59b 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -146,7 +146,6 @@ using class mozilla::dom::SessionHistoryInfo from "mozilla/dom/SessionHistoryEnt using struct nsPoint from "nsPoint.h"; using struct mozilla::dom::LoadingSessionHistoryInfo from "mozilla/dom/SessionHistoryEntry.h"; using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h"; -using mozilla::RemoteDecodeIn from "mozilla/RemoteDecoderManagerChild.h"; using mozilla::dom::PerformanceTimingData from "mozilla/dom/PerformanceTiming.h"; union ChromeRegistryItem @@ -328,6 +327,7 @@ struct XPCOMInitData nsCString[] requestedLocales; DynamicScalarDefinition[] dynamicScalarDefs; SystemParameterKVPair[] systemParameters; + MediaCodecsSupported codecsSupported; }; struct VisitedQueryResult @@ -947,9 +947,6 @@ child: async DispatchBeforeUnloadToSubtree(MaybeDiscardedBrowsingContext aStartingAt) returns (PermitUnloadResult result); - // Update the cached list of codec supported in the given process. - async UpdateMediaCodecsSupported(RemoteDecodeIn aLocation, MediaCodecsSupported aSupported); - parent: /** * This is a temporary way to pass index and length through parent process. diff --git a/dom/media/ipc/PRDD.ipdl b/dom/media/ipc/PRDD.ipdl index e2898f4cab77a..38ff9d8c8b2e6 100644 --- a/dom/media/ipc/PRDD.ipdl +++ b/dom/media/ipc/PRDD.ipdl @@ -15,7 +15,6 @@ using mozilla::dom::NativeThreadId from "mozilla/dom/NativeThreadId.h"; using moveonly mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h"; using moveonly mozilla::ModulePaths from "mozilla/UntrustedModulesData.h"; using moveonly mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h"; -using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h"; namespace mozilla { @@ -59,10 +58,6 @@ child: async GetModulesTrust(ModulePaths aModPaths, bool aRunAtNormalPriority) returns (ModulesMapResult? modMapResult); - - // Update the cached list of codec supported following a check in the - // RDD parent. - async UpdateMediaCodecsSupported(MediaCodecsSupported aSupported); }; } // namespace mozilla diff --git a/dom/media/ipc/RDDChild.cpp b/dom/media/ipc/RDDChild.cpp index 5d51a49b30d61..f37da980b5726 100644 --- a/dom/media/ipc/RDDChild.cpp +++ b/dom/media/ipc/RDDChild.cpp @@ -6,12 +6,11 @@ #include "RDDChild.h" #include "mozilla/RDDProcessManager.h" -#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/MemoryReportRequest.h" -#include "mozilla/gfx/GPUProcessManager.h" -#include "mozilla/gfx/gfxVars.h" #include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/Endpoint.h" +#include "mozilla/gfx/gfxVars.h" +#include "mozilla/gfx/GPUProcessManager.h" #if defined(XP_LINUX) && defined(MOZ_SANDBOX) # include "mozilla/SandboxBroker.h" @@ -139,13 +138,6 @@ mozilla::ipc::IPCResult RDDChild::RecvGetModulesTrust( #endif // defined(XP_WIN) } -mozilla::ipc::IPCResult RDDChild::RecvUpdateMediaCodecsSupported( - const PDMFactory::MediaCodecsSupported& aSupported) { - dom::ContentParent::BroadcastMediaCodecsSupportedUpdate( - RemoteDecodeIn::RddProcess, aSupported); - return IPC_OK(); -} - void RDDChild::ActorDestroy(ActorDestroyReason aWhy) { if (aWhy == AbnormalShutdown) { GenerateCrashReport(OtherPid()); diff --git a/dom/media/ipc/RDDChild.h b/dom/media/ipc/RDDChild.h index af90afe11e048..a060fa121376a 100644 --- a/dom/media/ipc/RDDChild.h +++ b/dom/media/ipc/RDDChild.h @@ -6,10 +6,11 @@ #ifndef _include_dom_media_ipc_RDDChild_h_ #define _include_dom_media_ipc_RDDChild_h_ #include "mozilla/PRDDChild.h" + +#include "mozilla/ipc/CrashReporterHelper.h" #include "mozilla/UniquePtr.h" -#include "mozilla/gfx/GPUProcessListener.h" #include "mozilla/gfx/gfxVarReceiver.h" -#include "mozilla/ipc/CrashReporterHelper.h" +#include "mozilla/gfx/GPUProcessListener.h" namespace mozilla { @@ -44,8 +45,6 @@ class RDDChild final : public PRDDChild, mozilla::ipc::IPCResult RecvGetModulesTrust( ModulePaths&& aModPaths, bool aRunAtNormalPriority, GetModulesTrustResolver&& aResolver); - mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported( - const PDMFactory::MediaCodecsSupported& aSupported); bool SendRequestMemoryReport(const uint32_t& aGeneration, const bool& aAnonymize, diff --git a/dom/media/ipc/RDDParent.cpp b/dom/media/ipc/RDDParent.cpp index 9bbd5ae18cb75..6c1a6a9c02537 100644 --- a/dom/media/ipc/RDDParent.cpp +++ b/dom/media/ipc/RDDParent.cpp @@ -6,31 +6,27 @@ #include "RDDParent.h" #if defined(XP_WIN) -# include -# include - +# include "mozilla/gfx/DeviceManagerDx.h" # include "WMF.h" -# include "WMFDecoderModule.h" +# include +# include # include "mozilla/WinDllServices.h" -# include "mozilla/gfx/DeviceManagerDx.h" #else # include #endif -#include "PDMFactory.h" #include "chrome/common/ipc_channel.h" -#include "gfxConfig.h" #include "mozilla/Assertions.h" #include "mozilla/HangDetails.h" #include "mozilla/Preferences.h" #include "mozilla/RemoteDecoderManagerChild.h" #include "mozilla/RemoteDecoderManagerParent.h" -#include "mozilla/ScopeExit.h" #include "mozilla/TimeStamp.h" #include "mozilla/dom/MemoryReportRequest.h" -#include "mozilla/gfx/gfxVars.h" #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" +#include "mozilla/gfx/gfxVars.h" +#include "gfxConfig.h" #if defined(XP_LINUX) && defined(MOZ_SANDBOX) # include "mozilla/Sandbox.h" @@ -41,14 +37,14 @@ #endif #if defined(XP_MACOSX) && defined(MOZ_SANDBOX) -# include "RDDProcessHost.h" # include "mozilla/Sandbox.h" # include "nsMacUtilsImpl.h" +# include "RDDProcessHost.h" #endif -#include "ProcessUtils.h" #include "nsDebugImpl.h" #include "nsThreadManager.h" +#include "ProcessUtils.h" namespace mozilla { @@ -124,9 +120,6 @@ mozilla::ipc::IPCResult RDDParent::RecvInit( gfxVars::ApplyUpdate(var); } - auto supported = PDMFactory::Supported(); - Unused << SendUpdateMediaCodecsSupported(supported); - #if defined(MOZ_SANDBOX) # if defined(XP_MACOSX) // Close all current connections to the WindowServer. This ensures that the @@ -153,18 +146,6 @@ mozilla::ipc::IPCResult RDDParent::RecvInit( } IPCResult RDDParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { -#if defined(XP_WIN) - auto scopeExit = MakeScopeExit( - [couldUseHWDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding()] { - if (couldUseHWDecoder != gfx::gfxVars::CanUseHardwareVideoDecoding()) { - // The capabilities of the system may have changed, force a refresh by - // re-initializing the WMF PDM. - WMFDecoderModule::Init(); - Unused << RDDParent::GetSingleton()->SendUpdateMediaCodecsSupported( - PDMFactory::Supported(true /* force refresh */)); - } - }); -#endif gfxVars::ApplyUpdate(aUpdate); return IPC_OK(); } diff --git a/dom/media/ipc/RDDProcessManager.cpp b/dom/media/ipc/RDDProcessManager.cpp index b9aa7c06ad6dd..f34811fdc1bd3 100644 --- a/dom/media/ipc/RDDProcessManager.cpp +++ b/dom/media/ipc/RDDProcessManager.cpp @@ -100,96 +100,75 @@ void RDDProcessManager::OnPreferenceChange(const char16_t* aData) { } } -RefPtr RDDProcessManager::LaunchRDDProcess() { - MOZ_ASSERT(NS_IsMainThread()); - - if (!Get()) { - // Shutdown? - return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, - __func__); - } - - if (mNumProcessAttempts && !StaticPrefs::media_rdd_retryonfailure_enabled()) { - // We failed to start the RDD process earlier, abort now. - return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, - __func__); - } - - if (mLaunchRDDPromise && mProcess) { - return mLaunchRDDPromise; - } - - std::vector extraArgs; - nsCString parentBuildID(mozilla::PlatformBuildID()); - extraArgs.push_back("-parentBuildID"); - extraArgs.push_back(parentBuildID.get()); - - // The subprocess is launched asynchronously, so we - // wait for the promise to be resolved to acquire the IPDL actor. - mProcess = new RDDProcessHost(this); - if (!mProcess->Launch(extraArgs)) { - mNumProcessAttempts++; - DestroyProcess(); - return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, - __func__); - } - - mLaunchRDDPromise = mProcess->LaunchPromise()->Then( +auto RDDProcessManager::EnsureRDDProcessAndCreateBridge( + base::ProcessId aOtherProcess) -> RefPtr { + return InvokeAsync( GetMainThreadSerialEventTarget(), __func__, - [this](bool) { + [aOtherProcess, this]() -> RefPtr { if (!Get()) { // Shutdown? - return GenericNonExclusivePromise::CreateAndReject( - NS_ERROR_NOT_AVAILABLE, __func__); + return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, + __func__); } - - mRDDChild = mProcess->GetActor(); - mProcessToken = mProcess->GetProcessToken(); - - // Flush any pref updates that happened during - // launch and weren't included in the blobs set - // up in LaunchRDDProcess. - for (const mozilla::dom::Pref& pref : mQueuedPrefs) { - Unused << NS_WARN_IF(!mRDDChild->SendPreferenceUpdate(pref)); + if (mProcess) { + return mProcess->LaunchPromise()->Then( + GetMainThreadSerialEventTarget(), __func__, + [aOtherProcess, this](bool) { + ipc::Endpoint endpoint; + if (!CreateContentBridge(aOtherProcess, &endpoint)) { + return EnsureRDDPromise::CreateAndReject( + NS_ERROR_NOT_AVAILABLE, __func__); + } + return EnsureRDDPromise::CreateAndResolve(std::move(endpoint), + __func__); + }, + [](nsresult aError) { + return EnsureRDDPromise::CreateAndReject(aError, __func__); + }); } - mQueuedPrefs.Clear(); - CrashReporter::AnnotateCrashReport( - CrashReporter::Annotation::RDDProcessStatus, "Running"_ns); - - if (!CreateVideoBridge()) { - mNumProcessAttempts++; - DestroyProcess(); - return GenericNonExclusivePromise::CreateAndReject( - NS_ERROR_NOT_AVAILABLE, __func__); + if (mNumProcessAttempts && + !StaticPrefs::media_rdd_retryonfailure_enabled()) { + // We failed to start the RDD process earlier, abort now. + return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, + __func__); } - return GenericNonExclusivePromise::CreateAndResolve(true, __func__); - }, - [this](nsresult aError) { - if (Get()) { - mNumProcessAttempts++; + // Launch the RDD process. + std::vector extraArgs; + nsCString parentBuildID(mozilla::PlatformBuildID()); + extraArgs.push_back("-parentBuildID"); + extraArgs.push_back(parentBuildID.get()); + + // The subprocess is launched asynchronously, so we + // wait for the promise to be resolved to acquire the IPDL actor. + mProcess = new RDDProcessHost(this); + if (!mProcess->Launch(extraArgs)) { DestroyProcess(); + return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, + __func__); } - return GenericNonExclusivePromise::CreateAndReject(aError, __func__); - }); - return mLaunchRDDPromise; -} - -auto RDDProcessManager::EnsureRDDProcessAndCreateBridge( - base::ProcessId aOtherProcess) -> RefPtr { - return InvokeAsync( - GetMainThreadSerialEventTarget(), __func__, - [aOtherProcess, this]() -> RefPtr { - return LaunchRDDProcess()->Then( + return mProcess->LaunchPromise()->Then( GetMainThreadSerialEventTarget(), __func__, - [aOtherProcess, this]() { - if (!Get()) { - // Shutdown? - return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, - __func__); + [aOtherProcess, this](bool) { + mRDDChild = mProcess->GetActor(); + mProcessToken = mProcess->GetProcessToken(); + + // Flush any pref updates that happened during + // launch and weren't included in the blobs set + // up in LaunchRDDProcess. + for (const mozilla::dom::Pref& pref : mQueuedPrefs) { + Unused << NS_WARN_IF(!mRDDChild->SendPreferenceUpdate(pref)); } + mQueuedPrefs.Clear(); + + CrashReporter::AnnotateCrashReport( + CrashReporter::Annotation::RDDProcessStatus, "Running"_ns); + ipc::Endpoint endpoint; - if (!CreateContentBridge(aOtherProcess, &endpoint)) { + + if (!CreateVideoBridge() || + !CreateContentBridge(aOtherProcess, &endpoint)) { + mNumProcessAttempts++; return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, __func__); } @@ -197,7 +176,9 @@ auto RDDProcessManager::EnsureRDDProcessAndCreateBridge( return EnsureRDDPromise::CreateAndResolve(std::move(endpoint), __func__); }, - [](nsresult aError) { + [this](nsresult aError) { + mNumProcessAttempts++; + DestroyProcess(); return EnsureRDDPromise::CreateAndReject(aError, __func__); }); }); @@ -286,11 +267,6 @@ bool RDDProcessManager::CreateVideoBridge() { GPUProcessManager* gpuManager = GPUProcessManager::Get(); base::ProcessId gpuProcessPid = gpuManager ? gpuManager->GPUProcessPid() : -1; - // Build content device data first; this ensure that the GPU process is fully - // ready. - ContentDeviceData contentDeviceData; - gfxPlatform::GetPlatform()->BuildContentDeviceData(&contentDeviceData); - // The child end is the producer of video frames; the parent end is the // consumer. base::ProcessId childPid = RDDProcessPid(); @@ -302,9 +278,13 @@ bool RDDProcessManager::CreateVideoBridge() { if (NS_FAILED(rv)) { MOZ_LOG(sPDMLog, LogLevel::Debug, ("Could not create video bridge: %d", int(rv))); + DestroyProcess(); return false; } + ContentDeviceData contentDeviceData; + gfxPlatform::GetPlatform()->BuildContentDeviceData(&contentDeviceData); + mRDDChild->SendInitVideoBridge(std::move(childPipe), mNumUnexpectedCrashes == 0, contentDeviceData); if (gpuProcessPid != -1) { diff --git a/dom/media/ipc/RDDProcessManager.h b/dom/media/ipc/RDDProcessManager.h index 0204eba3734b6..587d4d2d70c53 100644 --- a/dom/media/ipc/RDDProcessManager.h +++ b/dom/media/ipc/RDDProcessManager.h @@ -31,8 +31,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener { using EnsureRDDPromise = MozPromise, nsresult, true>; - // Launch a new RDD process asynchronously - RefPtr LaunchRDDProcess(); // If not using a RDD process, launch a new RDD process asynchronously and // create a RemoteDecoderManager bridge RefPtr EnsureRDDProcessAndCreateBridge( @@ -106,9 +104,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener { // the initial map is passed in command-line arguments) to be sent // when the process can receive IPC messages. nsTArray mQueuedPrefs; - // Promise will be resolved when the RDD process has been fully started and - // VideoBridge configured. Only accessed on the main thread. - RefPtr mLaunchRDDPromise; }; } // namespace mozilla diff --git a/dom/media/ipc/RemoteDecoderManagerChild.cpp b/dom/media/ipc/RemoteDecoderManagerChild.cpp index 4db6a9e7e4c7b..eb22620d01503 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.cpp +++ b/dom/media/ipc/RemoteDecoderManagerChild.cpp @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "RemoteDecoderManagerChild.h" -#include "PDMFactory.h" #include "RemoteAudioDecoder.h" #include "RemoteMediaDataDecoder.h" #include "RemoteVideoDecoder.h" @@ -46,11 +45,6 @@ static StaticRefPtr sRemoteDecoderManagerChildForGPUProcess; static UniquePtr>> sRecreateTasks; -static StaticDataMutex> sGPUSupported( - "RDMC::sGPUSupported"); -static StaticDataMutex> sRDDSupported( - "RDMC::sRDDSupported"); - class ShutdownObserver final : public nsIObserver { public: NS_DECL_ISUPPORTS @@ -196,30 +190,18 @@ nsISerialEventTarget* RemoteDecoderManagerChild::GetManagerThread() { bool RemoteDecoderManagerChild::Supports( RemoteDecodeIn aLocation, const SupportDecoderParams& aParams, DecoderDoctorDiagnostics* aDiagnostics) { - Maybe supported; + RefPtr pdm; switch (aLocation) { - case RemoteDecodeIn::RddProcess: { - auto supportedRDD = sRDDSupported.Lock(); - supported = *supportedRDD; + case RemoteDecodeIn::RddProcess: + pdm = PDMFactory::PDMFactoryForRdd(); break; - } - case RemoteDecodeIn::GpuProcess: { - auto supportedGPU = sGPUSupported.Lock(); - supported = *supportedGPU; + case RemoteDecodeIn::GpuProcess: + pdm = PDMFactory::PDMFactoryForGpu(); break; - } default: return false; } - if (!supported) { - // We haven't received the correct information yet from either the GPU or - // the RDD process; assume it is supported to prevent false negative. - return true; - } - - // We can ignore the SupportDecoderParams argument for now as creation of the - // decoder will actually fail later and fallback PDMs will be tested on later. - return PDMFactory::SupportsMimeType(aParams.MimeType(), *supported); + return pdm->Supports(aParams, aDiagnostics); } /* static */ @@ -592,23 +574,4 @@ void RemoteDecoderManagerChild::HandleFatalError(const char* aMsg) const { dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid()); } -void RemoteDecoderManagerChild::SetSupported( - RemoteDecodeIn aLocation, - const PDMFactory::MediaCodecsSupported& aSupported) { - switch (aLocation) { - case RemoteDecodeIn::GpuProcess: { - auto supported = sGPUSupported.Lock(); - *supported = Some(aSupported); - break; - } - case RemoteDecodeIn::RddProcess: { - auto supported = sRDDSupported.Lock(); - *supported = Some(aSupported); - break; - } - default: - MOZ_CRASH("Not to be used for any other process"); - } -} - } // namespace mozilla diff --git a/dom/media/ipc/RemoteDecoderManagerChild.h b/dom/media/ipc/RemoteDecoderManagerChild.h index ea65ebc86f825..d19978d735481 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.h +++ b/dom/media/ipc/RemoteDecoderManagerChild.h @@ -5,10 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef include_dom_media_ipc_RemoteDecoderManagerChild_h #define include_dom_media_ipc_RemoteDecoderManagerChild_h - #include "GPUVideoImage.h" -#include "ipc/EnumSerializer.h" -#include "mozilla/EnumTypeTraits.h" #include "mozilla/PRemoteDecoderManagerChild.h" #include "mozilla/layers/VideoBridgeUtils.h" @@ -20,8 +17,6 @@ enum class RemoteDecodeIn { Unspecified, RddProcess, GpuProcess, - - SENTINEL, }; class RemoteDecoderManagerChild final @@ -37,8 +32,6 @@ class RemoteDecoderManagerChild final static RemoteDecoderManagerChild* GetSingleton(RemoteDecodeIn aLocation); static void Init(); - static void SetSupported(RemoteDecodeIn aLocation, - const PDMFactory::MediaCodecsSupported& aSupported); // Can be called from any thread. static bool Supports(RemoteDecodeIn aLocation, @@ -121,12 +114,4 @@ class RemoteDecoderManagerChild final } // namespace mozilla -namespace IPC { -template <> -struct ParamTraits - : public ContiguousEnumSerializer {}; -} // namespace IPC - #endif // include_dom_media_ipc_RemoteDecoderManagerChild_h diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index a49f15ea38505..7f89b03d9b07f 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -6,9 +6,6 @@ #include "PDMFactory.h" -#ifdef MOZ_AV1 -# include "AOMDecoder.h" -#endif #include "AgnosticDecoderModule.h" #include "AudioTrimmer.h" #include "BlankDecoderModule.h" @@ -19,12 +16,8 @@ #include "MP4Decoder.h" #include "MediaChangeMonitor.h" #include "MediaInfo.h" -#include "OpusDecoder.h" -#include "TheoraDecoder.h" -#include "VPXDecoder.h" #include "VideoUtils.h" -#include "VorbisDecoder.h" -#include "WAVDecoder.h" +#include "VPXDecoder.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/RemoteDecoderManagerChild.h" #include "mozilla/RemoteDecoderModule.h" @@ -61,6 +54,10 @@ namespace mozilla { +// Set on the main thread, in content processes before any PDMFactory will ever +// be created; never modified after. +static Maybe sSupported; + extern already_AddRefed CreateNullDecoderModule(); class PDMFactoryImpl final { @@ -71,6 +68,8 @@ class PDMFactoryImpl final { } else if (XRE_IsRDDProcess()) { InitRddPDMs(); } else if (XRE_IsContentProcess()) { + MOZ_DIAGNOSTIC_ASSERT(sSupported.isSome(), + "PDMFactory accessed while not initialized"); InitContentPDMs(); } else { MOZ_DIAGNOSTIC_ASSERT( @@ -232,6 +231,31 @@ PDMFactory::PDMFactory() { PDMFactory::~PDMFactory() = default; +PDMFactory::PDMFactory(const RemoteDecodeIn& aProcess) { + switch (aProcess) { + case RemoteDecodeIn::RddProcess: + CreateRddPDMs(); + break; + case RemoteDecodeIn::GpuProcess: + CreateGpuPDMs(); + break; + default: + MOZ_CRASH("Not to be used for any other process"); + } +} + +/* static */ +already_AddRefed PDMFactory::PDMFactoryForRdd() { + RefPtr pdm = new PDMFactory(RemoteDecodeIn::RddProcess); + return pdm.forget(); +} + +/* static */ +already_AddRefed PDMFactory::PDMFactoryForGpu() { + RefPtr pdm = new PDMFactory(RemoteDecodeIn::GpuProcess); + return pdm.forget(); +} + /* static */ void PDMFactory::EnsureInit() { { @@ -390,6 +414,15 @@ bool PDMFactory::Supports(const SupportDecoderParams& aParams, if (mEMEPDM) { return mEMEPDM->Supports(aParams, aDiagnostics); } + if (VPXDecoder::IsVPX(aParams.MimeType(), + VPXDecoder::VP8 | VPXDecoder::VP9) && + !aParams.mConfig.GetAsVideoInfo()->HasAlpha()) { + // Work around bug 1521370, where trying to instantiate an external decoder + // could cause a crash. + // We always ship a VP8/VP9 decoder (libvpx) and optionally we have ffvpx. + // So we can speed up the test by assuming that this codec is supported. + return true; + } RefPtr current = GetDecoderModule(aParams, aDiagnostics); @@ -609,10 +642,13 @@ void PDMFactory::SetCDMProxy(CDMProxy* aProxy) { } /* static */ -PDMFactory::MediaCodecsSupported PDMFactory::Supported(bool aForceRefresh) { - MOZ_ASSERT(NS_IsMainThread()); +PDMFactory::MediaCodecsSupported PDMFactory::Supported() { + if (XRE_IsContentProcess()) { + return *sSupported; + } + MOZ_ASSERT(XRE_IsParentProcess()); - static auto calculate = []() { + static MediaCodecsSupported supported = []() { auto pdm = MakeRefPtr(); MediaCodecsSupported supported; // H264 and AAC depends on external framework that must be dynamically @@ -626,18 +662,6 @@ PDMFactory::MediaCodecsSupported PDMFactory::Supported(bool aForceRefresh) { if (pdm->SupportsMimeType("video/avc"_ns, nullptr)) { supported += MediaCodecs::H264; } - if (pdm->SupportsMimeType("video/vp9"_ns, nullptr)) { - supported += MediaCodecs::VP9; - } - if (pdm->SupportsMimeType("video/vp8"_ns, nullptr)) { - supported += MediaCodecs::VP8; - } - if (pdm->SupportsMimeType("video/av1"_ns, nullptr)) { - supported += MediaCodecs::AV1; - } - if (pdm->SupportsMimeType("video/theora"_ns, nullptr)) { - supported += MediaCodecs::Theora; - } if (pdm->SupportsMimeType("audio/mp4a-latm"_ns, nullptr)) { supported += MediaCodecs::AAC; } @@ -645,64 +669,28 @@ PDMFactory::MediaCodecsSupported PDMFactory::Supported(bool aForceRefresh) { if (pdm->SupportsMimeType("audio/mpeg"_ns, nullptr)) { supported += MediaCodecs::MP3; } - if (pdm->SupportsMimeType("audio/opus"_ns, nullptr)) { - supported += MediaCodecs::Opus; - } - if (pdm->SupportsMimeType("audio/vorbis"_ns, nullptr)) { - supported += MediaCodecs::Vorbis; - } - if (pdm->SupportsMimeType("audio/flac"_ns, nullptr)) { - supported += MediaCodecs::Flac; - } - if (pdm->SupportsMimeType("audio/x-wav"_ns, nullptr)) { - supported += MediaCodecs::Wave; - } + // The codecs below are potentially always supported as we ship native + // support for them. If they are disabled through pref, it will be handled + // in MediaDecoder class that could use those. + supported += MediaCodecs::VP9; + supported += MediaCodecs::VP8; + supported += MediaCodecs::AV1; + supported += MediaCodecs::Theora; + supported += MediaCodecs::Opus; + supported += MediaCodecs::Vorbis; + supported += MediaCodecs::Flac; + supported += MediaCodecs::Wave; + return supported; - }; - static MediaCodecsSupported supported = calculate(); - if (aForceRefresh) { - supported = calculate(); - } + }(); return supported; } /* static */ -bool PDMFactory::SupportsMimeType(const nsACString& aMimeType, - const MediaCodecsSupported& aSupported) { - if (MP4Decoder::IsH264(aMimeType)) { - return aSupported.contains(MediaCodecs::H264); - } - if (VPXDecoder::IsVP9(aMimeType)) { - return aSupported.contains(MediaCodecs::VP9); - } - if (VPXDecoder::IsVP8(aMimeType)) { - return aSupported.contains(MediaCodecs::VP8); - } - if (AOMDecoder::IsAV1(aMimeType)) { - return aSupported.contains(MediaCodecs::AV1); - } - if (TheoraDecoder::IsTheora(aMimeType)) { - return aSupported.contains(MediaCodecs::Theora); - } - if (MP4Decoder::IsAAC(aMimeType)) { - return aSupported.contains(MediaCodecs::AAC); - } - if (aMimeType.EqualsLiteral("audio/mpeg")) { - return aSupported.contains(MediaCodecs::MP3); - } - if (OpusDataDecoder::IsOpus(aMimeType)) { - return aSupported.contains(MediaCodecs::Opus); - } - if (VorbisDataDecoder::IsVorbis(aMimeType)) { - return aSupported.contains(MediaCodecs::Vorbis); - } - if (aMimeType.EqualsLiteral("audio/flac")) { - return aSupported.contains(MediaCodecs::Flac); - } - if (WaveDataDecoder::IsWave(aMimeType)) { - return aSupported.contains(MediaCodecs::Wave); - } - return false; +void PDMFactory::SetSupported(const MediaCodecsSupported& aSupported) { + MOZ_ASSERT(NS_IsMainThread()); + + sSupported = Some(aSupported); } } // namespace mozilla diff --git a/dom/media/platforms/PDMFactory.h b/dom/media/platforms/PDMFactory.h index 3194e28d8d578..83d835cc7f63f 100644 --- a/dom/media/platforms/PDMFactory.h +++ b/dom/media/platforms/PDMFactory.h @@ -44,6 +44,11 @@ class PDMFactory final { PDMFactory(); + // To be called in the content process only, used to determine which PDMs are + // usable in their respective process. + static already_AddRefed PDMFactoryForRdd(); + static already_AddRefed PDMFactoryForGpu(); + // Factory method that creates the appropriate PlatformDecoderModule for // the platform we're running on. RefPtr CreateDecoder( @@ -87,12 +92,15 @@ class PDMFactory final { using MediaCodecsSupported = EnumSet; - static MediaCodecsSupported Supported(bool aForceRefresh = false); - static bool SupportsMimeType(const nsACString& aMimeType, - const MediaCodecsSupported& aSupported); + static MediaCodecsSupported Supported(); + static void SetSupported(const MediaCodecsSupported& aSupported); private: virtual ~PDMFactory(); + // Will set PDM list for the required process. + // This is used to determine which PDMs are available on the given process + // from the content process. + explicit PDMFactory(const RemoteDecodeIn& aProcess); void CreatePDMs(); void CreateNullPDM(); diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h index 2d5ec7a54b1a3..4dd62fad21c25 100644 --- a/dom/media/platforms/PlatformDecoderModule.h +++ b/dom/media/platforms/PlatformDecoderModule.h @@ -315,8 +315,6 @@ class PlatformDecoderModule { virtual nsresult Startup() { return NS_OK; } // Indicates if the PlatformDecoderModule supports decoding of aMimeType. - // The answer to both SupportsMimeType and Supports doesn't guarantee that - // creation of a decoder will actually succeed. virtual bool SupportsMimeType( const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const = 0; diff --git a/dom/media/platforms/apple/AppleDecoderModule.cpp b/dom/media/platforms/apple/AppleDecoderModule.cpp index 16520efd13ae5..55625b5d5402e 100644 --- a/dom/media/platforms/apple/AppleDecoderModule.cpp +++ b/dom/media/platforms/apple/AppleDecoderModule.cpp @@ -15,6 +15,7 @@ #include "mozilla/DebugOnly.h" #include "mozilla/Logging.h" #include "mozilla/StaticPrefs_media.h" +#include "mozilla/gfx/gfxVars.h" extern "C" { // Only exists from MacOS 11 @@ -27,6 +28,7 @@ extern Boolean VTIsHardwareDecodeSupported(CMVideoCodecType codecType) namespace mozilla { bool AppleDecoderModule::sInitialized = false; +bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true; bool AppleDecoderModule::sCanUseVP9Decoder = false; /* static */ @@ -35,6 +37,8 @@ void AppleDecoderModule::Init() { return; } + sCanUseHardwareVideoDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding(); + sInitialized = true; if (RegisterSupplementalVP9Decoder()) { sCanUseVP9Decoder = CanCreateVP9Decoder(); @@ -130,7 +134,7 @@ bool AppleDecoderModule::CanCreateVP9Decoder() { // warning as VTIsHardwareDecodeSupported is only available from macOS 10.13. if (__builtin_available(macOS 10.13, *)) { // Only use VP9 decoder if it's hardware accelerated. - if (!VTIsHardwareDecodeSupported || + if (!sCanUseHardwareVideoDecoder || !VTIsHardwareDecodeSupported || !VTIsHardwareDecodeSupported(kCMVideoCodecType_VP9)) { return false; } diff --git a/dom/media/platforms/apple/AppleDecoderModule.h b/dom/media/platforms/apple/AppleDecoderModule.h index 2f1dcb7430df1..2e444ac9d517f 100644 --- a/dom/media/platforms/apple/AppleDecoderModule.h +++ b/dom/media/platforms/apple/AppleDecoderModule.h @@ -36,6 +36,7 @@ class AppleDecoderModule : public PlatformDecoderModule { static void Init(); + static bool sCanUseHardwareVideoDecoder; static bool sCanUseVP9Decoder; static constexpr int kCMVideoCodecType_VP9{'vp09'}; diff --git a/dom/media/platforms/apple/AppleVTDecoder.cpp b/dom/media/platforms/apple/AppleVTDecoder.cpp index 7969a373bd199..42e918c64eb74 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -21,7 +21,6 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Logging.h" #include "mozilla/TaskQueue.h" -#include "mozilla/gfx/gfxVars.h" #include "nsThreadUtils.h" #define LOG(...) DDMOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, __VA_ARGS__) @@ -582,7 +581,7 @@ CFDictionaryRef AppleVTDecoder::CreateDecoderSpecification() { const void* specKeys[] = { kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder}; const void* specValues[1]; - if (gfx::gfxVars::CanUseHardwareVideoDecoding()) { + if (AppleDecoderModule::sCanUseHardwareVideoDecoder) { specValues[0] = kCFBooleanTrue; } else { // This GPU is blacklisted for hardware decoding. diff --git a/dom/media/platforms/wmf/WMFDecoderModule.cpp b/dom/media/platforms/wmf/WMFDecoderModule.cpp index 64e14675f9da1..acd6f553617e3 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.cpp +++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp @@ -68,16 +68,15 @@ WMFDecoderModule::~WMFDecoderModule() { } } -static bool IsRemoteAcceleratedCompositor( - layers::KnowsCompositor* aKnowsCompositor) { - if (!aKnowsCompositor) { +static bool IsRemoteAcceleratedCompositor(const SupportDecoderParams& aParams) { + if (!aParams.mKnowsCompositor) { return false; } TextureFactoryIdentifier ident = - aKnowsCompositor->GetTextureFactoryIdentifier(); + aParams.mKnowsCompositor->GetTextureFactoryIdentifier(); return ident.mParentBackend != LayersBackend::LAYERS_BASIC && - !aKnowsCompositor->UsingSoftwareWebRender() && + !aParams.mKnowsCompositor->UsingSoftwareWebRender() && ident.mParentProcessType == GeckoProcessType_GPU; } @@ -173,13 +172,6 @@ nsresult WMFDecoderModule::Startup() { already_AddRefed WMFDecoderModule::CreateVideoDecoder( const CreateDecoderParams& aParams) { - // In GPU process, only support decoding if an accelerated compositor is - // known. - if (XRE_IsGPUProcess() && - !IsRemoteAcceleratedCompositor(aParams.mKnowsCompositor)) { - return nullptr; - } - UniquePtr manager(new WMFVideoMFTManager( aParams.VideoConfig(), aParams.mKnowsCompositor, aParams.mImageContainer, aParams.mRate.mValue, aParams.mOptions, sDXVAEnabled)); @@ -209,11 +201,6 @@ already_AddRefed WMFDecoderModule::CreateVideoDecoder( already_AddRefed WMFDecoderModule::CreateAudioDecoder( const CreateDecoderParams& aParams) { - if (XRE_IsGPUProcess()) { - // Only allow video in the GPU process. - return nullptr; - } - UniquePtr manager( new WMFAudioMFTManager(aParams.AudioConfig())); @@ -249,26 +236,41 @@ static bool CanCreateWMFDecoder() { /* static */ bool WMFDecoderModule::HasH264() { + if (XRE_IsContentProcess()) { + return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::H264); + } return CanCreateWMFDecoder(); } /* static */ bool WMFDecoderModule::HasVP8() { + if (XRE_IsContentProcess()) { + return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::VP8); + } return sUsableVPXMFT && CanCreateWMFDecoder(); } /* static */ bool WMFDecoderModule::HasVP9() { + if (XRE_IsContentProcess()) { + return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::VP9); + } return sUsableVPXMFT && CanCreateWMFDecoder(); } /* static */ bool WMFDecoderModule::HasAAC() { + if (XRE_IsContentProcess()) { + return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::AAC); + } return CanCreateWMFDecoder(); } /* static */ bool WMFDecoderModule::HasMP3() { + if (XRE_IsContentProcess()) { + return PDMFactory::Supported().contains(PDMFactory::MediaCodecs::MP3); + } return CanCreateWMFDecoder(); } @@ -283,14 +285,13 @@ bool WMFDecoderModule::SupportsMimeType( bool WMFDecoderModule::Supports(const SupportDecoderParams& aParams, DecoderDoctorDiagnostics* aDiagnostics) const { - // In GPU process, only support decoding if video. This only gives a hint of - // what the GPU decoder *may* support. The actual check will occur in - // CreateVideoDecoder. - const auto& trackInfo = aParams.mConfig; - if (XRE_IsGPUProcess() && !trackInfo.GetAsVideoInfo()) { + // In GPU process, only support decoding if an accelerated compositor is + // known. + if (XRE_IsGPUProcess() && !IsRemoteAcceleratedCompositor(aParams)) { return false; } + const auto& trackInfo = aParams.mConfig; const auto* videoInfo = trackInfo.GetAsVideoInfo(); // Temporary - forces use of VPXDecoder when alpha is present. // Bug 1263836 will handle alpha scenario once implemented. It will shift diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index aed77d6281384..547fc66e7b892 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -4,29 +4,26 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GPUChild.h" - +#include "gfxConfig.h" +#include "GfxInfoBase.h" +#include "gfxPlatform.h" #include "GPUProcessHost.h" #include "GPUProcessManager.h" -#include "GfxInfoBase.h" #include "VRProcessManager.h" -#include "gfxConfig.h" -#include "gfxPlatform.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/Telemetry.h" #include "mozilla/TelemetryIPC.h" #include "mozilla/dom/CheckerboardReportService.h" -#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/gfx/gfxVars.h" #if defined(XP_WIN) # include "mozilla/gfx/DeviceManagerDx.h" #endif -#include "mozilla/HangDetails.h" -#include "mozilla/RemoteDecoderManagerChild.h" // For RemoteDecodeIn -#include "mozilla/Unused.h" #include "mozilla/ipc/Endpoint.h" #include "mozilla/layers/APZInputBridgeChild.h" #include "mozilla/layers/LayerTreeOwnerTracker.h" +#include "mozilla/Unused.h" +#include "mozilla/HangDetails.h" #include "nsIGfxInfo.h" #include "nsIObserverService.h" @@ -300,13 +297,6 @@ mozilla::ipc::IPCResult GPUChild::RecvBHRThreadHang( return IPC_OK(); } -mozilla::ipc::IPCResult GPUChild::RecvUpdateMediaCodecsSupported( - const PDMFactory::MediaCodecsSupported& aSupported) { - dom::ContentParent::BroadcastMediaCodecsSupportedUpdate( - RemoteDecodeIn::GpuProcess, aSupported); - return IPC_OK(); -} - class DeferredDeleteGPUChild : public Runnable { public: explicit DeferredDeleteGPUChild(UniquePtr&& aChild) diff --git a/gfx/ipc/GPUChild.h b/gfx/ipc/GPUChild.h index e5fb2cca8fcd7..236ebaf730a38 100644 --- a/gfx/ipc/GPUChild.h +++ b/gfx/ipc/GPUChild.h @@ -68,8 +68,6 @@ class GPUChild final : public ipc::CrashReporterHelper, mozilla::ipc::IPCResult RecvUsedFallback(const Fallback& aFallback, const nsCString& aMessage); mozilla::ipc::IPCResult RecvBHRThreadHang(const HangDetails& aDetails); - mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported( - const PDMFactory::MediaCodecsSupported& aSupported); bool SendRequestMemoryReport(const uint32_t& aGeneration, const bool& aAnonymize, diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 550f51bd42c89..1d5ca622a9253 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -6,32 +6,22 @@ #ifdef XP_WIN # include "WMF.h" -# include "WMFDecoderModule.h" #endif -#include "GLContextProvider.h" #include "GPUParent.h" -#include "GPUProcessHost.h" -#include "GPUProcessManager.h" -#include "GfxInfoBase.h" -#include "ProcessUtils.h" -#include "VRGPUChild.h" -#include "VRManager.h" -#include "VRManagerParent.h" -#include "VsyncBridgeParent.h" -#include "cairo.h" #include "gfxConfig.h" #include "gfxCrashReporterUtils.h" +#include "GfxInfoBase.h" #include "gfxPlatform.h" +#include "GLContextProvider.h" +#include "GPUProcessHost.h" +#include "GPUProcessManager.h" #include "mozilla/Assertions.h" -#include "mozilla/HangDetails.h" #include "mozilla/PerfStats.h" -#include "mozilla/Preferences.h" -#include "mozilla/RemoteDecoderManagerChild.h" -#include "mozilla/RemoteDecoderManagerParent.h" -#include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" +#include "mozilla/RemoteDecoderManagerChild.h" +#include "mozilla/RemoteDecoderManagerParent.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/gfxVars.h" @@ -39,37 +29,43 @@ #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" #include "mozilla/layers/APZInputBridgeParent.h" -#include "mozilla/layers/APZPublicUtils.h" // for apz::InitializeGlobalState #include "mozilla/layers/APZThreadUtils.h" +#include "mozilla/layers/APZPublicUtils.h" // for apz::InitializeGlobalState #include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/CompositorManagerParent.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/ImageBridgeParent.h" #include "mozilla/layers/LayerTreeOwnerTracker.h" -#include "mozilla/layers/MemoryReportingMLGPU.h" #include "mozilla/layers/UiCompositorControllerParent.h" +#include "mozilla/layers/MemoryReportingMLGPU.h" #include "mozilla/layers/VideoBridgeParent.h" #include "mozilla/webrender/RenderThread.h" #include "mozilla/webrender/WebRenderAPI.h" +#include "mozilla/HangDetails.h" +#include "mozilla/Preferences.h" +#include "nscore.h" #include "nsDebugImpl.h" #include "nsIGfxInfo.h" #include "nsThreadManager.h" -#include "nscore.h" #include "prenv.h" +#include "ProcessUtils.h" +#include "VRGPUChild.h" +#include "VRManager.h" +#include "VRManagerParent.h" +#include "VsyncBridgeParent.h" +#include "cairo.h" #include "skia/include/core/SkGraphics.h" #if defined(XP_WIN) -# include -# include - -# include "mozilla/WindowsVersion.h" # include "mozilla/gfx/DeviceManagerDx.h" # include "mozilla/widget/WinCompositorWindowThread.h" +# include "mozilla/WindowsVersion.h" +# include +# include #else # include #endif #ifdef MOZ_WIDGET_GTK # include - # include "skia/include/ports/SkTypeface_cairo.h" #endif #ifdef MOZ_GECKO_PROFILER @@ -146,7 +142,9 @@ bool GPUParent::Init(base::ProcessId aParentPid, const char* aParentBuildID, LayerTreeOwnerTracker::Initialize(); CompositorBridgeParent::InitializeStatics(); mozilla::ipc::SetThisProcessName("GPU Process"); - +#ifdef XP_WIN + wmf::MFStartup(); +#endif return true; } @@ -297,19 +295,6 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( RecvGetDeviceStatus(&data); Unused << SendInitComplete(data); - // Dispatch a task to run when idle that will determine which codecs are - // usable. The primary goal is to determine if the media feature pack is - // installed. - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThreadQueue( - NS_NewRunnableFunction( - "GPUParent::Supported", - []() { - auto supported = PDMFactory::Supported(); - Unused << GPUParent::GetSingleton()->SendUpdateMediaCodecsSupported( - supported); - }), - 2000 /* 2 seconds timeout */, EventQueuePriority::Idle)); - Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_INITIALIZATION_TIME_MS, mLaunchTime); return IPC_OK(); @@ -378,18 +363,6 @@ mozilla::ipc::IPCResult GPUParent::RecvInitProfiler( } mozilla::ipc::IPCResult GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { -#if defined(XP_WIN) - auto scopeExit = MakeScopeExit( - [couldUseHWDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding()] { - if (couldUseHWDecoder != gfx::gfxVars::CanUseHardwareVideoDecoding()) { - // The capabilities of the system may have changed, force a refresh by - // re-initializing the WMF PDM. - WMFDecoderModule::Init(); - Unused << GPUParent::GetSingleton()->SendUpdateMediaCodecsSupported( - PDMFactory::Supported(true /* force refresh */)); - } - }); -#endif gfxVars::ApplyUpdate(aUpdate); return IPC_OK(); } diff --git a/gfx/ipc/PGPU.ipdl b/gfx/ipc/PGPU.ipdl index 2d9fb59aa60c1..fea0231ca2876 100644 --- a/gfx/ipc/PGPU.ipdl +++ b/gfx/ipc/PGPU.ipdl @@ -35,7 +35,6 @@ using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h"; using mozilla::gfx::Feature from "gfxFeature.h"; using mozilla::gfx::Fallback from "gfxFallback.h"; using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h"; -using mozilla::PDMFactory::MediaCodecsSupported from "PDMFactory.h"; namespace mozilla { namespace gfx { @@ -155,10 +154,6 @@ child: async UsedFallback(Fallback aFallback, nsCString message); async BHRThreadHang(HangDetails aDetails); - - // Update the cached list of codec supported following a check in the - // GPU parent. - async UpdateMediaCodecsSupported(MediaCodecsSupported aSupported); }; } // namespace gfx