Backed out 6 changesets (bug 1561179) for perma fails on browser_timeout_throttling_with_audio_playback.js. CLOSED TREE

Backed out changeset 5d8059472045 (bug 1561179)
Backed out changeset 90c207dd2cc2 (bug 1561179)
Backed out changeset e90af73ef3c4 (bug 1561179)
Backed out changeset 4678da971197 (bug 1561179)
Backed out changeset 55340b999a4e (bug 1561179)
Backed out changeset 4037cce56491 (bug 1561179)
This commit is contained in:
Razvan Maries 2019-10-31 03:21:24 +02:00
Родитель c7c5a06642
Коммит cdb80ead85
29 изменённых файлов: 166 добавлений и 273 удалений

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

@ -1093,7 +1093,9 @@ mozilla::ipc::IPCResult ContentParent::RecvLaunchRDDProcess(
Preferences::GetBool("media.rdd-process.enabled", false)) {
RDDProcessManager* rdd = RDDProcessManager::Get();
if (rdd) {
bool rddOpened = rdd->LaunchRDDProcess(OtherPid(), aEndpoint);
rdd->LaunchRDDProcess();
bool rddOpened = rdd->CreateContentBridge(OtherPid(), aEndpoint);
if (NS_WARN_IF(!rddOpened)) {
*aRv = NS_ERROR_NOT_AVAILABLE;

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

@ -41,9 +41,11 @@ parent:
async UpdateVar(GfxVarUpdate var);
async InitVideoBridge(Endpoint<PVideoBridgeChild> endpoint);
async CreateVideoBridgeToParentProcess(Endpoint<PVideoBridgeChild> endpoint);
child:
// args TBD, sent when init complete. Occurs once, after Init().
async InitComplete();
async InitCrashReporter(Shmem shmem, NativeThreadId threadId);

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

@ -5,11 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RDDChild.h"
#include "mozilla/RDDProcessManager.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/gfx/GPUProcessManager.h"
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/SandboxBroker.h"
@ -26,7 +24,7 @@ namespace mozilla {
using namespace layers;
using namespace gfx;
RDDChild::RDDChild(RDDProcessHost* aHost) : mHost(aHost) {
RDDChild::RDDChild(RDDProcessHost* aHost) : mHost(aHost), mRDDReady(false) {
MOZ_COUNT_CTOR(RDDChild);
}
@ -59,14 +57,29 @@ bool RDDChild::Init(bool aStartMacSandbox) {
#endif
gfxVars::AddReceiver(this);
auto* gpm = gfx::GPUProcessManager::Get();
if (gpm) {
gpm->AddListener(this);
}
return true;
}
bool RDDChild::EnsureRDDReady() {
if (mRDDReady) {
return true;
}
mRDDReady = true;
return true;
}
mozilla::ipc::IPCResult RDDChild::RecvInitComplete() {
// We synchronously requested RDD parameters before this arrived.
if (mRDDReady) {
return IPC_OK();
}
mRDDReady = true;
return IPC_OK();
}
bool RDDChild::SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
@ -77,13 +90,6 @@ bool RDDChild::SendRequestMemoryReport(const uint32_t& aGeneration,
return true;
}
void RDDChild::OnCompositorUnexpectedShutdown() {
auto* rddm = RDDProcessManager::Get();
if (rddm) {
rddm->CreateVideoBridge();
}
}
void RDDChild::OnVarChanged(const GfxVarUpdate& aVar) { SendUpdateVar(aVar); }
mozilla::ipc::IPCResult RDDChild::RecvAddMemoryReport(
@ -108,12 +114,6 @@ void RDDChild::ActorDestroy(ActorDestroyReason aWhy) {
GenerateCrashReport(OtherPid());
}
auto* gpm = gfx::GPUProcessManager::Get();
if (gpm) {
// Note: the manager could have shutdown already.
gpm->RemoveListener(this);
}
gfxVars::RemoveReceiver(this);
mHost->OnChannelClosed();
}

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

@ -10,7 +10,6 @@
#include "mozilla/ipc/CrashReporterHelper.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/gfxVarReceiver.h"
#include "mozilla/gfx/GPUProcessListener.h"
namespace mozilla {
@ -26,8 +25,7 @@ class RDDProcessHost;
class RDDChild final : public PRDDChild,
public ipc::CrashReporterHelper<GeckoProcessType_RDD>,
public gfx::gfxVarReceiver,
public gfx::GPUProcessListener {
public gfx::gfxVarReceiver {
typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
public:
@ -36,9 +34,13 @@ class RDDChild final : public PRDDChild,
bool Init(bool aStartMacSandbox);
void OnCompositorUnexpectedShutdown() override;
bool EnsureRDDReady();
void OnVarChanged(const GfxVarUpdate& aVar) override;
// PRDDChild overrides.
mozilla::ipc::IPCResult RecvInitComplete();
void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport);
@ -57,6 +59,7 @@ class RDDChild final : public PRDDChild,
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
UniquePtr<SandboxBroker> mSandboxBroker;
#endif
bool mRDDReady;
};
} // namespace mozilla

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

@ -121,6 +121,8 @@ static void StartRDDMacSandbox() {
mozilla::ipc::IPCResult RDDParent::RecvInit(
nsTArray<GfxVarUpdate>&& vars, const Maybe<FileDescriptor>& aBrokerFd,
bool aStartMacSandbox) {
Unused << SendInitComplete();
for (const auto& var : vars) {
gfxVars::ApplyUpdate(var);
}
@ -172,9 +174,9 @@ mozilla::ipc::IPCResult RDDParent::RecvNewContentRemoteDecoderManager(
return IPC_OK();
}
mozilla::ipc::IPCResult RDDParent::RecvInitVideoBridge(
mozilla::ipc::IPCResult RDDParent::RecvCreateVideoBridgeToParentProcess(
Endpoint<PVideoBridgeChild>&& aEndpoint) {
if (!RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess(
if (!RemoteDecoderManagerParent::CreateVideoBridgeToParentProcess(
std::move(aEndpoint))) {
return IPC_FAIL_NO_REASON(this);
}

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

@ -32,7 +32,7 @@ class RDDParent final : public PRDDParent {
mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager(
Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitVideoBridge(
mozilla::ipc::IPCResult RecvCreateVideoBridgeToParentProcess(
Endpoint<PVideoBridgeChild>&& aEndpoint);
mozilla::ipc::IPCResult RecvRequestMemoryReport(
const uint32_t& generation, const bool& anonymize,

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

@ -11,7 +11,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/layers/VideoBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "nsAppRunner.h"
@ -21,8 +20,7 @@
namespace mozilla {
using namespace gfx;
using namespace layers;
using namespace mozilla::layers;
static StaticAutoPtr<RDDProcessManager> sRDDSingleton;
@ -103,11 +101,9 @@ void RDDProcessManager::OnPreferenceChange(const char16_t* aData) {
}
}
bool RDDProcessManager::LaunchRDDProcess(
base::ProcessId aOtherProcess,
ipc::Endpoint<PRemoteDecoderManagerChild>* aOutRemoteDecoderManager) {
void RDDProcessManager::LaunchRDDProcess() {
if (mProcess) {
return true;
return;
}
mNumProcessAttempts++;
@ -122,27 +118,30 @@ bool RDDProcessManager::LaunchRDDProcess(
mProcess = new RDDProcessHost(this);
if (!mProcess->Launch(extraArgs)) {
DestroyProcess();
return false;
}
if (!EnsureRDDReady()) {
return false;
}
bool ok = true;
if (ok) ok = CreateContentBridge(aOtherProcess, aOutRemoteDecoderManager);
if (ok) ok = CreateVideoBridge();
return ok;
}
bool RDDProcessManager::EnsureRDDReady() {
if (mProcess && !mProcess->IsConnected() && !mProcess->WaitForLaunch()) {
// If this fails, we should have fired OnProcessLaunchComplete and
// removed the process.
MOZ_ASSERT(!mProcess && !mRDDChild);
return false;
if (mProcess && !mProcess->IsConnected()) {
if (!mProcess->WaitForLaunch()) {
// If this fails, we should have fired OnProcessLaunchComplete and
// removed the process.
MOZ_ASSERT(!mProcess && !mRDDChild);
return false;
}
}
return true;
if (mRDDChild) {
if (mRDDChild->EnsureRDDReady()) {
return true;
}
// If the initialization above fails, we likely have a RDD process teardown
// waiting in our message queue (or will soon).
DestroyProcess();
}
return false;
}
void RDDProcessManager::OnProcessLaunchComplete(RDDProcessHost* aHost) {
@ -163,6 +162,26 @@ void RDDProcessManager::OnProcessLaunchComplete(RDDProcessHost* aHost) {
}
mQueuedPrefs.Clear();
ipc::Endpoint<PVideoBridgeParent> parentPipe;
ipc::Endpoint<PVideoBridgeChild> childPipe;
// Currently hardcoded to use the current process as the parent side,
// we need to add support for the GPU process.
nsresult rv = PVideoBridge::CreateEndpoints(
base::GetCurrentProcId(), mRDDChild->OtherPid(), &parentPipe, &childPipe);
if (NS_FAILED(rv)) {
MOZ_LOG(sPDMLog, LogLevel::Debug,
("Could not create video bridge: %d", int(rv)));
DestroyProcess();
return;
}
mRDDChild->SendCreateVideoBridgeToParentProcess(std::move(childPipe));
CompositorThreadHolder::Loop()->PostTask(
NewRunnableFunction("gfx::VideoBridgeParent::Open",
&VideoBridgeParent::Open, std::move(parentPipe)));
CrashReporter::AnnotateCrashReport(
CrashReporter::Annotation::RDDProcessStatus,
NS_LITERAL_CSTRING("Running"));
@ -223,6 +242,10 @@ void RDDProcessManager::DestroyProcess() {
bool RDDProcessManager::CreateContentBridge(
base::ProcessId aOtherProcess,
ipc::Endpoint<PRemoteDecoderManagerChild>* aOutRemoteDecoderManager) {
if (!EnsureRDDReady() || !StaticPrefs::media_rdd_process_enabled()) {
return false;
}
ipc::Endpoint<PRemoteDecoderManagerParent> parentPipe;
ipc::Endpoint<PRemoteDecoderManagerChild> childPipe;
@ -240,39 +263,6 @@ bool RDDProcessManager::CreateContentBridge(
return true;
}
bool RDDProcessManager::CreateVideoBridge() {
ipc::Endpoint<PVideoBridgeParent> parentPipe;
ipc::Endpoint<PVideoBridgeChild> childPipe;
GPUProcessManager* gpuManager = GPUProcessManager::Get();
base::ProcessId gpuProcessPid = gpuManager ? gpuManager->GPUProcessPid() : -1;
// The child end is the producer of video frames; the parent end is the
// consumer.
base::ProcessId childPid = RDDProcessPid();
base::ProcessId parentPid =
gpuProcessPid != -1 ? gpuProcessPid : base::GetCurrentProcId();
nsresult rv = PVideoBridge::CreateEndpoints(parentPid, childPid, &parentPipe,
&childPipe);
if (NS_FAILED(rv)) {
MOZ_LOG(sPDMLog, LogLevel::Debug,
("Could not create video bridge: %d", int(rv)));
DestroyProcess();
return false;
}
mRDDChild->SendInitVideoBridge(std::move(childPipe));
if (gpuProcessPid != -1) {
gpuManager->InitVideoBridge(std::move(parentPipe));
} else {
VideoBridgeParent::Open(std::move(parentPipe),
VideoBridgeSource::RddProcess);
}
return true;
}
base::ProcessId RDDProcessManager::RDDProcessPid() {
base::ProcessId rddPid = mRDDChild ? mRDDChild->OtherPid() : -1;
return rddPid;

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

@ -19,8 +19,6 @@ class RDDChild;
// objects that may live in another process. Currently, it provides access
// to the RDD process via ContentParent.
class RDDProcessManager final : public RDDProcessHost::Listener {
friend class RDDChild;
public:
static void Initialize();
static void Shutdown();
@ -29,15 +27,17 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
~RDDProcessManager();
// If not using a RDD process, launch a new RDD process asynchronously.
bool LaunchRDDProcess(base::ProcessId aOtherProcess,
mozilla::ipc::Endpoint<PRemoteDecoderManagerChild>*
aOutRemoteDecoderManager);
void LaunchRDDProcess();
// Ensure that RDD-bound methods can be used. If no RDD process is being
// used, or one is launched and ready, this function returns immediately.
// Otherwise it blocks until the RDD process has finished launching.
bool EnsureRDDReady();
bool CreateContentBridge(base::ProcessId aOtherProcess,
mozilla::ipc::Endpoint<PRemoteDecoderManagerChild>*
aOutRemoteDecoderManager);
void OnProcessLaunchComplete(RDDProcessHost* aHost) override;
void OnProcessUnexpectedShutdown(RDDProcessHost* aHost) override;
@ -65,11 +65,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
RDDProcessHost* Process() { return mProcess; }
private:
bool CreateContentBridge(base::ProcessId aOtherProcess,
mozilla::ipc::Endpoint<PRemoteDecoderManagerChild>*
aOutRemoteDecoderManager);
bool CreateVideoBridge();
// Called from our xpcom-shutdown observer.
void OnXPCOMShutdown();
void OnPreferenceChange(const char16_t* aData);

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

@ -155,10 +155,6 @@ bool RemoteDecoderManagerChild::DeallocPRemoteDecoderChild(
return true;
}
RemoteDecoderManagerChild::RemoteDecoderManagerChild(
layers::VideoBridgeSource aSource)
: mSource(aSource) {}
void RemoteDecoderManagerChild::OpenForRDDProcess(
Endpoint<PRemoteDecoderManagerChild>&& aEndpoint) {
MOZ_ASSERT(NS_GetCurrentThread() == GetManagerThread());
@ -174,8 +170,7 @@ void RemoteDecoderManagerChild::OpenForRDDProcess(
}
sRemoteDecoderManagerChildForRDDProcess = nullptr;
if (aEndpoint.IsValid()) {
RefPtr<RemoteDecoderManagerChild> manager =
new RemoteDecoderManagerChild(VideoBridgeSource::RddProcess);
RefPtr<RemoteDecoderManagerChild> manager = new RemoteDecoderManagerChild();
if (aEndpoint.Bind(manager)) {
sRemoteDecoderManagerChildForRDDProcess = manager;
manager->InitIPDL();
@ -189,8 +184,7 @@ void RemoteDecoderManagerChild::OpenForGPUProcess(
// fail since this is as close to being recreated as we will ever be.
sRemoteDecoderManagerChildForGPUProcess = nullptr;
if (aEndpoint.IsValid()) {
RefPtr<RemoteDecoderManagerChild> manager =
new RemoteDecoderManagerChild(VideoBridgeSource::GpuProcess);
RefPtr<RemoteDecoderManagerChild> manager = new RemoteDecoderManagerChild();
if (aEndpoint.Bind(manager)) {
sRemoteDecoderManagerChildForGPUProcess = manager;
manager->InitIPDL();

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

@ -6,7 +6,6 @@
#ifndef include_dom_media_ipc_RemoteDecoderManagerChild_h
#define include_dom_media_ipc_RemoteDecoderManagerChild_h
#include "mozilla/PRemoteDecoderManagerChild.h"
#include "mozilla/layers/VideoBridgeUtils.h"
namespace mozilla {
@ -62,7 +61,6 @@ class RemoteDecoderManagerChild final : public PRemoteDecoderManagerChild,
void RunWhenGPUProcessRecreated(already_AddRefed<Runnable> aTask);
bool CanSend();
layers::VideoBridgeSource GetSource() const { return mSource; }
protected:
void InitIPDL();
@ -83,7 +81,7 @@ class RemoteDecoderManagerChild final : public PRemoteDecoderManagerChild,
// Main thread only
static void InitializeThread();
explicit RemoteDecoderManagerChild(layers::VideoBridgeSource aSource);
RemoteDecoderManagerChild() = default;
~RemoteDecoderManagerChild() = default;
static void OpenForRDDProcess(
@ -93,9 +91,6 @@ class RemoteDecoderManagerChild final : public PRemoteDecoderManagerChild,
RefPtr<RemoteDecoderManagerChild> mIPDLSelfRef;
// The associated source of this decoder manager
layers::VideoBridgeSource mSource;
// Should only ever be accessed on the manager thread.
bool mCanSend = false;
};

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

@ -174,7 +174,7 @@ bool RemoteDecoderManagerParent::CreateForContent(
return true;
}
bool RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess(
bool RemoteDecoderManagerParent::CreateVideoBridgeToParentProcess(
Endpoint<PVideoBridgeChild>&& aEndpoint) {
// We never want to decode in the GPU process, but output
// frames to the parent process.
@ -185,9 +185,9 @@ bool RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess(
return false;
}
RefPtr<Runnable> task =
NewRunnableFunction("gfx::VideoBridgeChild::Open",
&VideoBridgeChild::Open, std::move(aEndpoint));
RefPtr<Runnable> task = NewRunnableFunction(
"gfx::VideoBridgeChild::Open", &VideoBridgeChild::OpenToParentProcess,
std::move(aEndpoint));
sRemoteDecoderManagerParentThread->Dispatch(task.forget(),
NS_DISPATCH_NORMAL);
return true;

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

@ -21,7 +21,7 @@ class RemoteDecoderManagerParent final : public PRemoteDecoderManagerParent {
static bool CreateForContent(
Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
static bool CreateVideoBridgeToOtherProcess(
static bool CreateVideoBridgeToParentProcess(
Endpoint<layers::PVideoBridgeChild>&& aEndpoint);
// Can be called from any thread

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

@ -37,8 +37,9 @@ class KnowsCompositorVideo : public layers::KnowsCompositor {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(KnowsCompositorVideo, override)
layers::TextureForwarder* GetTextureForwarder() override {
auto* vbc = VideoBridgeChild::GetSingleton();
return (vbc && vbc->CanSend()) ? vbc : nullptr;
return mTextureFactoryIdentifier.mParentProcessType == GeckoProcessType_GPU
? VideoBridgeChild::GetSingletonToGPUProcess()
: VideoBridgeChild::GetSingletonToParentProcess();
}
layers::LayersIPCActor* GetLayersIPCActor() override {
return GetTextureForwarder();
@ -46,7 +47,10 @@ class KnowsCompositorVideo : public layers::KnowsCompositor {
static already_AddRefed<KnowsCompositorVideo> TryCreateForIdentifier(
const layers::TextureFactoryIdentifier& aIdentifier) {
VideoBridgeChild* child = VideoBridgeChild::GetSingleton();
VideoBridgeChild* child =
(aIdentifier.mParentProcessType == GeckoProcessType_GPU)
? VideoBridgeChild::GetSingletonToGPUProcess()
: VideoBridgeChild::GetSingletonToParentProcess();
if (!child) {
return nullptr;
}
@ -310,14 +314,13 @@ MediaResult RemoteVideoDecoderParent::ProcessDecodedData(
DecodedOutputIPDL& aDecodedData) {
MOZ_ASSERT(OnManagerThread());
nsTArray<RemoteVideoDataIPDL> array;
// If the video decoder bridge has shut down, stop.
if (mKnowsCompositor && !mKnowsCompositor->GetTextureForwarder()) {
aDecodedData = std::move(array);
return NS_OK;
}
nsTArray<RemoteVideoDataIPDL> array;
for (const auto& data : aData) {
MOZ_ASSERT(data->mType == MediaData::Type::VIDEO_DATA,
"Can only decode videos using RemoteDecoderParent!");

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

@ -38,7 +38,6 @@
#include "mozilla/layers/LayerTreeOwnerTracker.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"
@ -316,12 +315,6 @@ mozilla::ipc::IPCResult GPUParent::RecvInitImageBridge(
return IPC_OK();
}
mozilla::ipc::IPCResult GPUParent::RecvInitVideoBridge(
Endpoint<PVideoBridgeParent>&& aEndpoint) {
VideoBridgeParent::Open(std::move(aEndpoint), VideoBridgeSource::RddProcess);
return IPC_OK();
}
mozilla::ipc::IPCResult GPUParent::RecvInitVRManager(
Endpoint<PVRManagerParent>&& aEndpoint) {
VRManagerParent::CreateForGPUProcess(std::move(aEndpoint));

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

@ -46,8 +46,6 @@ class GPUParent final : public PGPUParent {
Endpoint<PVsyncBridgeParent>&& aVsyncEndpoint);
mozilla::ipc::IPCResult RecvInitImageBridge(
Endpoint<PImageBridgeParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitVideoBridge(
Endpoint<PVideoBridgeParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitVRManager(
Endpoint<PVRManagerParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitVR(Endpoint<PVRGPUChild>&& aVRGPUChild);

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

@ -968,12 +968,6 @@ void GPUProcessManager::CreateContentRemoteDecoderManager(
*aOutEndpoint = std::move(childPipe);
}
void GPUProcessManager::InitVideoBridge(ipc::Endpoint<PVideoBridgeParent>&& aVideoBridge) {
if (EnsureGPUReady()) {
mGPUChild->SendInitVideoBridge(std::move(aVideoBridge));
}
}
void GPUProcessManager::MapLayerTreeId(LayersId aLayersId,
base::ProcessId aOwningId) {
LayerTreeOwnerTracker::Get()->Map(aLayersId, aOwningId);

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

@ -33,7 +33,6 @@ class CompositorUpdateObserver;
class PCompositorBridgeChild;
class PCompositorManagerChild;
class PImageBridgeChild;
class PVideoBridgeParent;
class RemoteCompositorSession;
class InProcessCompositorSession;
class UiCompositorControllerChild;
@ -72,7 +71,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
typedef layers::PCompositorBridgeChild PCompositorBridgeChild;
typedef layers::PCompositorManagerChild PCompositorManagerChild;
typedef layers::PImageBridgeChild PImageBridgeChild;
typedef layers::PVideoBridgeParent PVideoBridgeParent;
typedef layers::RemoteCompositorSession RemoteCompositorSession;
typedef layers::InProcessCompositorSession InProcessCompositorSession;
typedef layers::UiCompositorControllerChild UiCompositorControllerChild;
@ -106,9 +104,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
mozilla::ipc::Endpoint<PRemoteDecoderManagerChild>* aOutVideoManager,
nsTArray<uint32_t>* aNamespaces);
// Initialize GPU process with consuming end of PVideoBridge.
void InitVideoBridge(mozilla::ipc::Endpoint<PVideoBridgeParent>&& aVideoBridge);
// Maps the layer tree and process together so that aOwningPID is allowed
// to access aLayersId across process.
void MapLayerTreeId(LayersId aLayersId, base::ProcessId aOwningId);

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

@ -25,7 +25,6 @@
#include "nsRect.h"
#include "nsRegion.h"
#include "mozilla/Array.h"
#include "mozilla/layers/VideoBridgeUtils.h"
#include <stdint.h>

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

@ -13,7 +13,6 @@ include protocol PImageBridge;
include protocol PProfiler;
include protocol PVRGPU;
include protocol PVRManager;
include protocol PVideoBridge;
include protocol PVsyncBridge;
include protocol PUiCompositorController;
include protocol PRemoteDecoderManager;
@ -62,7 +61,6 @@ parent:
async InitCompositorManager(Endpoint<PCompositorManagerParent> endpoint);
async InitVsyncBridge(Endpoint<PVsyncBridgeParent> endpoint);
async InitImageBridge(Endpoint<PImageBridgeParent> endpoint);
async InitVideoBridge(Endpoint<PVideoBridgeParent> endpoint);
async InitVRManager(Endpoint<PVRManagerParent> endpoint);
async InitUiCompositorController(LayersId rootLayerTreeId, Endpoint<PUiCompositorControllerParent> endpoint);
async InitProfiler(Endpoint<PProfilerChild> endpoint);

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

@ -16,12 +16,9 @@ using namespace gfx;
GPUVideoTextureData::GPUVideoTextureData(RemoteDecoderManagerChild* aManager,
const SurfaceDescriptorGPUVideo& aSD,
const gfx::IntSize& aSize)
: mManager(aManager),
mSD(aSD), mSize(aSize) {
mSD.source() = Some(mManager->GetSource());
}
: mManager(aManager), mSD(aSD), mSize(aSize) {}
GPUVideoTextureData::~GPUVideoTextureData() {}
GPUVideoTextureData::~GPUVideoTextureData() {}
bool GPUVideoTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) {
aOutDescriptor = mSD;

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

@ -1491,7 +1491,7 @@ void TextureClient::GPUVideoDesc(SurfaceDescriptorGPUVideo* const aOutDesc) {
MOZ_RELEASE_ASSERT(mData);
mData->GetSubDescriptor(&subDesc);
*aOutDesc = SurfaceDescriptorGPUVideo(handle, std::move(subDesc), Nothing());
*aOutDesc = SurfaceDescriptorGPUVideo(handle, std::move(subDesc));
}
class MemoryTextureReadLock : public NonBlockingTextureReadLock {

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

@ -37,7 +37,7 @@ TextureHost* GPUVideoTextureHost::EnsureWrappedTextureHost() {
// one from RDD). We'll need to flag which one to use to lookup our
// descriptor, or just try both.
mWrappedTextureHost =
VideoBridgeParent::GetSingleton(mDescriptor.source())->LookupTexture(mDescriptor.handle());
VideoBridgeParent::GetSingleton()->LookupTexture(mDescriptor.handle());
return mWrappedTextureHost;
}

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

@ -16,7 +16,6 @@ using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h";
using gfxImageFormat from "gfxTypes.h";
using mozilla::layers::MaybeVideoBridgeSource from "mozilla/layers/VideoBridgeUtils.h";
namespace mozilla {
namespace layers {
@ -102,7 +101,6 @@ union GPUVideoSubDescriptor {
struct SurfaceDescriptorGPUVideo {
uint64_t handle;
GPUVideoSubDescriptor subdesc;
MaybeVideoBridgeSource source;
};
struct RGBDescriptor {

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

@ -7,12 +7,12 @@
#include "VideoBridgeChild.h"
#include "VideoBridgeParent.h"
#include "CompositorThread.h"
#include "mozilla/dom/ContentChild.h"
namespace mozilla {
namespace layers {
StaticRefPtr<VideoBridgeChild> sVideoBridge;
StaticRefPtr<VideoBridgeChild> sVideoBridgeToParentProcess;
StaticRefPtr<VideoBridgeChild> sVideoBridgeToGPUProcess;
/* static */
void VideoBridgeChild::StartupForGPUProcess() {
@ -23,25 +23,42 @@ void VideoBridgeChild::StartupForGPUProcess() {
base::GetCurrentProcId(), &parentPipe,
&childPipe);
VideoBridgeChild::Open(std::move(childPipe));
VideoBridgeParent::Open(std::move(parentPipe), VideoBridgeSource::GpuProcess);
VideoBridgeChild::OpenToGPUProcess(std::move(childPipe));
CompositorThreadHolder::Loop()->PostTask(
NewRunnableFunction("gfx::VideoBridgeParent::Open",
&VideoBridgeParent::Open, std::move(parentPipe)));
}
void VideoBridgeChild::Open(Endpoint<PVideoBridgeChild>&& aEndpoint) {
MOZ_ASSERT(!sVideoBridge || !sVideoBridge->CanSend());
sVideoBridge = new VideoBridgeChild();
void VideoBridgeChild::OpenToParentProcess(
Endpoint<PVideoBridgeChild>&& aEndpoint) {
sVideoBridgeToParentProcess = new VideoBridgeChild();
if (!aEndpoint.Bind(sVideoBridge)) {
if (!aEndpoint.Bind(sVideoBridgeToParentProcess)) {
// We can't recover from this.
MOZ_CRASH("Failed to bind VideoBridgeChild to endpoint");
MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
}
}
void VideoBridgeChild::OpenToGPUProcess(
Endpoint<PVideoBridgeChild>&& aEndpoint) {
sVideoBridgeToGPUProcess = new VideoBridgeChild();
if (!aEndpoint.Bind(sVideoBridgeToGPUProcess)) {
// We can't recover from this.
MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
}
}
/* static */
void VideoBridgeChild::Shutdown() {
if (sVideoBridge) {
sVideoBridge->Close();
sVideoBridge = nullptr;
if (sVideoBridgeToParentProcess) {
sVideoBridgeToParentProcess->Close();
sVideoBridgeToParentProcess = nullptr;
}
if (sVideoBridgeToGPUProcess) {
sVideoBridgeToGPUProcess->Close();
sVideoBridgeToGPUProcess = nullptr;
}
}
@ -52,7 +69,13 @@ VideoBridgeChild::VideoBridgeChild()
VideoBridgeChild::~VideoBridgeChild() {}
VideoBridgeChild* VideoBridgeChild::GetSingleton() { return sVideoBridge; }
VideoBridgeChild* VideoBridgeChild::GetSingletonToParentProcess() {
return sVideoBridgeToParentProcess;
}
VideoBridgeChild* VideoBridgeChild::GetSingletonToGPUProcess() {
return sVideoBridgeToGPUProcess;
}
bool VideoBridgeChild::AllocUnsafeShmem(
size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
@ -103,9 +126,5 @@ bool VideoBridgeChild::IsSameProcess() const {
return OtherPid() == base::GetCurrentProcId();
}
void VideoBridgeChild::HandleFatalError(const char* aMsg) const {
dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid());
}
} // namespace layers
} // namespace mozilla

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

@ -8,7 +8,6 @@
#define MOZILLA_GFX_VIDEOBRIDGECHILD_H
#include "mozilla/layers/PVideoBridgeChild.h"
#include "mozilla/layers/VideoBridgeUtils.h"
#include "ISurfaceAllocator.h"
#include "TextureForwarder.h"
@ -23,7 +22,8 @@ class VideoBridgeChild final : public PVideoBridgeChild,
static void StartupForGPUProcess();
static void Shutdown();
static VideoBridgeChild* GetSingleton();
static VideoBridgeChild* GetSingletonToParentProcess();
static VideoBridgeChild* GetSingletonToGPUProcess();
// PVideoBridgeChild
PTextureChild* AllocPTextureChild(const SurfaceDescriptor& aSharedData,
@ -65,10 +65,8 @@ class VideoBridgeChild final : public PVideoBridgeChild,
bool CanSend() { return mCanSend; }
static void Open(Endpoint<PVideoBridgeChild>&& aEndpoint);
protected:
void HandleFatalError(const char* aMsg) const override;
static void OpenToParentProcess(Endpoint<PVideoBridgeChild>&& aEndpoint);
static void OpenToGPUProcess(Endpoint<PVideoBridgeChild>&& aEndpoint);
private:
VideoBridgeChild();

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

@ -7,7 +7,6 @@
#include "VideoBridgeParent.h"
#include "CompositorThread.h"
#include "mozilla/layers/TextureHost.h"
#include "mozilla/layers/VideoBridgeUtils.h"
namespace mozilla {
namespace layers {
@ -15,66 +14,27 @@ namespace layers {
using namespace mozilla::ipc;
using namespace mozilla::gfx;
static VideoBridgeParent* sVideoBridgeFromRddProcess;
static VideoBridgeParent* sVideoBridgeFromGpuProcess;
static VideoBridgeParent* sVideoBridgeSingleton;
VideoBridgeParent::VideoBridgeParent(VideoBridgeSource aSource)
: mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()),
mClosed(false) {
VideoBridgeParent::VideoBridgeParent() : mClosed(false) {
mSelfRef = this;
switch (aSource) {
default:
MOZ_CRASH("Unhandled case");
case VideoBridgeSource::RddProcess:
sVideoBridgeFromRddProcess = this;
break;
case VideoBridgeSource::GpuProcess:
sVideoBridgeFromGpuProcess = this;
break;
}
sVideoBridgeSingleton = this;
mCompositorThreadRef = CompositorThreadHolder::GetSingleton();
}
VideoBridgeParent::~VideoBridgeParent() {
if (sVideoBridgeFromRddProcess == this) {
sVideoBridgeFromRddProcess = nullptr;
}
if (sVideoBridgeFromGpuProcess == this) {
sVideoBridgeFromGpuProcess = nullptr;
}
}
VideoBridgeParent::~VideoBridgeParent() { sVideoBridgeSingleton = nullptr; }
/* static */
void VideoBridgeParent::Open(Endpoint<PVideoBridgeParent>&& aEndpoint,
VideoBridgeSource aSource) {
RefPtr<VideoBridgeParent> parent = new VideoBridgeParent(aSource);
CompositorThreadHolder::Loop()->PostTask(
NewRunnableMethod<Endpoint<PVideoBridgeParent>&&>(
"gfx::layers::VideoBridgeParent::Bind", parent,
&VideoBridgeParent::Bind, std::move(aEndpoint)));
}
void VideoBridgeParent::Bind(Endpoint<PVideoBridgeParent>&& aEndpoint) {
if (!aEndpoint.Bind(this)) {
void VideoBridgeParent::Open(Endpoint<PVideoBridgeParent>&& aEndpoint) {
RefPtr<VideoBridgeParent> parent = new VideoBridgeParent();
if (!aEndpoint.Bind(parent)) {
// We can't recover from this.
MOZ_CRASH("Failed to bind VideoBridgeParent to endpoint");
MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
}
}
/* static */
VideoBridgeParent* VideoBridgeParent::GetSingleton(
Maybe<VideoBridgeSource>& aSource) {
MOZ_ASSERT(aSource.isSome());
switch (aSource.value()) {
default:
MOZ_CRASH("Unhandled case");
case VideoBridgeSource::RddProcess:
MOZ_ASSERT(sVideoBridgeFromRddProcess);
return sVideoBridgeFromRddProcess;
case VideoBridgeSource::GpuProcess:
MOZ_ASSERT(sVideoBridgeFromGpuProcess);
return sVideoBridgeFromGpuProcess;
}
VideoBridgeParent* VideoBridgeParent::GetSingleton() {
return sVideoBridgeSingleton;
}
TextureHost* VideoBridgeParent::LookupTexture(uint64_t aSerial) {
@ -87,7 +47,7 @@ void VideoBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
}
void VideoBridgeParent::ActorDealloc() {
mCompositorThreadHolder = nullptr;
mCompositorThreadRef = nullptr;
mSelfRef = nullptr;
}

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

@ -13,7 +13,6 @@
namespace mozilla {
namespace layers {
enum class VideoBridgeSource : uint8_t;
class CompositorThreadHolder;
class VideoBridgeParent final : public PVideoBridgeParent,
@ -22,11 +21,7 @@ class VideoBridgeParent final : public PVideoBridgeParent,
public:
~VideoBridgeParent();
static VideoBridgeParent* GetSingleton(Maybe<VideoBridgeSource>& aSource);
static void Open(Endpoint<PVideoBridgeParent>&& aEndpoint,
VideoBridgeSource aSource);
static VideoBridgeParent* GetSingleton();
TextureHost* LookupTexture(uint64_t aSerial);
// PVideoBridgeParent
@ -59,16 +54,17 @@ class VideoBridgeParent final : public PVideoBridgeParent,
void DeallocShmem(ipc::Shmem& aShmem) override;
static void Open(Endpoint<PVideoBridgeParent>&& aEndpoint);
private:
explicit VideoBridgeParent(VideoBridgeSource aSource);
void Bind(Endpoint<PVideoBridgeParent>&& aEndpoint);
VideoBridgeParent();
void ActorDealloc() override;
// This keeps us alive until ActorDestroy(), at which point we do a
// deferred destruction of ourselves.
RefPtr<VideoBridgeParent> mSelfRef;
RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
RefPtr<CompositorThreadHolder> mCompositorThreadRef;
std::map<uint64_t, PTextureParent*> mTextureMap;

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

@ -1,37 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#ifndef IPC_VideoBridgeUtils_h
#define IPC_VideoBridgeUtils_h
#include "ipc/IPCMessageUtils.h"
namespace mozilla {
namespace layers {
enum class VideoBridgeSource : uint8_t {
RddProcess,
GpuProcess,
_Count,
};
typedef Maybe<VideoBridgeSource> MaybeVideoBridgeSource;
} // namespace layers
} // namespace mozilla
namespace IPC {
template <>
struct ParamTraits<mozilla::layers::VideoBridgeSource>
: public ContiguousEnumSerializer<
mozilla::layers::VideoBridgeSource,
mozilla::layers::VideoBridgeSource::RddProcess,
mozilla::layers::VideoBridgeSource::_Count> {};
} // namespace IPC
#endif // IPC_VideoBridgeUtils_h

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

@ -215,7 +215,6 @@ EXPORTS.mozilla.layers += [
'ipc/UiCompositorControllerParent.h',
'ipc/VideoBridgeChild.h',
'ipc/VideoBridgeParent.h',
'ipc/VideoBridgeUtils.h',
'LayerAttributes.h',
'LayerMetricsWrapper.h',
'LayersHelpers.h',