Bug 1675820 - Part 1: Upgrade destroyed asserts in BrowsingContextGroup, r=kmag

The issues with BrowsingContextGroup identity may be related to using a
destroyed BrowsingContextGroup in some situations when we shouldn't be. By
upgrading the intensity of these assertions, we should be able to catch the
issues more readily.

Differential Revision: https://phabricator.services.mozilla.com/D108117
This commit is contained in:
Nika Layzell
2021-03-18 19:24:48 +00:00
parent 7ba32138e3
commit e0a76b996b
2 changed files with 13 additions and 13 deletions

View File

@@ -51,13 +51,13 @@ BrowsingContextGroup::BrowsingContextGroup(uint64_t aId) : mId(aId) {
} }
void BrowsingContextGroup::Register(nsISupports* aContext) { void BrowsingContextGroup::Register(nsISupports* aContext) {
MOZ_ASSERT(!mDestroyed); MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(aContext); MOZ_DIAGNOSTIC_ASSERT(aContext);
mContexts.PutEntry(aContext); mContexts.PutEntry(aContext);
} }
void BrowsingContextGroup::Unregister(nsISupports* aContext) { void BrowsingContextGroup::Unregister(nsISupports* aContext) {
MOZ_ASSERT(!mDestroyed); MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(aContext); MOZ_DIAGNOSTIC_ASSERT(aContext);
mContexts.RemoveEntry(aContext); mContexts.RemoveEntry(aContext);
@@ -65,7 +65,7 @@ void BrowsingContextGroup::Unregister(nsISupports* aContext) {
} }
void BrowsingContextGroup::EnsureHostProcess(ContentParent* aProcess) { void BrowsingContextGroup::EnsureHostProcess(ContentParent* aProcess) {
MOZ_ASSERT(!mDestroyed); MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(this != sChromeGroup, MOZ_DIAGNOSTIC_ASSERT(this != sChromeGroup,
"cannot have content host for chrome group"); "cannot have content host for chrome group");
MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE, MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE,
@@ -117,7 +117,7 @@ static void CollectContextInitializers(
} }
void BrowsingContextGroup::Subscribe(ContentParent* aProcess) { void BrowsingContextGroup::Subscribe(ContentParent* aProcess) {
MOZ_ASSERT(!mDestroyed); MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(aProcess && !aProcess->IsLaunching()); MOZ_DIAGNOSTIC_ASSERT(aProcess && !aProcess->IsLaunching());
MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE); MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE);
@@ -220,11 +220,11 @@ bool BrowsingContextGroup::ShouldSuspendAllTopLevelContexts() const {
BrowsingContextGroup::~BrowsingContextGroup() { Destroy(); } BrowsingContextGroup::~BrowsingContextGroup() { Destroy(); }
void BrowsingContextGroup::Destroy() { void BrowsingContextGroup::Destroy() {
#ifdef DEBUG #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
if (mDestroyed) { if (mDestroyed) {
MOZ_ASSERT(mHosts.Count() == 0); MOZ_DIAGNOSTIC_ASSERT(mHosts.Count() == 0);
MOZ_ASSERT(mSubscribers.Count() == 0); MOZ_DIAGNOSTIC_ASSERT(mSubscribers.Count() == 0);
MOZ_ASSERT_IF(sBrowsingContextGroups, MOZ_DIAGNOSTIC_ASSERT_IF(sBrowsingContextGroups,
!sBrowsingContextGroups->Contains(Id()) || !sBrowsingContextGroups->Contains(Id()) ||
*sBrowsingContextGroups->Lookup(Id()) != this); *sBrowsingContextGroups->Lookup(Id()) != this);
} }
@@ -249,12 +249,12 @@ void BrowsingContextGroup::Destroy() {
} }
void BrowsingContextGroup::AddKeepAlive() { void BrowsingContextGroup::AddKeepAlive() {
MOZ_ASSERT(!mDestroyed); MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
mKeepAliveCount++; mKeepAliveCount++;
} }
void BrowsingContextGroup::RemoveKeepAlive() { void BrowsingContextGroup::RemoveKeepAlive() {
MOZ_ASSERT(!mDestroyed); MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(mKeepAliveCount > 0); MOZ_DIAGNOSTIC_ASSERT(mKeepAliveCount > 0);
mKeepAliveCount--; mKeepAliveCount--;

View File

@@ -172,7 +172,7 @@ class BrowsingContextGroup final : public nsWrapperCache {
uint32_t mKeepAliveCount = 0; uint32_t mKeepAliveCount = 0;
#ifdef DEBUG #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
bool mDestroyed = false; bool mDestroyed = false;
#endif #endif