Make PLayerTransaction's constructor async. (bug 1350634, ipc_r=billm, r=mattwoodrow, r=kats)

PLayerTransaction's constructor was previously synchronous so we could
return a TextureFactoryIdentifier. This is quite reliably available
already in the case of opening a tab, due to RenderFrameParent knowing
which compositor it is attached to, so we can make the constructor
asynchronous.

In the top-level widget case, we add a new synchronous message to find
the TextureFactoryIdentifier.
This commit is contained in:
David Anderson 2017-04-30 17:22:56 -07:00
parent d79729cfc6
commit d7a1f66c55
13 changed files with 45 additions and 42 deletions

View file

@ -35,6 +35,7 @@
#include "mozilla/layers/IAPZCTreeManager.h" #include "mozilla/layers/IAPZCTreeManager.h"
#include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/PLayerTransactionChild.h"
#include "mozilla/layers/ShadowLayers.h" #include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layout/RenderFrameChild.h" #include "mozilla/layout/RenderFrameChild.h"
@ -2710,11 +2711,9 @@ TabChild::InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIden
if (lf) { if (lf) {
nsTArray<LayersBackend> backends; nsTArray<LayersBackend> backends;
backends.AppendElement(mTextureFactoryIdentifier.mParentBackend); backends.AppendElement(mTextureFactoryIdentifier.mParentBackend);
bool success;
PLayerTransactionChild* shadowManager = PLayerTransactionChild* shadowManager =
compositorChild->SendPLayerTransactionConstructor(backends, compositorChild->SendPLayerTransactionConstructor(backends, aLayersId);
aLayersId, &mTextureFactoryIdentifier, &success); if (shadowManager) {
if (shadowManager && success) {
lf->SetShadowManager(shadowManager); lf->SetShadowManager(shadowManager);
lf->IdentifyTextureHost(mTextureFactoryIdentifier); lf->IdentifyTextureHost(mTextureFactoryIdentifier);
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier); ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
@ -3097,20 +3096,20 @@ TabChild::ReinitRendering()
wr::AsPipelineId(mLayersId), wr::AsPipelineId(mLayersId),
&mTextureFactoryIdentifier); &mTextureFactoryIdentifier);
} else { } else {
bool success; bool success = false;
nsTArray<LayersBackend> ignored; nsTArray<LayersBackend> ignored;
PLayerTransactionChild* shadowManager = PLayerTransactionChild* shadowManager = cb->SendPLayerTransactionConstructor(ignored, LayersId());
cb->SendPLayerTransactionConstructor(ignored, LayersId(), &mTextureFactoryIdentifier, &success); if (shadowManager &&
shadowManager->SendGetTextureFactoryIdentifier(&mTextureFactoryIdentifier) &&
mTextureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_NONE)
{
success = true;
}
if (!success) { if (!success) {
NS_WARNING("failed to re-allocate layer transaction"); NS_WARNING("failed to re-allocate layer transaction");
return; return;
} }
if (!shadowManager) {
NS_WARNING("failed to re-construct LayersChild");
return;
}
RefPtr<LayerManager> lm = mPuppetWidget->RecreateLayerManager(shadowManager); RefPtr<LayerManager> lm = mPuppetWidget->RecreateLayerManager(shadowManager);
ShadowLayerForwarder* lf = lm->AsShadowForwarder(); ShadowLayerForwarder* lf = lm->AsShadowForwarder();
lf->IdentifyTextureHost(mTextureFactoryIdentifier); lf->IdentifyTextureHost(mTextureFactoryIdentifier);

View file

@ -330,9 +330,7 @@ CompositorBridgeChild::CompositorIsInGPUProcess()
PLayerTransactionChild* PLayerTransactionChild*
CompositorBridgeChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints, CompositorBridgeChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId, const uint64_t& aId)
TextureFactoryIdentifier*,
bool*)
{ {
LayerTransactionChild* c = new LayerTransactionChild(aId); LayerTransactionChild* c = new LayerTransactionChild(aId);
c->AddIPDLReference(); c->AddIPDLReference();

View file

@ -248,9 +248,7 @@ private:
virtual PLayerTransactionChild* virtual PLayerTransactionChild*
AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints, AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId, const uint64_t& aId) override;
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool* aSuccess) override;
virtual bool DeallocPLayerTransactionChild(PLayerTransactionChild *aChild) override; virtual bool DeallocPLayerTransactionChild(PLayerTransactionChild *aChild) override;

View file

@ -1437,9 +1437,7 @@ CompositorBridgeParent::NewCompositor(const nsTArray<LayersBackend>& aBackendHin
PLayerTransactionParent* PLayerTransactionParent*
CompositorBridgeParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints, CompositorBridgeParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId, const uint64_t& aId)
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool *aSuccess)
{ {
MOZ_ASSERT(aId == 0); MOZ_ASSERT(aId == 0);
@ -1447,16 +1445,13 @@ CompositorBridgeParent::AllocPLayerTransactionParent(const nsTArray<LayersBacken
if (!mLayerManager) { if (!mLayerManager) {
NS_WARNING("Failed to initialise Compositor"); NS_WARNING("Failed to initialise Compositor");
*aSuccess = false;
LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, 0); LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, 0);
p->AddIPDLReference(); p->AddIPDLReference();
return p; return p;
} }
mCompositionManager = new AsyncCompositionManager(this, mLayerManager); mCompositionManager = new AsyncCompositionManager(this, mLayerManager);
*aSuccess = true;
*aTextureFactoryIdentifier = mLayerManager->GetTextureFactoryIdentifier();
LayerTransactionParent* p = new LayerTransactionParent(mLayerManager, this, 0); LayerTransactionParent* p = new LayerTransactionParent(mLayerManager, this, 0);
p->AddIPDLReference(); p->AddIPDLReference();
return p; return p;

View file

@ -510,9 +510,7 @@ protected:
virtual PLayerTransactionParent* virtual PLayerTransactionParent*
AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints, AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId, const uint64_t& aId) override;
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool* aSuccess) override;
virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override; virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override;
virtual void ScheduleTask(already_AddRefed<CancelableRunnable>, int); virtual void ScheduleTask(already_AddRefed<CancelableRunnable>, int);

View file

@ -62,9 +62,7 @@ CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
PLayerTransactionParent* PLayerTransactionParent*
CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent( CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent(
const nsTArray<LayersBackend>&, const nsTArray<LayersBackend>&,
const uint64_t& aId, const uint64_t& aId)
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool *aSuccess)
{ {
MOZ_ASSERT(aId != 0); MOZ_ASSERT(aId != 0);
@ -85,8 +83,6 @@ CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent(
if (state && state->mLayerManager) { if (state && state->mLayerManager) {
state->mCrossProcessParent = this; state->mCrossProcessParent = this;
HostLayerManager* lm = state->mLayerManager; HostLayerManager* lm = state->mLayerManager;
*aTextureFactoryIdentifier = lm->GetCompositor()->GetTextureFactoryIdentifier();
*aSuccess = true;
LayerTransactionParent* p = new LayerTransactionParent(lm, this, aId); LayerTransactionParent* p = new LayerTransactionParent(lm, this, aId);
p->AddIPDLReference(); p->AddIPDLReference();
sIndirectLayerTrees[aId].mLayerTree = p; sIndirectLayerTrees[aId].mLayerTree = p;
@ -97,7 +93,6 @@ CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent(
} }
NS_WARNING("Created child without a matching parent?"); NS_WARNING("Created child without a matching parent?");
*aSuccess = false;
LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, aId); LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, aId);
p->AddIPDLReference(); p->AddIPDLReference();
return p; return p;

View file

@ -91,9 +91,7 @@ public:
virtual PLayerTransactionParent* virtual PLayerTransactionParent*
AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints, AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId, const uint64_t& aId) override;
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool *aSuccess) override;
virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override; virtual bool DeallocPLayerTransactionParent(PLayerTransactionParent* aLayers) override;

View file

@ -1053,5 +1053,17 @@ LayerTransactionParent::RecvRecordPaintTimes(const PaintTiming& aTiming)
return IPC_OK(); return IPC_OK();
} }
mozilla::ipc::IPCResult
LayerTransactionParent::RecvGetTextureFactoryIdentifier(TextureFactoryIdentifier* aIdentifier)
{
if (!mLayerManager) {
// Default constructor sets mParentBackend to LAYERS_NONE.
return IPC_OK();
}
*aIdentifier = mLayerManager->GetTextureFactoryIdentifier();
return IPC_OK();
}
} // namespace layers } // namespace layers
} // namespace mozilla } // namespace mozilla

View file

@ -141,6 +141,7 @@ protected:
virtual mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId, virtual mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId,
nsTArray<ScrollableLayerGuid>&& aTargets) override; nsTArray<ScrollableLayerGuid>&& aTargets) override;
virtual mozilla::ipc::IPCResult RecvRecordPaintTimes(const PaintTiming& aTiming) override; virtual mozilla::ipc::IPCResult RecvRecordPaintTimes(const PaintTiming& aTiming) override;
virtual mozilla::ipc::IPCResult RecvGetTextureFactoryIdentifier(TextureFactoryIdentifier* aIdentifier) override;
bool SetLayerAttributes(const OpSetLayerAttributes& aOp); bool SetLayerAttributes(const OpSetLayerAttributes& aOp);

View file

@ -218,8 +218,7 @@ parent:
// layersBackendHints is an ordered list of preffered backends where // layersBackendHints is an ordered list of preffered backends where
// layersBackendHints[0] is the best backend. If any hints are LayersBackend::LAYERS_NONE // layersBackendHints[0] is the best backend. If any hints are LayersBackend::LAYERS_NONE
// that hint is ignored. // that hint is ignored.
sync PLayerTransaction(LayersBackend[] layersBackendHints, uint64_t id) async PLayerTransaction(LayersBackend[] layersBackendHints, uint64_t id);
returns (TextureFactoryIdentifier textureFactoryIdentifier, bool success);
// Notify the compositor that a region of the screen has been invalidated. // Notify the compositor that a region of the screen has been invalidated.
async NotifyRegionInvalidated(nsIntRegion region); async NotifyRegionInvalidated(nsIntRegion region);

View file

@ -18,6 +18,7 @@ using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
using class mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h"; using class mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h";
using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h"; using mozilla::layers::FrameMetrics::ViewID from "FrameMetrics.h";
using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h"; using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h";
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h";
using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h"; using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h";
using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h"; using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
@ -118,6 +119,9 @@ parent:
// Query a named property from the last frame // Query a named property from the last frame
sync RequestProperty(nsString property) returns (float value); sync RequestProperty(nsString property) returns (float value);
// Return the TextureFactoryIdentifier for this compositor.
sync GetTextureFactoryIdentifier() returns (TextureFactoryIdentifier aIdentifier);
// Tell the compositor to notify APZ that a layer has been confirmed for an // Tell the compositor to notify APZ that a layer has been confirmed for an
// input event. // input event.
async SetConfirmedTargetAPZC(uint64_t aInputBlockId, ScrollableLayerGuid[] aTargets); async SetConfirmedTargetAPZC(uint64_t aInputBlockId, ScrollableLayerGuid[] aTargets);

View file

@ -1001,8 +1001,6 @@ description =
description = description =
[PCompositorBridge::StopFrameTimeRecording] [PCompositorBridge::StopFrameTimeRecording]
description = description =
[PCompositorBridge::PLayerTransaction]
description =
[PCompositorBridge::SyncWithCompositor] [PCompositorBridge::SyncWithCompositor]
description = description =
[PCompositorBridge::PWebRenderBridge] [PCompositorBridge::PWebRenderBridge]
@ -1036,6 +1034,8 @@ description =
description = description =
[PLayerTransaction::RequestProperty] [PLayerTransaction::RequestProperty]
description = description =
[PLayerTransaction::GetTextureFactoryIdentifier]
description = bug 1350634
[PUiCompositorController::Pause] [PUiCompositorController::Pause]
description = description =
[PUiCompositorController::Resume] [PUiCompositorController::Resume]

View file

@ -12,6 +12,7 @@
#include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/PLayerTransactionChild.h"
#include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/ImageBridgeChild.h"
#include "LiveResizeListener.h" #include "LiveResizeListener.h"
#include "nsBaseWidget.h" #include "nsBaseWidget.h"
@ -1344,8 +1345,13 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
bool success = false; bool success = false;
if (!backendHints.IsEmpty()) { if (!backendHints.IsEmpty()) {
shadowManager = mCompositorBridgeChild->SendPLayerTransactionConstructor( shadowManager =
backendHints, 0, &textureFactoryIdentifier, &success); mCompositorBridgeChild->SendPLayerTransactionConstructor(backendHints, 0);
if (shadowManager->SendGetTextureFactoryIdentifier(&textureFactoryIdentifier) &&
textureFactoryIdentifier.mParentBackend != LayersBackend::LAYERS_NONE)
{
success = true;
}
} }
if (!success) { if (!success) {