gecko-dev/gfx/vr/ipc/VRLayerChild.h
Kearwood "Kip" Gilbert 2a221a0a19 Bug 1321275 - Fix reference counting of PVRLayerChild when GPU process has been terminated r=daoshengmu
- In VRManagerChild::DeallocPVRLayerChild, we delete the PVRLayerChild, rather
  than doing proper reference counting on the VRLayerChild object which has
  been deallocated but still referenced by VRDisplayPresentation::mLayers.
  This happens when the GPU process is terminated.

- When the user tries to stop the VR presentation or change the URL,
  PVRLayerChild::SendDestroy is called by VRDisplayPresentation::DestroyLayers.
  This results in the assertion about "invalid actor state".

- This patch fixes this by following the same pattern used by TextureClient
  for its PTextureChild.

MozReview-Commit-ID: 327cdb4s7kl

--HG--
extra : rebase_source : 88847acd39d82f258f0c969e6ef5e22b794f6428
2017-07-12 16:05:40 -07:00

65 lines
1.7 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_VR_LAYERCHILD_H
#define GFX_VR_LAYERCHILD_H
#include "VRManagerChild.h"
#include "mozilla/RefPtr.h"
#include "mozilla/gfx/PVRLayerChild.h"
#include "GLContext.h"
#include "gfxVR.h"
class nsICanvasRenderingContextInternal;
namespace mozilla {
class WebGLContext;
namespace dom {
class HTMLCanvasElement;
}
namespace layers {
class SharedSurfaceTextureClient;
}
namespace gl {
class SurfaceFactory;
}
namespace gfx {
class VRLayerChild : public PVRLayerChild {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRLayerChild)
public:
static PVRLayerChild* CreateIPDLActor();
static bool DestroyIPDLActor(PVRLayerChild* actor);
void Initialize(dom::HTMLCanvasElement* aCanvasElement);
void SubmitFrame();
bool IsIPCOpen();
private:
VRLayerChild();
virtual ~VRLayerChild();
void ClearSurfaces();
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
RefPtr<dom::HTMLCanvasElement> mCanvasElement;
RefPtr<layers::SharedSurfaceTextureClient> mShSurfClient;
RefPtr<layers::TextureClient> mFront;
bool mIPCOpen;
// AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
// and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.
// The purpose of these methods is to be aware of when the IPC system around this
// actor goes down: mIPCOpen is then set to false.
void AddIPDLReference();
void ReleaseIPDLReference();
};
} // namespace gfx
} // namespace mozilla
#endif