summaryrefslogtreecommitdiffstats
path: root/gfx/ipc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /gfx/ipc
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/ipc')
-rw-r--r--gfx/ipc/CanvasManagerChild.cpp13
-rw-r--r--gfx/ipc/CanvasManagerChild.h1
-rw-r--r--gfx/ipc/CanvasShutdownManager.cpp7
-rw-r--r--gfx/ipc/GPUChild.cpp19
-rw-r--r--gfx/ipc/GPUParent.cpp120
5 files changed, 74 insertions, 86 deletions
diff --git a/gfx/ipc/CanvasManagerChild.cpp b/gfx/ipc/CanvasManagerChild.cpp
index dee232b6b1..79e607171d 100644
--- a/gfx/ipc/CanvasManagerChild.cpp
+++ b/gfx/ipc/CanvasManagerChild.cpp
@@ -207,14 +207,15 @@ RefPtr<layers::CanvasChild> CanvasManagerChild::GetCanvasChild() {
}
RefPtr<webgpu::WebGPUChild> CanvasManagerChild::GetWebGPUChild() {
- if (!mWebGPUChild) {
- mWebGPUChild = MakeAndAddRef<webgpu::WebGPUChild>();
- if (!SendPWebGPUConstructor(mWebGPUChild)) {
- mWebGPUChild = nullptr;
- }
+ if (PWebGPUChild* actor = LoneManagedOrNullAsserts(ManagedPWebGPUChild())) {
+ return static_cast<webgpu::WebGPUChild*>(actor);
}
- return mWebGPUChild;
+ auto actor = MakeRefPtr<webgpu::WebGPUChild>();
+ if (!SendPWebGPUConstructor(actor)) {
+ return nullptr;
+ }
+ return actor;
}
layers::ActiveResourceTracker* CanvasManagerChild::GetActiveResourceTracker() {
diff --git a/gfx/ipc/CanvasManagerChild.h b/gfx/ipc/CanvasManagerChild.h
index c59ba7c502..bb76e7d4a0 100644
--- a/gfx/ipc/CanvasManagerChild.h
+++ b/gfx/ipc/CanvasManagerChild.h
@@ -68,7 +68,6 @@ class CanvasManagerChild final : public PCanvasManagerChild {
RefPtr<mozilla::dom::ThreadSafeWorkerRef> mWorkerRef;
RefPtr<layers::CanvasChild> mCanvasChild;
- RefPtr<webgpu::WebGPUChild> mWebGPUChild;
UniquePtr<layers::ActiveResourceTracker> mActiveResourceTracker;
const uint32_t mId;
bool mActive = true;
diff --git a/gfx/ipc/CanvasShutdownManager.cpp b/gfx/ipc/CanvasShutdownManager.cpp
index d7fc96d255..f15e2e24f5 100644
--- a/gfx/ipc/CanvasShutdownManager.cpp
+++ b/gfx/ipc/CanvasShutdownManager.cpp
@@ -149,11 +149,10 @@ void CanvasShutdownManager::OnRemoteCanvasRestored() {
/* static */ void CanvasShutdownManager::OnCompositorManagerRestored() {
MOZ_ASSERT(NS_IsMainThread());
- class RestoreRunnable final : public WorkerRunnable {
+ class RestoreRunnable final : public WorkerThreadRunnable {
public:
explicit RestoreRunnable(WorkerPrivate* aWorkerPrivate)
- : WorkerRunnable(aWorkerPrivate,
- "CanvasShutdownManager::RestoreRunnable") {}
+ : WorkerThreadRunnable("CanvasShutdownManager::RestoreRunnable") {}
bool WorkerRun(JSContext*, WorkerPrivate*) override {
MaybeRestoreRemoteCanvas();
@@ -171,7 +170,7 @@ void CanvasShutdownManager::OnRemoteCanvasRestored() {
for (const auto& manager : sManagers) {
if (manager->mWorkerRef) {
auto task = MakeRefPtr<RestoreRunnable>(manager->mWorkerRef->Private());
- task->Dispatch();
+ task->Dispatch(manager->mWorkerRef->Private());
}
}
}
diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp
index afc9f61ee4..2a9fe23628 100644
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -8,12 +8,15 @@
#include "GPUProcessHost.h"
#include "GPUProcessManager.h"
#include "GfxInfoBase.h"
+#include "TelemetryProbesReporter.h"
+#include "VideoUtils.h"
#include "VRProcessManager.h"
#include "gfxConfig.h"
#include "gfxPlatform.h"
#include "mozilla/Components.h"
#include "mozilla/FOGIPC.h"
#include "mozilla/StaticPrefs_dom.h"
+#include "mozilla/StaticPrefs_media.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TelemetryIPC.h"
#include "mozilla/dom/CheckerboardReportService.h"
@@ -341,8 +344,24 @@ mozilla::ipc::IPCResult GPUChild::RecvBHRThreadHang(
mozilla::ipc::IPCResult GPUChild::RecvUpdateMediaCodecsSupported(
const media::MediaCodecsSupported& aSupported) {
+ if (ContainHardwareCodecsSupported(aSupported)) {
+ mozilla::TelemetryProbesReporter::ReportDeviceMediaCodecSupported(
+ aSupported);
+ }
+#if defined(XP_WIN)
+ // Do not propagate HEVC support if the pref is off
+ media::MediaCodecsSupported trimedSupported = aSupported;
+ if (aSupported.contains(
+ mozilla::media::MediaCodecsSupport::HEVCHardwareDecode) &&
+ StaticPrefs::media_wmf_hevc_enabled() != 1) {
+ trimedSupported -= mozilla::media::MediaCodecsSupport::HEVCHardwareDecode;
+ }
+ dom::ContentParent::BroadcastMediaCodecsSupportedUpdate(
+ RemoteDecodeIn::GpuProcess, trimedSupported);
+#else
dom::ContentParent::BroadcastMediaCodecsSupportedUpdate(
RemoteDecodeIn::GpuProcess, aSupported);
+#endif
return IPC_OK();
}
diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp
index f4240a5d97..3d33be3a75 100644
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -104,70 +104,27 @@ namespace mozilla::gfx {
using namespace ipc;
using namespace layers;
-static GPUParent* sGPUParent;
-
-static void ReportHardwareMediaCodecSupportIfNeeded() {
- // We only need to report the result once.
- static bool sReported = false;
- if (sReported) {
- return;
- }
+static media::MediaCodecsSupported GetFullMediaCodecSupport(
+ bool aForceRefresh = false) {
#if defined(XP_WIN)
- NS_GetCurrentThread()->Dispatch(NS_NewRunnableFunction(
- "GPUParent:ReportHardwareMediaCodecSupportIfNeeded", []() {
- // Only report telemetry when hardware decoding is available.
- if (!gfx::gfxVars::IsInitialized() ||
- !gfx::gfxVars::CanUseHardwareVideoDecoding()) {
- return;
- }
- sReported = true;
-
- // TODO : we can remove this after HEVC is enabled by default.
- // HEVC is not enabled. We need to force to enable it in order to know
- // its support as well, and it would be turn off later.
- if (StaticPrefs::media_wmf_hevc_enabled() != 1) {
- WMFDecoderModule::Init(WMFDecoderModule::Config::ForceEnableHEVC);
- }
- const auto support = PDMFactory::Supported(true /* force refresh */);
- if (support.contains(
- mozilla::media::MediaCodecsSupport::H264HardwareDecode)) {
- Telemetry::ScalarSet(
- Telemetry::ScalarID::MEDIA_DEVICE_HARDWARE_DECODING_SUPPORT,
- u"h264"_ns, true);
- }
- if (support.contains(
- mozilla::media::MediaCodecsSupport::VP8HardwareDecode)) {
- Telemetry::ScalarSet(
- Telemetry::ScalarID::MEDIA_DEVICE_HARDWARE_DECODING_SUPPORT,
- u"vp8"_ns, true);
- }
- if (support.contains(
- mozilla::media::MediaCodecsSupport::VP9HardwareDecode)) {
- Telemetry::ScalarSet(
- Telemetry::ScalarID::MEDIA_DEVICE_HARDWARE_DECODING_SUPPORT,
- u"vp9"_ns, true);
- }
- if (support.contains(
- mozilla::media::MediaCodecsSupport::AV1HardwareDecode)) {
- Telemetry::ScalarSet(
- Telemetry::ScalarID::MEDIA_DEVICE_HARDWARE_DECODING_SUPPORT,
- u"av1"_ns, true);
- }
- if (support.contains(
- mozilla::media::MediaCodecsSupport::HEVCHardwareDecode)) {
- Telemetry::ScalarSet(
- Telemetry::ScalarID::MEDIA_DEVICE_HARDWARE_DECODING_SUPPORT,
- u"hevc"_ns, true);
- }
- if (StaticPrefs::media_wmf_hevc_enabled() != 1) {
- WMFDecoderModule::Init();
- }
- }));
+ // Re-initializing WMFPDM if forcing a refresh is required or hardware
+ // decoding is supported in order to get HEVC result properly. We will disable
+ // it later if the pref is OFF.
+ if (aForceRefresh || (gfx::gfxVars::IsInitialized() &&
+ gfx::gfxVars::CanUseHardwareVideoDecoding())) {
+ WMFDecoderModule::Init(WMFDecoderModule::Config::ForceEnableHEVC);
+ }
+ auto disableHEVCIfNeeded = MakeScopeExit([]() {
+ if (StaticPrefs::media_wmf_hevc_enabled() != 1) {
+ WMFDecoderModule::DisableForceEnableHEVC();
+ }
+ });
#endif
- // TODO : in the future, when we have GPU procss on MacOS, then we can report
- // HEVC usage as well.
+ return PDMFactory::Supported(aForceRefresh);
}
+static GPUParent* sGPUParent;
+
GPUParent::GPUParent() : mLaunchTime(TimeStamp::Now()) { sGPUParent = this; }
GPUParent::~GPUParent() { sGPUParent = nullptr; }
@@ -260,6 +217,10 @@ bool GPUParent::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
DeviceManagerDx::Init();
GpuProcessD3D11TextureMap::Init();
GpuProcessD3D11QueryMap::Init();
+ auto rv = wmf::MediaFoundationInitializer::HasInitialized();
+ if (!rv) {
+ NS_WARNING("Failed to init Media Foundation in the GPU process");
+ }
#endif
CompositorThreadHolder::Start();
@@ -456,19 +417,20 @@ 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(
+ // Dispatch a task to background thread to determine the media codec supported
+ // result, and propagate it back to the chrome process on the main thread.
+ MOZ_ALWAYS_SUCCEEDS(NS_DispatchBackgroundTask(
NS_NewRunnableFunction(
"GPUParent::Supported",
[]() {
- auto supported = PDMFactory::Supported();
- Unused << GPUParent::GetSingleton()->SendUpdateMediaCodecsSupported(
- supported);
- ReportHardwareMediaCodecSupportIfNeeded();
+ NS_DispatchToMainThread(NS_NewRunnableFunction(
+ "GPUParent::UpdateMediaCodecsSupported",
+ [supported = GetFullMediaCodecSupport()]() {
+ Unused << GPUParent::GetSingleton()
+ ->SendUpdateMediaCodecsSupported(supported);
+ }));
}),
- 2000 /* 2 seconds timeout */, EventQueuePriority::Idle));
+ nsIEventTarget::DISPATCH_NORMAL));
Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_INITIALIZATION_TIME_MS,
mLaunchTime);
@@ -553,12 +515,20 @@ mozilla::ipc::IPCResult GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) {
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 */));
- ReportHardwareMediaCodecSupportIfNeeded();
+ MOZ_ALWAYS_SUCCEEDS(NS_DispatchBackgroundTask(
+ NS_NewRunnableFunction(
+ "GPUParent::RecvUpdateVar",
+ []() {
+ NS_DispatchToMainThread(NS_NewRunnableFunction(
+ "GPUParent::UpdateMediaCodecsSupported",
+ [supported = GetFullMediaCodecSupport(
+ true /* force refresh */)]() {
+ Unused << GPUParent::GetSingleton()
+ ->SendUpdateMediaCodecsSupported(
+ supported);
+ }));
+ }),
+ nsIEventTarget::DISPATCH_NORMAL));
}
});
#endif