Changeset 247755 in webkit
- Timestamp:
- Jul 23, 2019 4:24:58 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247746 r247755 1 2019-07-23 Chris Fleizach <cfleizach@apple.com> 2 3 AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak 4 https://bugs.webkit.org/show_bug.cgi?id=199988 5 6 Reviewed by Per Arne Vollan. 7 8 Implement the reset state to cancel current speech jobs. 9 10 * Modules/speech/SpeechSynthesis.cpp: 11 (WebCore::SpeechSynthesis::startSpeakingImmediately): 12 (WebCore::SpeechSynthesis::cancel): 13 * platform/PlatformSpeechSynthesizer.h: 14 * platform/ios/PlatformSpeechSynthesizerIOS.mm: 15 (WebCore::PlatformSpeechSynthesizer::resetState): 16 * platform/mac/PlatformSpeechSynthesizerMac.mm: 17 (WebCore::PlatformSpeechSynthesizer::resetState): 18 1 19 2019-07-23 Zalan Bujtas <zalan@apple.com> 2 20 -
trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp
r247620 r247755 111 111 void SpeechSynthesis::startSpeakingImmediately(SpeechSynthesisUtterance& utterance) 112 112 { 113 ASSERT(!m_currentSpeechUtterance);114 113 utterance.setStartTime(MonotonicTime::now()); 115 114 m_currentSpeechUtterance = &utterance; … … 153 152 if (m_speechSynthesisClient) 154 153 m_speechSynthesisClient->cancel(); 155 else if (m_platformSpeechSynthesizer) 154 else if (m_platformSpeechSynthesizer) { 156 155 m_platformSpeechSynthesizer->cancel(); 156 // The platform should have called back immediately and cleared the current utterance. 157 ASSERT(!m_currentSpeechUtterance); 158 } 157 159 current = nullptr; 158 159 // The platform should have called back immediately and cleared the current utterance.160 ASSERT(!m_currentSpeechUtterance);161 160 } 162 161 -
trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h
r243002 r247755 74 74 virtual void cancel(); 75 75 76 void resetState(); 76 77 PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; } 77 78 -
trunk/Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm
r244704 r247755 292 292 } 293 293 294 void PlatformSpeechSynthesizer::resetState() 295 { 296 [m_platformSpeechWrapper.get() cancel]; 297 } 298 294 299 } // namespace WebCore 295 300 -
trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm
r243002 r247755 278 278 } 279 279 280 void PlatformSpeechSynthesizer::resetState() 281 { 282 [m_platformSpeechWrapper.get() cancel]; 283 } 284 280 285 } // namespace WebCore 281 286 -
trunk/Source/WebKit/ChangeLog
r247748 r247755 1 2019-07-23 Chris Fleizach <cfleizach@apple.com> 2 3 AX: CrashTracer: com.apple.WebKit.WebContent at WebKit: WebKit::WebSpeechSynthesisClient::speak 4 https://bugs.webkit.org/show_bug.cgi?id=199988 5 6 Reviewed by Per Arne Vollan. 7 8 Improvements to WebSpeechSynthesis to avoid crashing and improve correctness. 9 - Reset and cancel speech jobs on page close or reload (otherwise the synthesizer keeps talking after your page is gone) 10 - Have a separate speech finish callback mechanism, use the start speaking callback when the synthesizer tells us. 11 - Move an assert on utterance state to only apply when we use the in process synthesizer. 12 13 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 14 (WebKit::WebPageProxy::didStartSpeaking): 15 * UIProcess/WebPageProxy.cpp: 16 (WebKit::WebPageProxy::reload): 17 (WebKit::WebPageProxy::resetState): 18 (WebKit::WebPageProxy::resetSpeechSynthesizer): 19 (WebKit::WebPageProxy::speechSynthesisSetFinishedCallback): 20 (WebKit::WebPageProxy::speechSynthesisSpeak): 21 * UIProcess/WebPageProxy.h: 22 * UIProcess/WebPageProxy.messages.in: 23 * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp: 24 (WebKit::WebSpeechSynthesisClient::speak): 25 1 26 2019-07-23 Chris Dumez <cdumez@apple.com> 2 27 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r246413 r247755 259 259 void WebPageProxy::didStartSpeaking(WebCore::PlatformSpeechSynthesisUtterance&) 260 260 { 261 if (speechSynthesisData().speakingStartedCompletionHandler) 262 speechSynthesisData().speakingStartedCompletionHandler(); 261 263 } 262 264 263 265 void WebPageProxy::didFinishSpeaking(WebCore::PlatformSpeechSynthesisUtterance&) 264 266 { 265 m_speechSynthesisData->speakingFinishedCompletionHandler(); 267 if (speechSynthesisData().speakingFinishedCompletionHandler) 268 speechSynthesisData().speakingFinishedCompletionHandler(); 266 269 } 267 270 268 271 void WebPageProxy::didPauseSpeaking(WebCore::PlatformSpeechSynthesisUtterance&) 269 272 { 270 m_speechSynthesisData->speakingPausedCompletionHandler(); 273 if (speechSynthesisData().speakingPausedCompletionHandler) 274 speechSynthesisData().speakingPausedCompletionHandler(); 271 275 } 272 276 273 277 void WebPageProxy::didResumeSpeaking(WebCore::PlatformSpeechSynthesisUtterance&) 274 278 { 275 m_speechSynthesisData->speakingResumedCompletionHandler(); 279 if (speechSynthesisData().speakingResumedCompletionHandler) 280 speechSynthesisData().speakingResumedCompletionHandler(); 276 281 } 277 282 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r247695 r247755 1360 1360 m_process->responsivenessTimer().start(); 1361 1361 1362 #if ENABLE(SPEECH_SYNTHESIS) 1363 resetSpeechSynthesizer(); 1364 #endif 1365 1362 1366 return navigation; 1363 1367 } … … 7053 7057 #if ENABLE(POINTER_LOCK) 7054 7058 requestPointerUnlock(); 7059 #endif 7060 7061 #if ENABLE(SPEECH_SYNTHESIS) 7062 resetSpeechSynthesizer(); 7055 7063 #endif 7056 7064 } … … 9127 9135 9128 9136 #if ENABLE(SPEECH_SYNTHESIS) 9137 9138 void WebPageProxy::resetSpeechSynthesizer() 9139 { 9140 if (!m_speechSynthesisData) 9141 return; 9142 9143 auto& synthesisData = speechSynthesisData(); 9144 synthesisData.speakingFinishedCompletionHandler = nullptr; 9145 synthesisData.speakingStartedCompletionHandler = nullptr; 9146 synthesisData.speakingPausedCompletionHandler = nullptr; 9147 synthesisData.speakingResumedCompletionHandler = nullptr; 9148 if (synthesisData.synthesizer) 9149 synthesisData.synthesizer->resetState(); 9150 } 9151 9129 9152 WebPageProxy::SpeechSynthesisData& WebPageProxy::speechSynthesisData() 9130 9153 { 9131 9154 if (!m_speechSynthesisData) 9132 m_speechSynthesisData = SpeechSynthesisData { std::make_unique<PlatformSpeechSynthesizer>(this), nullptr, nullptr, nullptr, nullptr };9155 m_speechSynthesisData = SpeechSynthesisData { std::make_unique<PlatformSpeechSynthesizer>(this), nullptr, nullptr, nullptr, nullptr, nullptr }; 9133 9156 return *m_speechSynthesisData; 9134 9157 } … … 9142 9165 result.uncheckedAppend(WebSpeechSynthesisVoice { voice->voiceURI(), voice->name(), voice->lang(), voice->localService(), voice->isDefault() }); 9143 9166 completionHandler(WTFMove(result)); 9167 } 9168 9169 void WebPageProxy::speechSynthesisSetFinishedCallback(CompletionHandler<void()>&& completionHandler) 9170 { 9171 speechSynthesisData().speakingFinishedCompletionHandler = WTFMove(completionHandler); 9144 9172 } 9145 9173 … … 9155 9183 utterance->setVoice(&voice.get()); 9156 9184 9185 speechSynthesisData().speakingStartedCompletionHandler = WTFMove(completionHandler); 9157 9186 speechSynthesisData().utterance = WTFMove(utterance); 9158 speechSynthesisData().speakingFinishedCompletionHandler = WTFMove(completionHandler);9159 9187 speechSynthesisData().synthesizer->speak(m_speechSynthesisData->utterance.get()); 9160 9188 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r247662 r247755 1534 1534 void speechSynthesisVoiceList(CompletionHandler<void(Vector<WebSpeechSynthesisVoice>&&)>&&); 1535 1535 void speechSynthesisSpeak(const String&, const String&, float volume, float rate, float pitch, MonotonicTime startTime, const String& voiceURI, const String& voiceName, const String& voiceLang, bool localService, bool defaultVoice, CompletionHandler<void()>&&); 1536 void speechSynthesisSetFinishedCallback(CompletionHandler<void()>&&); 1536 1537 void speechSynthesisCancel(); 1537 1538 void speechSynthesisPause(CompletionHandler<void()>&&); … … 2097 2098 struct SpeechSynthesisData; 2098 2099 SpeechSynthesisData& speechSynthesisData(); 2100 void resetSpeechSynthesizer(); 2099 2101 #endif 2100 2102 … … 2534 2536 std::unique_ptr<WebCore::PlatformSpeechSynthesizer> synthesizer; 2535 2537 RefPtr<WebCore::PlatformSpeechSynthesisUtterance> utterance; 2538 CompletionHandler<void()> speakingStartedCompletionHandler; 2536 2539 CompletionHandler<void()> speakingFinishedCompletionHandler; 2537 2540 CompletionHandler<void()> speakingPausedCompletionHandler; -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r247460 r247755 559 559 SpeechSynthesisVoiceList() -> (Vector<WebKit::WebSpeechSynthesisVoice> voiceList) Synchronous 560 560 SpeechSynthesisSpeak(String text, String lang, float volume, float rate, float pitch, MonotonicTime startTime, String voiceURI, String voiceName, String voiceLang, bool localService, bool defaultVoice) -> () Async 561 SpeechSynthesisSetFinishedCallback() -> () Async 561 562 SpeechSynthesisCancel() 562 563 SpeechSynthesisPause() -> () Async -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp
r247192 r247755 58 58 void WebSpeechSynthesisClient::speak(RefPtr<WebCore::PlatformSpeechSynthesisUtterance> utterance) 59 59 { 60 WTF::CompletionHandler<void()> completionHandler = [this, weakThis = makeWeakPtr(*this)]() mutable { 60 WTF::CompletionHandler<void()> startedCompletionHandler = [this, weakThis = makeWeakPtr(*this)]() mutable { 61 if (!weakThis) 62 return; 63 if (auto observer = corePageObserver()) 64 observer->didStartSpeaking(); 65 }; 66 67 WTF::CompletionHandler<void()> finishedCompletionHandler = [this, weakThis = makeWeakPtr(*this)]() mutable { 61 68 if (!weakThis) 62 69 return; … … 71 78 auto localService = voice ? voice->localService() : false; 72 79 auto isDefault = voice ? voice->isDefault() : false; 73 74 m_page.sendWithAsyncReply(Messages::WebPageProxy::SpeechSynthesisSpeak(utterance->text(), utterance->lang(), utterance->volume(), utterance->rate(), utterance->pitch(), utterance->startTime(), voiceURI, name, lang, localService, isDefault), WTFMove(completionHandler)); 75 if (auto observer = corePageObserver()) 76 observer->didStartSpeaking(); 80 81 m_page.sendWithAsyncReply(Messages::WebPageProxy::SpeechSynthesisSetFinishedCallback(), WTFMove(finishedCompletionHandler)); 82 m_page.sendWithAsyncReply(Messages::WebPageProxy::SpeechSynthesisSpeak(utterance->text(), utterance->lang(), utterance->volume(), utterance->rate(), utterance->pitch(), utterance->startTime(), voiceURI, name, lang, localService, isDefault), WTFMove(startedCompletionHandler)); 77 83 } 78 84
Note: See TracChangeset
for help on using the changeset viewer.