Commit f7161031 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

webaudio: Replace the UntracedMember<AudioNode> in AudioHandler with a WeakPersistent.

Bug: 856641
Change-Id: Id1f5bdff7cbf8cf6fa62adeadc2d07e819755a5c
Reviewed-on: https://chromium-review.googlesource.com/c/1318687Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605787}
parent b3fe8d3b
...@@ -76,8 +76,6 @@ AudioHandler::AudioHandler(NodeType node_type, ...@@ -76,8 +76,6 @@ AudioHandler::AudioHandler(NodeType node_type,
AudioHandler::~AudioHandler() { AudioHandler::~AudioHandler() {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
// dispose() should be called.
DCHECK(!GetNode());
InstanceCounters::DecrementCounter(InstanceCounters::kAudioHandlerCounter); InstanceCounters::DecrementCounter(InstanceCounters::kAudioHandlerCounter);
#if DEBUG_AUDIONODE_REFERENCES #if DEBUG_AUDIONODE_REFERENCES
--node_count_[GetNodeType()]; --node_count_[GetNodeType()];
...@@ -111,7 +109,6 @@ void AudioHandler::Dispose() { ...@@ -111,7 +109,6 @@ void AudioHandler::Dispose() {
Context()->GetDeferredTaskHandler().RemoveAutomaticPullNode(this); Context()->GetDeferredTaskHandler().RemoveAutomaticPullNode(this);
for (auto& output : outputs_) for (auto& output : outputs_)
output->Dispose(); output->Dispose();
node_ = nullptr;
} }
AudioNode* AudioHandler::GetNode() const { AudioNode* AudioHandler::GetNode() const {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/audio/audio_bus.h" #include "third_party/blink/renderer/platform/audio/audio_bus.h"
#include "third_party/blink/renderer/platform/audio/audio_utilities.h" #include "third_party/blink/renderer/platform/audio/audio_utilities.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" #include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
...@@ -108,10 +109,11 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> { ...@@ -108,10 +109,11 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> {
// Do not release resources used by an audio rendering thread in dispose(). // Do not release resources used by an audio rendering thread in dispose().
virtual void Dispose(); virtual void Dispose();
// GetNode() returns a valid object until dispose() is called. This returns // GetNode() returns a valid object until the AudioNode is collected on the
// nullptr after dispose(). We must not call GetNode() in an audio rendering // main thread, and nullptr thereafter. We must not call GetNode() in an audio
// thread. // rendering thread.
AudioNode* GetNode() const; AudioNode* GetNode() const;
// context() returns a valid object until the BaseAudioContext dies, and // context() returns a valid object until the BaseAudioContext dies, and
// returns nullptr otherwise. This always returns a valid object in an audio // returns nullptr otherwise. This always returns a valid object in an audio
// rendering thread, and inside dispose(). We must not call context() in the // rendering thread, and inside dispose(). We must not call context() in the
...@@ -264,11 +266,8 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> { ...@@ -264,11 +266,8 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> {
volatile bool is_initialized_; volatile bool is_initialized_;
NodeType node_type_; NodeType node_type_;
// The owner AudioNode. This untraced member is safe because dispose() is // The owner AudioNode. Accessed only on the main thread.
// called before the AudioNode death, and it clears |node_|. Do not access const WeakPersistent<AudioNode> node_;
// |node_| directly, use GetNode() instead.
// See http://crbug.com/404527 for the detail.
UntracedMember<AudioNode> node_;
// This untraced member is safe because this is cleared for all of live // This untraced member is safe because this is cleared for all of live
// AudioHandlers when the BaseAudioContext dies. Do not access m_context // AudioHandlers when the BaseAudioContext dies. Do not access m_context
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment