Commit 0622d767 authored by David Anderson's avatar David Anderson
Browse files

Fix a race condition between VideoBridge and Compositor thread shutdown. (bug...

Fix a race condition between VideoBridge and Compositor thread shutdown. (bug 1356365, r=mattwoodrow)
parent cedb307a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ VsyncBridgeParent::VsyncBridgeParent()
 : mOpen(false)
{
  MOZ_COUNT_CTOR(VsyncBridgeParent);
  mCompositorThreadRef = CompositorThreadHolder::GetSingleton();
}

VsyncBridgeParent::~VsyncBridgeParent()
@@ -75,6 +76,7 @@ void
VsyncBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
{
  mOpen = false;
  mCompositorThreadRef = nullptr;
}

void
+5 −0
Original line number Diff line number Diff line
@@ -10,6 +10,10 @@
#include "mozilla/gfx/PVsyncBridgeParent.h"

namespace mozilla {
namespace layers {
class CompositorThreadHolder;
} // namespace layers

namespace gfx {

class VsyncBridgeParent final : public PVsyncBridgeParent
@@ -34,6 +38,7 @@ private:

private:
  bool mOpen;
  RefPtr<layers::CompositorThreadHolder> mCompositorThreadRef;
};

} // namespace gfx
+3 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "VideoBridgeParent.h"
#include "CompositorThread.h"
#include "mozilla/layers/TextureHost.h"

namespace mozilla {
@@ -13,7 +14,6 @@ namespace layers {
using namespace mozilla::ipc;
using namespace mozilla::gfx;


static VideoBridgeParent* sVideoBridgeSingleton;

VideoBridgeParent::VideoBridgeParent()
@@ -21,6 +21,7 @@ VideoBridgeParent::VideoBridgeParent()
{
  mSelfRef = this;
  sVideoBridgeSingleton = this;
  mCompositorThreadRef = CompositorThreadHolder::GetSingleton();
}

VideoBridgeParent::~VideoBridgeParent()
@@ -50,6 +51,7 @@ VideoBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
void
VideoBridgeParent::DeallocPVideoBridgeParent()
{
  mCompositorThreadRef = nullptr;
  mSelfRef = nullptr;
}

+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
namespace mozilla {
namespace layers {

class CompositorThreadHolder;

class VideoBridgeParent final : public PVideoBridgeParent,
                                public HostIPCAllocator,
                                public ShmemAllocator
@@ -61,6 +63,7 @@ private:
  // This keeps us alive until ActorDestroy(), at which point we do a
  // deferred destruction of ourselves.
  RefPtr<VideoBridgeParent> mSelfRef;
  RefPtr<CompositorThreadHolder> mCompositorThreadRef;

  std::map<uint64_t, PTextureParent*> mTextureMap;