Bug 1230428 - Part 1. Check mTask since end event is posted asynchronized. r=eeejay
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 10 Dec 2015 13:45:26 -0500
changeset 276104 f75a98aa4ef04966d2064bda531c9c1ddb494e7c
parent 276103 6ba1161b0fe196103b3076dad39bb5e108f7ad4f
child 276105 5a889d2cc25ba685416703862652097239038383
push id69042
push userm_kato@ga2.so-net.ne.jp
push dateThu, 10 Dec 2015 18:48:21 +0000
treeherdermozilla-inbound@5a889d2cc25b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs1230428
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1230428 - Part 1. Check mTask since end event is posted asynchronized. r=eeejay
dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm
dom/media/webspeech/synth/windows/SapiService.cpp
--- a/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm
+++ b/dom/media/webspeech/synth/cocoa/OSXSpeechSynthesizerService.mm
@@ -74,28 +74,38 @@ SpeechTaskCallback::OnCancel()
 }
 
 NS_IMETHODIMP
 SpeechTaskCallback::OnPause()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   [mSpeechSynthesizer pauseSpeakingAtBoundary:NSSpeechImmediateBoundary];
+  if (!mTask) {
+    // When calling pause() on child porcess, it may not receive end event
+    // from chrome process yet.
+    return NS_ERROR_FAILURE;
+  }
   mTask->DispatchPause(GetTimeDurationFromStart(), mCurrentIndex);
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
 SpeechTaskCallback::OnResume()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   [mSpeechSynthesizer continueSpeaking];
+  if (!mTask) {
+    // When calling resume() on child porcess, it may not receive end event
+    // from chrome process yet.
+    return NS_ERROR_FAILURE;
+  }
   mTask->DispatchResume(GetTimeDurationFromStart(), mCurrentIndex);
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
 SpeechTaskCallback::OnVolumeChanged(float aVolume)
@@ -115,23 +125,29 @@ SpeechTaskCallback::GetTimeDurationFromS
   TimeDuration duration = TimeStamp::Now() - mStartingTime;
   return duration.ToMilliseconds();
 }
 
 void
 SpeechTaskCallback::OnWillSpeakWord(uint32_t aIndex)
 {
   mCurrentIndex = aIndex;
+  if (!mTask) {
+    return;
+  }
   mTask->DispatchBoundary(NS_LITERAL_STRING("word"),
                           GetTimeDurationFromStart(), mCurrentIndex);
 }
 
 void
 SpeechTaskCallback::OnError(uint32_t aIndex)
 {
+  if (!mTask) {
+    return;
+  }
   mTask->DispatchError(GetTimeDurationFromStart(), aIndex);
 }
 
 void
 SpeechTaskCallback::OnDidFinishSpeaking()
 {
   mTask->DispatchEnd(GetTimeDurationFromStart(), mCurrentIndex);
   // no longer needed
--- a/dom/media/webspeech/synth/windows/SapiService.cpp
+++ b/dom/media/webspeech/synth/windows/SapiService.cpp
@@ -71,26 +71,36 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(SapiCall
 NS_IMPL_CYCLE_COLLECTING_RELEASE(SapiCallback)
 
 NS_IMETHODIMP
 SapiCallback::OnPause()
 {
   if (FAILED(mSapiClient->Pause())) {
     return NS_ERROR_FAILURE;
   }
+  if (!mTask) {
+    // When calling pause() on child porcess, it may not receive end event
+    // from chrome process yet.
+    return NS_ERROR_FAILURE;
+  }
   mTask->DispatchPause(GetTickCount() - mStartingTime, mCurrentIndex);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SapiCallback::OnResume()
 {
   if (FAILED(mSapiClient->Resume())) {
     return NS_ERROR_FAILURE;
   }
+  if (!mTask) {
+    // When calling resume() on child porcess, it may not receive end event
+    // from chrome process yet.
+    return NS_ERROR_FAILURE;
+  }
   mTask->DispatchResume(GetTickCount() - mStartingTime, mCurrentIndex);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SapiCallback::OnCancel()
 {
   // After cancel, mCurrentIndex may be updated.