Bug 1320346 - dump |rv| when AddBlocker() fails to get more debugging info. r?cpearce
MozReview-Commit-ID: LA3uPvdKCU5
--- a/dom/media/MediaShutdownManager.cpp
+++ b/dom/media/MediaShutdownManager.cpp
@@ -69,32 +69,41 @@ MediaShutdownManager::EnsureCorrectShutd
{
bool needShutdownObserver = mDecoders.Count() > 0;
if (needShutdownObserver != mIsObservingShutdown) {
mIsObservingShutdown = needShutdownObserver;
if (mIsObservingShutdown) {
nsresult rv = GetShutdownBarrier()->AddBlocker(
this, NS_LITERAL_STRING(__FILE__), __LINE__,
NS_LITERAL_STRING("MediaShutdownManager shutdown"));
- MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
+ if (NS_FAILED(rv)) {
+ // Leak the buffer on the heap to make sure that it lives long enough,
+ // as MOZ_CRASH_ANNOTATE expects the pointer passed to it to live to
+ // the end of the program.
+ const size_t CAPACITY = 256;
+ auto buf = new char[CAPACITY];
+ snprintf(buf, CAPACITY, "Failed to add shutdown blocker! rv=%x", uint32_t(rv));
+ MOZ_CRASH_ANNOTATE(buf);
+ MOZ_REALLY_CRASH();
+ }
} else {
GetShutdownBarrier()->RemoveBlocker(this);
// Clear our singleton reference. This will probably delete
// this instance, so don't deref |this| clearing sInstance.
sInstance = nullptr;
DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::BlockShutdown() end."));
}
}
}
void
MediaShutdownManager::Register(MediaDecoder* aDecoder)
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_DIAGNOSTIC_ASSERT(!mIsDoingXPCOMShutDown);
+ MOZ_RELEASE_ASSERT(!mIsDoingXPCOMShutDown);
// Don't call Register() after you've Unregistered() all the decoders,
// that's not going to work.
MOZ_ASSERT(!mDecoders.Contains(aDecoder));
mDecoders.PutEntry(aDecoder);
MOZ_ASSERT(mDecoders.Contains(aDecoder));
MOZ_ASSERT(mDecoders.Count() > 0);
EnsureCorrectShutdownObserverState();
}