Bug 1412184 - Set the main thread after BindToOwner in AudioNode ctor. r?smaug
We dont't have a garantee to have a global here.
MozReview-Commit-ID: 8aTcYxuVISi
--- a/dom/media/webaudio/AudioNode.cpp
+++ b/dom/media/webaudio/AudioNode.cpp
@@ -49,20 +49,26 @@ AudioNode::AudioNode(AudioContext* aCont
ChannelInterpretation aChannelInterpretation)
: DOMEventTargetHelper(aContext->GetParentObject())
, mContext(aContext)
, mChannelCount(aChannelCount)
, mChannelCountMode(aChannelCountMode)
, mChannelInterpretation(aChannelInterpretation)
, mId(gId++)
, mPassThrough(false)
- , mAbstractMainThread(aContext->GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other))
+ , mAbstractMainThread(nullptr)
{
MOZ_ASSERT(aContext);
DOMEventTargetHelper::BindToOwner(aContext->GetParentObject());
+
+ if (aContext->GetOwnerGlobal()) {
+ mAbstractMainThread =
+ aContext->GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other);
+ }
+
aContext->RegisterNode(this);
}
AudioNode::~AudioNode()
{
MOZ_ASSERT(mInputNodes.IsEmpty());
MOZ_ASSERT(mOutputNodes.IsEmpty());
MOZ_ASSERT(mOutputParams.IsEmpty());
--- a/dom/media/webaudio/AudioNode.h
+++ b/dom/media/webaudio/AudioNode.h
@@ -289,15 +289,15 @@ private:
uint32_t mChannelCount;
ChannelCountMode mChannelCountMode;
ChannelInterpretation mChannelInterpretation;
const uint32_t mId;
// Whether the node just passes through its input. This is a devtools API that
// only works for some node types.
bool mPassThrough;
// DocGroup-specifc AbstractThread::MainThread() for MediaStreamGraph operations.
- const RefPtr<AbstractThread> mAbstractMainThread;
+ RefPtr<AbstractThread> mAbstractMainThread;
};
} // namespace dom
} // namespace mozilla
#endif