Bug 1125848 - Prevent PCompositorChild messages to be sent after the actor started shutting down. r=sotaro

This commit is contained in:
Nicolas Silva 2015-03-05 19:03:16 +01:00
Родитель 376726d034
Коммит 215a48573c
2 изменённых файлов: 146 добавлений и 0 удалений

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

@ -40,6 +40,7 @@ Atomic<int32_t> CompositableForwarder::sSerialCounter(0);
CompositorChild::CompositorChild(ClientLayerManager *aLayerManager) CompositorChild::CompositorChild(ClientLayerManager *aLayerManager)
: mLayerManager(aLayerManager) : mLayerManager(aLayerManager)
, mCanSend(true)
{ {
} }
@ -59,6 +60,7 @@ CompositorChild::Destroy()
static_cast<LayerTransactionChild*>(ManagedPLayerTransactionChild()[i]); static_cast<LayerTransactionChild*>(ManagedPLayerTransactionChild()[i]);
layers->Destroy(); layers->Destroy();
} }
MOZ_ASSERT(!mCanSend);
SendStop(); SendStop();
} }
@ -118,6 +120,7 @@ CompositorChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBac
TextureFactoryIdentifier*, TextureFactoryIdentifier*,
bool*) bool*)
{ {
MOZ_ASSERT(mCanSend);
LayerTransactionChild* c = new LayerTransactionChild(); LayerTransactionChild* c = new LayerTransactionChild();
c->AddIPDLReference(); c->AddIPDLReference();
return c; return c;
@ -307,6 +310,7 @@ CompositorChild::AddOverfillObserver(ClientLayerManager* aLayerManager)
void void
CompositorChild::ActorDestroy(ActorDestroyReason aWhy) CompositorChild::ActorDestroy(ActorDestroyReason aWhy)
{ {
MOZ_ASSERT(!mCanSend);
MOZ_ASSERT(sCompositor == this); MOZ_ASSERT(sCompositor == this);
#ifdef MOZ_B2G #ifdef MOZ_B2G
@ -451,6 +455,126 @@ CompositorChild::CancelNotifyAfterRemotePaint(TabChild* aTabChild)
} }
} }
bool
CompositorChild::SendWillStop()
{
MOZ_ASSERT(mCanSend);
// From now on the only two messages we can send are WillStop and Stop.
mCanSend = false;
return PCompositorChild::SendWillStop();
}
bool
CompositorChild::SendPause()
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendPause();
}
bool
CompositorChild::SendResume()
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendResume();
}
bool
CompositorChild::SendNotifyChildCreated(const uint64_t& id)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendNotifyChildCreated(id);
}
bool
CompositorChild::SendAdoptChild(const uint64_t& id)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendAdoptChild(id);
}
bool
CompositorChild::SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const nsIntRect& dirtyRect)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendMakeSnapshot(inSnapshot, dirtyRect);
}
bool
CompositorChild::SendFlushRendering()
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendFlushRendering();
}
bool
CompositorChild::SendGetTileSize(int32_t* tileWidth, int32_t* tileHeight)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendGetTileSize(tileWidth, tileHeight);
}
bool
CompositorChild::SendStartFrameTimeRecording(const int32_t& bufferSize, uint32_t* startIndex)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendStartFrameTimeRecording(bufferSize, startIndex);
}
bool
CompositorChild::SendStopFrameTimeRecording(const uint32_t& startIndex, nsTArray<float>* intervals)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendStopFrameTimeRecording(startIndex, intervals);
}
bool
CompositorChild::SendNotifyRegionInvalidated(const nsIntRegion& region)
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendNotifyRegionInvalidated(region);
}
bool
CompositorChild::SendRequestNotifyAfterRemotePaint()
{
MOZ_ASSERT(mCanSend);
if (!mCanSend) {
return true;
}
return PCompositorChild::SendRequestNotifyAfterRemotePaint();
}
} // namespace layers } // namespace layers
} // namespace mozilla } // namespace mozilla

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

@ -93,6 +93,25 @@ public:
void CancelNotifyAfterRemotePaint(TabChild* aTabChild); void CancelNotifyAfterRemotePaint(TabChild* aTabChild);
// Beware that these methods don't override their super-class equivalent (which
// are not virtual), they just overload them.
// All of these Send* methods just add a sanity check (that it is not too late
// send a message) and forward the call to the super-class's equivalent method.
// This means that it is correct to call directly the super-class methods, but
// you won't get the extra safety provided here.
bool SendWillStop();
bool SendPause();
bool SendResume();
bool SendNotifyChildCreated(const uint64_t& id);
bool SendAdoptChild(const uint64_t& id);
bool SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const nsIntRect& dirtyRect);
bool SendFlushRendering();
bool SendGetTileSize(int32_t* tileWidth, int32_t* tileHeight);
bool SendStartFrameTimeRecording(const int32_t& bufferSize, uint32_t* startIndex);
bool SendStopFrameTimeRecording(const uint32_t& startIndex, nsTArray<float>* intervals);
bool SendNotifyRegionInvalidated(const nsIntRegion& region);
bool SendRequestNotifyAfterRemotePaint();
private: private:
// Private destructor, to discourage deletion outside of Release(): // Private destructor, to discourage deletion outside of Release():
virtual ~CompositorChild(); virtual ~CompositorChild();
@ -159,6 +178,9 @@ private:
// When we receive overfill numbers, notify these client layer managers // When we receive overfill numbers, notify these client layer managers
nsAutoTArray<ClientLayerManager*,0> mOverfillObservers; nsAutoTArray<ClientLayerManager*,0> mOverfillObservers;
// True until the beginning of the two-step shutdown sequence of this actor.
bool mCanSend;
}; };
} // layers } // layers