Index: Source/platform/speech/PlatformSpeechSynthesizer.h |
diff --git a/Source/platform/speech/PlatformSpeechSynthesizer.h b/Source/platform/speech/PlatformSpeechSynthesizer.h |
index f808750fe3102bb50409dfa7fcb5bda64ac19400..c54e2f1849b92a6fe28c03e3c3f62be8b558b1c7 100644 |
--- a/Source/platform/speech/PlatformSpeechSynthesizer.h |
+++ b/Source/platform/speech/PlatformSpeechSynthesizer.h |
@@ -58,12 +58,10 @@ protected: |
class PLATFORM_EXPORT PlatformSpeechSynthesizer : public GarbageCollectedFinalized<PlatformSpeechSynthesizer> { |
WTF_MAKE_NONCOPYABLE(PlatformSpeechSynthesizer); |
- USING_PRE_FINALIZER(PlatformSpeechSynthesizer, dispose); |
public: |
static PlatformSpeechSynthesizer* create(PlatformSpeechSynthesizerClient*); |
virtual ~PlatformSpeechSynthesizer(); |
- void dispose(); |
const HeapVector<Member<PlatformSpeechSynthesisVoice>>& voiceList() const { return m_voiceList; } |
virtual void speak(PlatformSpeechSynthesisUtterance*); |
@@ -75,6 +73,15 @@ public: |
void setVoiceList(HeapVector<Member<PlatformSpeechSynthesisVoice>>&); |
+ // Eager finalization is required to promptly release the owned WebSpeechSynthesizer. |
+ // |
+ // If not and delayed until lazily swept, m_webSpeechSynthesizerClient may end up |
+ // being lazily swept first (i.e., before this PlatformSpeechSynthesizer), leaving |
+ // m_webSpeechSynthesizer with a dangling pointer to a finalized object -- |
+ // WebSpeechSynthesizer embedder implementations calling notification methods in the |
+ // other directions by way of m_webSpeechSynthesizerClient. Eagerly releasing |
+ // WebSpeechSynthesizer prevents such unsafe accesses. |
+ EAGERLY_FINALIZE(); |
DECLARE_VIRTUAL_TRACE(); |
protected: |