Bug 1621762: Part 5 - Change PWebGL alloc+constructor to Initialize message r=jgilbert,jld

We need to separate WebGL actor construction and initialization since IpdlQueue initialization needs the actor to already exist.

Differential Revision: https://phabricator.services.mozilla.com/D68262
This commit is contained in:
David Parks 2020-04-30 22:23:48 +00:00
Родитель 7ac7bc9be6
Коммит b18b3bfd97
10 изменённых файлов: 38 добавлений и 41 удалений

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

@ -750,15 +750,17 @@ bool ClientWebGLContext::CreateHostContext(const uvec2& requestedSize) {
auto sink = MakeUnique<HostWebGLCommandSinkP>(commandPcq->TakeConsumer(),
responsePcq->TakeProducer());
// Use the error/warning and command queues to construct a
// ClientWebGLContext in this process and a HostWebGLContext
// in the host process.
outOfProcess.mWebGLChild = new dom::WebGLChild(*this);
if (!cbc->SendPWebGLConstructor(outOfProcess.mWebGLChild.get(), initDesc,
&notLost.info)) {
outOfProcess.mWebGLChild = new WebGLChild(*this);
outOfProcess.mWebGLChild = static_cast<dom::WebGLChild*>(
cbc->SendPWebGLConstructor(outOfProcess.mWebGLChild));
if (!outOfProcess.mWebGLChild) {
return Err("SendPWebGLConstructor failed");
}
if (!outOfProcess.mWebGLChild->SendInitialize(initDesc, &notLost.info)) {
return Err("WebGL actor Initialize failed");
}
notLost.outOfProcess = Some(std::move(outOfProcess));
return Ok();
}();

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

@ -11,6 +11,8 @@ include protocol PLayerTransaction;
using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
using mozilla::webgl::ContextLossReason from "mozilla/dom/WebGLIpdl.h";
using std::string from "ipc/IPCMessageUtils.h";
using mozilla::webgl::InitContextDesc from "mozilla/dom/WebGLIpdl.h";
using mozilla::webgl::InitContextResult from "mozilla/dom/WebGLIpdl.h";
namespace mozilla {
namespace dom {
@ -25,6 +27,9 @@ sync refcounted protocol PWebGL
manager PCompositorBridge;
parent:
sync Initialize(InitContextDesc desc)
returns (InitContextResult res);
async __delete__();
// DLP: TODO: Does this need to be sync?

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

@ -14,30 +14,28 @@ namespace mozilla {
namespace dom {
/* static */
RefPtr<WebGLParent> WebGLParent::Create(const webgl::InitContextDesc& desc,
webgl::InitContextResult* const out) {
RefPtr<WebGLParent> parent = new WebGLParent;
mozilla::ipc::IPCResult WebGLParent::RecvInitialize(
const webgl::InitContextDesc& desc, webgl::InitContextResult* const out) {
auto remotingData = Some(HostWebGLContext::RemotingData{
*parent, {}, // std::move(commandSink),
*this, {}, // std::move(commandSink),
});
parent->mHost = HostWebGLContext::Create(
mHost = HostWebGLContext::Create(
{
{},
std::move(remotingData),
},
desc, out);
if (!parent->mHost) {
WEBGL_BRIDGE_LOGE("Failed to create HostWebGLContext");
return nullptr;
if (!mHost) {
return IPC_FAIL(this, "Failed to create HostWebGLContext");
}
if (!parent->BeginCommandQueueDrain()) {
WEBGL_BRIDGE_LOGE("Failed to start WebGL command queue drain");
return nullptr;
if (!BeginCommandQueueDrain()) {
return IPC_FAIL(this, "Failed to start WebGL command queue drain");
}
return parent;
return IPC_OK();
}
WebGLParent::WebGLParent() = default;

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

@ -28,13 +28,15 @@ class WebGLParent final : public PWebGLParent,
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLParent, override);
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLParent)
static RefPtr<WebGLParent> Create(const webgl::InitContextDesc&,
webgl::InitContextResult* out);
mozilla::ipc::IPCResult RecvInitialize(const webgl::InitContextDesc&,
webgl::InitContextResult* out);
RefPtr<layers::SharedSurfaceTextureClient> GetVRFrame(webgl::ObjectId);
private:
// For IPDL:
WebGLParent();
private:
~WebGLParent();
bool BeginCommandQueueDrain();

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

@ -12,7 +12,6 @@
#include "base/message_loop.h" // for MessageLoop
#include "base/task.h" // for NewRunnableMethod, etc
#include "mozilla/StaticPrefs_layers.h"
#include "mozilla/dom/WebGLChild.h"
#include "mozilla/layers/CompositorManagerChild.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/APZChild.h"

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

@ -302,8 +302,7 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent,
return IPC_FAIL_NO_REASON(this);
}
virtual already_AddRefed<PWebGLParent> AllocPWebGLParent(
const webgl::InitContextDesc&, webgl::InitContextResult* out) = 0;
virtual already_AddRefed<PWebGLParent> AllocPWebGLParent() = 0;
bool mCanSend;
@ -693,8 +692,7 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
WebRenderBridgeParent* GetWrBridge() { return mWrBridge; }
webgpu::WebGPUParent* GetWebGPUBridge() { return mWebGPUBridge; }
already_AddRefed<PWebGLParent> AllocPWebGLParent(
const webgl::InitContextDesc&, webgl::InitContextResult*) override {
already_AddRefed<PWebGLParent> AllocPWebGLParent() override {
MOZ_ASSERT_UNREACHABLE(
"This message is CrossProcessCompositorBridgeParent only");
return nullptr;

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

@ -766,11 +766,9 @@ mozilla::ipc::IPCResult ContentCompositorBridgeParent::RecvPreferredDXGIAdapter(
}
already_AddRefed<dom::PWebGLParent>
ContentCompositorBridgeParent::AllocPWebGLParent(
const webgl::InitContextDesc& aInitDesc,
webgl::InitContextResult* const out) {
RefPtr<dom::PWebGLParent> ret = dom::WebGLParent::Create(aInitDesc, out);
return ret.forget();
ContentCompositorBridgeParent::AllocPWebGLParent() {
RefPtr<dom::PWebGLParent> parent = new dom::WebGLParent();
return parent.forget();
}
} // namespace layers

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

@ -161,8 +161,7 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase {
return IPC_FAIL_NO_REASON(this);
}
already_AddRefed<dom::PWebGLParent> AllocPWebGLParent(
const webgl::InitContextDesc&, webgl::InitContextResult* out) override;
already_AddRefed<dom::PWebGLParent> AllocPWebGLParent() override;
// Use DidCompositeLocked if you already hold a lock on
// sIndirectLayerTreesLock; Otherwise use DidComposite, which would request

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

@ -48,8 +48,6 @@ using mozilla::wr::MaybeExternalImageId from "mozilla/webrender/WebRenderTypes.h
using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h";
using struct DxgiAdapterDesc from "mozilla/D3DMessageUtils.h";
using mozilla::webgl::InitContextDesc from "mozilla/dom/WebGLIpdl.h";
using mozilla::webgl::InitContextResult from "mozilla/dom/WebGLIpdl.h";
namespace mozilla {
namespace layers {
@ -300,9 +298,7 @@ parent:
async RequestFxrOutput();
// Actor that represents one WebGL context.
// (modeled after `sync PBackgroundLSSnapshot`)
sync PWebGL(InitContextDesc desc)
returns (InitContextResult res);
async PWebGL();
child:
// Send back Compositor Frame Metrics from APZCs so tiled layers can

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

@ -1213,8 +1213,8 @@ description = Synchronous ping allowing worker thread to confirm actor is create
description = Synchronous launch of a child process that in turn launches and sandboxes another process. Called on a dedicated thread and targets a dedicated process, so this shouldn't block anything.
[PWebGL::UpdateCompositableHandle]
description = Compositing WebGL is synchronous by spec. Updates to WebGL canvas contents must be updated in lockstep with other DOM updates.
[PCompositorBridge::PWebGL]
description = Creation of WebGL contexts is synchronous by spec.
[PWebGL::Initialize]
description = Initialization of WebGL contexts is synchronous by spec.
[PSocketProcess::GetTLSClientCert]
description = Synchronously get client certificate and key from parent process. Once bug 696976 has been fixed, this can be removed.