Backed out changeset 7b113a6167e9 (
bug 1215265) for mass bustage CLOSED TREE
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -44,19 +44,24 @@ CompositorChild::CompositorChild(ClientL
{
}
CompositorChild::~CompositorChild()
{
if (mCanSend) {
gfxCriticalError() << "CompositorChild was not deinitialized";
}
- if (sCompositor == this) {
- sCompositor = nullptr;
- }
+}
+
+static void DeferredDestroyCompositor(RefPtr<CompositorParent> aCompositorParent,
+ RefPtr<CompositorChild> aCompositorChild)
+{
+ // Bug 848949 needs to be fixed before
+ // we can close the channel properly
+ //aCompositorChild->Close();
}
void
CompositorChild::Destroy()
{
// This must not be called from the destructor!
MOZ_ASSERT(mRefCnt != 0);
@@ -91,27 +96,21 @@ CompositorChild::Destroy()
ManagedPLayerTransactionChild(transactions);
for (int i = transactions.Length() - 1; i >= 0; --i) {
RefPtr<LayerTransactionChild> layers =
static_cast<LayerTransactionChild*>(transactions[i]);
layers->Destroy();
}
SendStop();
-}
-/*static*/ void
-CompositorChild::ShutdownLayersIPC()
-{
- if (sCompositor) {
- sCompositor->Destroy();
- do {
- NS_ProcessNextEvent(nullptr, true);
- } while (sCompositor);
- }
+ // The DeferredDestroyCompositor task takes ownership of compositorParent and
+ // will release them when it runs.
+ MessageLoop::current()->PostTask(FROM_HERE,
+ NewRunnableFunction(DeferredDestroyCompositor, mCompositorParent, selfRef));
}
bool
CompositorChild::LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId,
FrameMetrics& aFrame)
{
SharedFrameMetricsData* data = mFrameMetricsTable.Get(aId);
if (data) {
--- a/gfx/layers/ipc/CompositorChild.h
+++ b/gfx/layers/ipc/CompositorChild.h
@@ -118,18 +118,16 @@ public:
bool SendMakeSnapshot(const SurfaceDescriptor& inSnapshot, const gfx::IntRect& 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();
- static void ShutdownLayersIPC();
-
private:
// Private destructor, to discourage deletion outside of Release():
virtual ~CompositorChild();
virtual PLayerTransactionChild*
AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -1745,17 +1745,17 @@ public:
base::ProcessHandle aPeerProcess,
mozilla::ipc::ProtocolCloneContext* aCtx) override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
// FIXME/bug 774388: work out what shutdown protocol we need.
virtual bool RecvRequestOverfill() override { return true; }
virtual bool RecvWillStop() override { return true; }
- virtual bool RecvStop() override;
+ virtual bool RecvStop() override { return true; }
virtual bool RecvPause() override { return true; }
virtual bool RecvResume() override { return true; }
virtual bool RecvNotifyHidden(const uint64_t& id) override;
virtual bool RecvNotifyVisible(const uint64_t& id) override;
virtual bool RecvNotifyChildCreated(const uint64_t& child) override;
virtual bool RecvAdoptChild(const uint64_t& child) override { return false; }
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
const gfx::IntRect& aRect) override
@@ -1825,17 +1825,16 @@ public:
TimeStamp& aCompositeEnd);
protected:
void OnChannelConnected(int32_t pid) override { mCompositorThreadHolder = sCompositorThreadHolder; }
private:
// Private destructor, to discourage deletion outside of Release():
virtual ~CrossProcessCompositorParent();
- void Destroy();
void DeferredDestroy();
// There can be many CPCPs, and IPDL-generated code doesn't hold a
// reference to top-level actors. So we hold a reference to
// ourself. This is released (deferred) in ActorDestroy().
RefPtr<CrossProcessCompositorParent> mSelfRef;
Transport* mTransport;
@@ -1937,37 +1936,24 @@ CrossProcessCompositorParent::RecvNotify
bool
CrossProcessCompositorParent::RecvRequestNotifyAfterRemotePaint()
{
mNotifyAfterRemotePaint = true;
return true;
}
void
-CrossProcessCompositorParent::Destroy()
+CrossProcessCompositorParent::ActorDestroy(ActorDestroyReason aWhy)
{
RefPtr<CompositorLRU> lru = CompositorLRU::GetSingleton();
lru->Remove(this);
-}
-void
-CrossProcessCompositorParent::ActorDestroy(ActorDestroyReason aWhy)
-{
- Destroy();
-}
-
-bool
-CrossProcessCompositorParent::RecvStop()
-{
- Destroy();
- // We must keep this object alive untill the code handling message
- // reception is finished on this thread.
- MessageLoop::current()->PostTask(FROM_HERE,
- NewRunnableMethod(this, &CrossProcessCompositorParent::DeferredDestroy));
- return true;
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &CrossProcessCompositorParent::DeferredDestroy));
}
PLayerTransactionParent*
CrossProcessCompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>&,
const uint64_t& aId,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
bool *aSuccess)
{
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -740,27 +740,26 @@ gfxPlatform::InitLayersIPC()
/* static */ void
gfxPlatform::ShutdownLayersIPC()
{
if (!sLayersIPCIsUp) {
return;
}
sLayersIPCIsUp = false;
- if (XRE_IsParentProcess()) {
+ if (XRE_IsParentProcess())
+ {
// This must happen after the shutdown of media and widgets, which
// are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification.
layers::ImageBridgeChild::ShutDown();
#ifdef MOZ_WIDGET_GONK
layers::SharedBufferManagerChild::ShutDown();
#endif
layers::CompositorParent::ShutDown();
- } else {
- CompositorChild::ShutdownLayersIPC();
}
}
gfxPlatform::~gfxPlatform()
{
mScreenReferenceSurface = nullptr;
mScreenReferenceDrawTarget = nullptr;
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -246,24 +246,22 @@ nsBaseWidget::Shutdown()
void nsBaseWidget::DestroyCompositor()
{
if (mCompositorChild) {
// XXX CompositorChild and CompositorParent might be re-created in
// ClientLayerManager destructor. See bug 1133426.
RefPtr<CompositorChild> compositorChild = mCompositorChild;
RefPtr<CompositorParent> compositorParent = mCompositorParent;
mCompositorChild->Destroy();
- mCompositorChild = nullptr;
}
// Can have base widgets that are things like tooltips
// which don't have CompositorVsyncDispatchers
if (mCompositorVsyncDispatcher) {
mCompositorVsyncDispatcher->Shutdown();
- mCompositorVsyncDispatcher = nullptr;
}
}
void nsBaseWidget::DestroyLayerManager()
{
if (mLayerManager) {
mLayerManager->Destroy();
mLayerManager = nullptr;