Skip to content

Commit

Permalink
Feodor2#284 such a followup
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor committed Oct 30, 2023
1 parent 5047fe5 commit 310f3ad
Show file tree
Hide file tree
Showing 45 changed files with 217 additions and 663 deletions.
7 changes: 3 additions & 4 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,10 +1022,9 @@ mozilla::ipc::IPCResult ContentParent::RecvLaunchRDDProcess(
Preferences::GetBool("media.rdd-process.enabled", false)) {
RDDProcessManager* rdd = RDDProcessManager::Get();
if (rdd) {
bool rddOpened = rdd->LaunchRDDProcess();
if (rddOpened) {
rddOpened = rdd->CreateContentBridge(OtherPid(), aEndpoint);
}
rdd->LaunchRDDProcess();

bool rddOpened = rdd->CreateContentBridge(OtherPid(), aEndpoint);

if (NS_WARN_IF(!rddOpened)) {
*aRv = NS_ERROR_NOT_AVAILABLE;
Expand Down
12 changes: 3 additions & 9 deletions dom/media/ipc/PRDD.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
* 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 GraphicsMessages;
include MemoryReportTypes;
include PrefsTypes;

include protocol PProfiler;
include protocol PRemoteDecoderManager;
include protocol PVideoBridge;

using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";

Expand All @@ -22,9 +20,7 @@ protocol PRDD
{
parent:

async Init(GfxVarUpdate[] vars,
FileDescriptor? sandboxBroker,
bool startMacSandbox);
async Init(FileDescriptor? sandboxBroker, bool startMacSandbox);

async InitProfiler(Endpoint<PProfilerChild> endpoint);

Expand All @@ -38,11 +34,9 @@ parent:

async PreferenceUpdate(Pref pref);

async UpdateVar(GfxVarUpdate var);

async InitVideoBridge(Endpoint<PVideoBridgeChild> endpoint);

child:
// args TBD, sent when init complete. Occurs once, after Init().
async InitComplete();

async InitCrashReporter(Shmem shmem, NativeThreadId threadId);

Expand Down
2 changes: 1 addition & 1 deletion dom/media/ipc/PRemoteDecoderManager.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sync protocol PRemoteDecoderManager
parent:
sync PRemoteDecoder(RemoteDecoderInfoIPDL info,
OptionSet options,
TextureFactoryIdentifier? identifier)
TextureFactoryIdentifier identifier)
returns (bool success,
nsCString aErrorDescription);

Expand Down
47 changes: 19 additions & 28 deletions dom/media/ipc/RDDChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
* 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"
Expand All @@ -22,9 +19,8 @@
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);
}

Expand All @@ -48,23 +44,34 @@ bool RDDChild::Init(bool aStartMacSandbox) {
}
#endif // XP_LINUX && MOZ_SANDBOX

nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();

SendInit(updates, brokerFd, aStartMacSandbox);
SendInit(brokerFd, aStartMacSandbox);

#ifdef MOZ_GECKO_PROFILER
Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
#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,
Expand All @@ -75,15 +82,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(
const MemoryReport& aReport) {
if (mMemoryReportRequest) {
Expand All @@ -106,13 +104,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();
}

Expand Down
13 changes: 6 additions & 7 deletions dom/media/ipc/RDDChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "mozilla/ipc/CrashReporterHelper.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/gfxVarReceiver.h"
#include "mozilla/gfx/GPUProcessListener.h"

namespace mozilla {

Expand All @@ -23,9 +21,7 @@ class MemoryReportRequestHost;
class RDDProcessHost;

class RDDChild final : public PRDDChild,
public ipc::CrashReporterHelper<GeckoProcessType_RDD>,
public gfx::gfxVarReceiver,
public gfx::GPUProcessListener {
public ipc::CrashReporterHelper<GeckoProcessType_RDD> {
typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;

public:
Expand All @@ -34,8 +30,10 @@ class RDDChild final : public PRDDChild,

bool Init(bool aStartMacSandbox);

void OnCompositorUnexpectedShutdown() override;
void OnVarChanged(const GfxVarUpdate& aVar) override;
bool EnsureRDDReady();

// PRDDChild overrides.
mozilla::ipc::IPCResult RecvInitComplete();

void ActorDestroy(ActorDestroyReason aWhy) override;

Expand All @@ -55,6 +53,7 @@ class RDDChild final : public PRDDChild,
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
UniquePtr<SandboxBroker> mSandboxBroker;
#endif
bool mRDDReady;
};

} // namespace mozilla
Expand Down
29 changes: 2 additions & 27 deletions dom/media/ipc/RDDParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/gfx/gfxVars.h"

#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
Expand All @@ -40,7 +39,6 @@
namespace mozilla {

using namespace ipc;
using namespace gfx;

static RDDParent* sRDDParent;

Expand Down Expand Up @@ -83,8 +81,6 @@ bool RDDParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
return false;
}

gfxVars::Initialize();

mozilla::ipc::SetThisProcessName("RDD Process");
return true;
}
Expand Down Expand Up @@ -117,12 +113,8 @@ static void StartRDDMacSandbox() {
#endif

mozilla::ipc::IPCResult RDDParent::RecvInit(
nsTArray<GfxVarUpdate>&& vars, const Maybe<FileDescriptor>& aBrokerFd,
bool aStartMacSandbox) {
for (const auto& var : vars) {
gfxVars::ApplyUpdate(var);
}

const Maybe<FileDescriptor>& aBrokerFd, bool aStartMacSandbox) {
Unused << SendInitComplete();
#if defined(MOZ_SANDBOX)
# if defined(XP_MACOSX)
// Close all current connections to the WindowServer. This ensures that the
Expand All @@ -149,11 +141,6 @@ mozilla::ipc::IPCResult RDDParent::RecvInit(
return IPC_OK();
}

IPCResult RDDParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) {
gfxVars::ApplyUpdate(aUpdate);
return IPC_OK();
}

mozilla::ipc::IPCResult RDDParent::RecvInitProfiler(
Endpoint<PProfilerChild>&& aEndpoint) {
#ifdef MOZ_GECKO_PROFILER
Expand All @@ -170,15 +157,6 @@ mozilla::ipc::IPCResult RDDParent::RecvNewContentRemoteDecoderManager(
return IPC_OK();
}

mozilla::ipc::IPCResult RDDParent::RecvInitVideoBridge(
Endpoint<PVideoBridgeChild>&& aEndpoint) {
if (!RemoteDecoderManagerParent::CreateVideoBridgeToOtherProcess(
std::move(aEndpoint))) {
return IPC_FAIL_NO_REASON(this);
}
return IPC_OK();
}

mozilla::ipc::IPCResult RDDParent::RecvRequestMemoryReport(
const uint32_t& aGeneration, const bool& aAnonymize,
const bool& aMinimizeMemoryUsage, const Maybe<FileDescriptor>& aDMDFile) {
Expand Down Expand Up @@ -219,9 +197,6 @@ void RDDParent::ActorDestroy(ActorDestroyReason aWhy) {
}
#endif

RemoteDecoderManagerParent::ShutdownVideoBridge();

gfxVars::Shutdown();
CrashReporterClient::DestroySingleton();
XRE_ShutdownChildProcess();
}
Expand Down
6 changes: 1 addition & 5 deletions dom/media/ipc/RDDParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,18 @@ class RDDParent final : public PRDDParent {
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
MessageLoop* aIOLoop, IPC::Channel* aChannel);

mozilla::ipc::IPCResult RecvInit(nsTArray<GfxVarUpdate>&& vars,
const Maybe<ipc::FileDescriptor>& aBrokerFd,
mozilla::ipc::IPCResult RecvInit(const Maybe<ipc::FileDescriptor>& aBrokerFd,
bool aStartMacSandbox);
mozilla::ipc::IPCResult RecvInitProfiler(
Endpoint<PProfilerChild>&& aEndpoint);

mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager(
Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitVideoBridge(
Endpoint<PVideoBridgeChild>&& aEndpoint);
mozilla::ipc::IPCResult RecvRequestMemoryReport(
const uint32_t& generation, const bool& anonymize,
const bool& minimizeMemoryUsage,
const Maybe<ipc::FileDescriptor>& DMDFile);
mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref);
mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref);

void ActorDestroy(ActorDestroyReason aWhy) override;

Expand Down
Loading

0 comments on commit 310f3ad

Please sign in to comment.