Bug 1343666 - Prevent crash on shutdown due to assertion in VRManagerChild::Get() draft
authorKearwood Gilbert <kgilbert@mozilla.com>
Thu, 02 Mar 2017 13:07:24 -0800
changeset 492140 b0488c7b7d3e7914e42eebf8fd4e18a7e25ff641
parent 490433 1bc2ad020aee2830e0a7941f10958dbec108c254
child 547665 6b2fc2549d63e1e1dc1d10b2471b66b35cb38076
push id47545
push userbmo:kgilbert@mozilla.com
push dateThu, 02 Mar 2017 21:33:35 +0000
bugs1343666
milestone54.0a1
Bug 1343666 - Prevent crash on shutdown due to assertion in VRManagerChild::Get() - Updated VREventObserver::DisconnectFromOwner() to call VRManagerChild::IsCreated() before calling the accessor VRManageRchild::Get() containing the assertion. MozReview-Commit-ID: Ezy08m6V4HV
dom/vr/VREventObserver.cpp
--- a/dom/vr/VREventObserver.cpp
+++ b/dom/vr/VREventObserver.cpp
@@ -40,18 +40,18 @@ void
 VREventObserver::DisconnectFromOwner()
 {
   // In the event that nsGlobalWindow is deallocated, VREventObserver may
   // still be AddRef'ed elsewhere.  Ensure that we don't UAF by
   // dereferencing mWindow.
   mWindow = nullptr;
 
   // Unregister from VRManagerChild
-  VRManagerChild* vmc = VRManagerChild::Get();
-  if (vmc) {
+  if (VRManagerChild::IsCreated()) {
+    VRManagerChild* vmc = VRManagerChild::Get();
     vmc->RemoveListener(this);
   }
 }
 
 void
 VREventObserver::NotifyVRDisplayMounted(uint32_t aDisplayID)
 {
   if (mWindow && mWindow->AsInner()->IsCurrentInnerWindow()) {