Repository: nvaccess/nvda

Issue:
Onecore: sayall broken

### Steps to reproduce:

1. Switch to onecore.
2. Google world War I. Click its Wikipedia article.
3. Read with sayall.

### Actual behavior:

After several sentences, onecore stops the sayall.

### Expected behavior:

Sayall continues indefinitely.

### System configuration
#### NVDA installed/portable/running from source:
n/a/

#### NVDA version:
Version: alpha-18783,af65e692

#### Windows version:

Windows version: Windows 10Ver1809 (64-bit) build 17763.737

#### Name and version of other software in use when reproducing the issue:

Firefox nightly




Discussion:
this needs to be investigated before 19.3. @leonardder @feerrenrut  
Is that browser related?



bglists@blueyonder.co.uk 
Sent via blueyonder. 
Please address personal E-mail to:-
briang1@blueyonder.co.uk, putting 'Brian Gaff'
in the display name field.
Newsgroup monitored: alt.comp.blind-users

Doubt it. It doesn't occur with espeak

On Sat, Sep 28, 2019 at 5:46 AM Brian Gaff <notifications@github.com> wrote:

> Is that browser related?
>
>
>
> bglists@blueyonder.co.uk
> Sent via blueyonder.
> Please address personal E-mail to:-
> briang1@blueyonder.co.uk, putting 'Brian Gaff'
> in the display name field.
> Newsgroup monitored: alt.comp.blind-users
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/nvaccess/nvda/issues/10292?email_source=notifications&email_token=ABI2FPISUQ47BHZLZWF5H73QL47XRA5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD72XQJA#issuecomment-536180772>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABI2FPKZ3V7PZEDVUFKCEJ3QL47XRANCNFSM4I3MOAMA>
> .
>


-- 

Derek Riemer: Improving the world one byte at a time!

   - University of Colorado Boulder Department of computer science, 4th
   year undergraduate student.
   - Accessibility enthusiast.
   - Proud user of the NVDA screen reader.
   - Open source enthusiast.
   - Skier.

Personal website <http://derekriemer.com>

I can't replicate this using Firefox 69.0.1, and alpha-18915,86b5b7e5.

I didn't let it read the whole article, but I did let it go through a pretty 
good quantity of it. I also tried in 2019.2.1 beta, and had no problem.

How long does it actually need to read, assuming you press control+home first to 
start at the top, before it fails?


-- 
Luke Davis
Moderator: the new NVDA Help mailing list! (https://groups.io/g/NVDAHelp)
Author: Debug Helper NVDA add-on (https://addons.nvda-project.org/addons/debugHelper.en.html)

It's not occurring for me now. I wonder if my onecore profile has something
else set. It's possible alpha solved this relatively recently.

On Sat, Oct 12, 2019 at 12:07 AM Luke Davis <notifications@github.com>
wrote:

> I can't replicate this using Firefox 69.0.1, and alpha-18915,86b5b7e5.
>
> I didn't let it read the whole article, but I did let it go through a
> pretty
> good quantity of it. I also tried in 2019.2.1 beta, and had no problem.
>
> How long does it actually need to read, assuming you press control+home
> first to
> start at the top, before it fails?
>
>
> --
> Luke Davis
> Moderator: the new NVDA Help mailing list! (https://groups.io/g/NVDAHelp)
> Author: Debug Helper NVDA add-on (
> https://addons.nvda-project.org/addons/debugHelper.en.html)
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/nvaccess/nvda/issues/10292?email_source=notifications&email_token=ABI2FPOFWEPVU3RV2T57GITQOFSTLA5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBBW2TY#issuecomment-541289807>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABI2FPIGYUAIW3THYHGW5IDQOFSTLANCNFSM4I3MOAMA>
> .
>


-- 

Derek Riemer: Improving the world one byte at a time!

   - University of Colorado Boulder Department of computer science, 4th
   year undergraduate student.
   - Accessibility enthusiast.
   - Proud user of the NVDA screen reader.
   - Open source enthusiast.
   - Skier.

Personal website <http://derekriemer.com>

Hi,

I cannot reproduce this using the latest alpha. 

It reads smooth. 

 

From: Derek Riemer <notifications@github.com> 
Sent: Sunday, October 13, 2019 9:08 PM
To: nvaccess/nvda <nvda@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: Re: [nvaccess/nvda] Onecore: sayall broken (#10292)

 

It's not occurring for me now. I wonder if my onecore profile has something
else set. It's possible alpha solved this relatively recently.

On Sat, Oct 12, 2019 at 12:07 AM Luke Davis <notifications@github.com <mailto:notifications@github.com> >
wrote:

> I can't replicate this using Firefox 69.0.1, and alpha-18915,86b5b7e5.
>
> I didn't let it read the whole article, but I did let it go through a
> pretty
> good quantity of it. I also tried in 2019.2.1 beta, and had no problem.
>
> How long does it actually need to read, assuming you press control+home
> first to
> start at the top, before it fails?
>
>
> --
> Luke Davis
> Moderator: the new NVDA Help mailing list! (https://groups.io/g/NVDAHelp)
> Author: Debug Helper NVDA add-on (
> https://addons.nvda-project.org/addons/debugHelper.en.html)
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/nvaccess/nvda/issues/10292?email_source=notifications <https://github.com/nvaccess/nvda/issues/10292?email_source=notifications&email_token=ABI2FPOFWEPVU3RV2T57GITQOFSTLA5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBBW2TY#issuecomment-541289807> &email_token=ABI2FPOFWEPVU3RV2T57GITQOFSTLA5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBBW2TY#issuecomment-541289807>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABI2FPIGYUAIW3THYHGW5IDQOFSTLANCNFSM4I3MOAMA>
> .
>


-- 

Derek Riemer: Improving the world one byte at a time!

- University of Colorado Boulder Department of computer science, 4th
year undergraduate student.
- Accessibility enthusiast.
- Proud user of the NVDA screen reader.
- Open source enthusiast.
- Skier.

Personal website <http://derekriemer.com>



—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <https://github.com/nvaccess/nvda/issues/10292?email_source=notifications&email_token=ACVCDE7H2G2OAJ57IPBVMITQONWY7A5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBC5O3Y#issuecomment-541448047> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACVCDE7QHEDTUHAS6ABAEWTQONWY7ANCNFSM4I3MOAMA> .  <https://github.com/notifications/beacon/ACVCDE7BRON3CI23I7OWNITQONWY7A5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBC5O3Y.gif> 


See #9946. May be we're missing the indexes that trigger say all to continue after reading a line/sentence.
@derekriemer: What's the current state of this? Could you provide us the number of characters on one line you have set in your browse mode settings?
I have someone reporting this issue as well and they advise that it is still present in 2019.3 beta2.

100

On Sun, Jan 19, 2020 at 3:28 PM Quentin Christensen <
notifications@github.com> wrote:

> I have someone reporting this issue as well and they advise that it is
> still present in 2019.3 beta2.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/nvaccess/nvda/issues/10292?email_source=notifications&email_token=ABI2FPJZO47RVNDVGLMKGA3Q6TH2FA5CNFSM4I3MOAMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJK6KAI#issuecomment-576054529>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABI2FPIU2MRGHICMAP2LKMLQ6TH2FANCNFSM4I3MOAMA>
> .
>


-- 

Derek Riemer: Improving the world one byte at a time!

   - University of Colorado Boulder Department of computer science, 4th
   year undergraduate student.
   - Accessibility enthusiast.
   - Proud user of the NVDA screen reader.
   - Open source enthusiast.
   - Skier.

Personal website <http://derekriemer.com>

Reproduced this issue with eSpeak and Firefox 72.0.2 (64 bits) and NVDA 2019.3beta2

STR:
* Open Firefox
* Search "NVAccess" on Google
* Press 1, 2, 3 to go to the first result
* Press NVDA+DownArrow (line 720 in the log)

Result:
After line 733, NVDA does not speak anymore. Need to press again NVDA+DownArrow (line 735) to continue reading.
Again after line 776, NVDA stops speaking. I need to press again NVDA+DownArrow (line 778) to continue.

Here is the log: [nvda_sayAllStopping.log](https://github.com/nvaccess/nvda/files/4121491/nvda_sayAllStopping.log)

Notes:
* I have also had this issue many times with IBMTTS synthesizer. However I did not raise an issue at the time because I did not know if it was due to this synth implementation. I have never got this issue on 2019.2.1 with this synth
* I have done the test on Chrome but did not succeed in reproducing the issue. @jcsteh, could this be a Firefox issue?
* I did not succeed in reproducing this issue on NVDA 2019.2.1 with eSpeak.

If it is confirmed that the issue is the same, the title should be changed.

I ran into some similar issues when working on #10593.

If someone wants to investigate further, in #10593 there are some unit tests that really helped to investigate, I put a log call in the start of "speak without pauses" to collect all the input speech sequences. Then the output can be inspected to see if that is where the problem is.

Other code I found suspicious was:
- https://github.com/nvaccess/nvda/blob/582cb55f936712102cd7844d0a7ce356d2e5e920/source/sayAllHandler.py#L194 You could try setting this to `if self.numBufferedLines < 2: `
- Nothing happens when this condition fails: https://github.com/nvaccess/nvda/blob/582cb55f936712102cd7844d0a7ce356d2e5e920/source/sayAllHandler.py#L172 Perhaps it should check the number of buffered lines?
At least for OneCore, the issue seems to be that it will stop on the first line of text after a blank line. The reason is that the blank line produces an index, but no actual text. And it looks like both OneCore, and Sapi5 (it seems() fails to include an index in its callback if the mark tag in the ssml appears directly before another mark tag, with no text in the middle. E.g.
```
<mark name="17" /><mark name="18" />Hello
```
In this case, only 18 will be included in the callback.
NVDA's speech manager then complains that 17 was skipped.
This bug is reproduceable in 2019.3 but not 2019.2.
I personally can't reproduce it with eSpeak, but I guess it is possible a similar problem could exist.
Hi Mick.
These problems occurs with sapi 4, too.
Tjere are some synths, like polish syntalk which has the problem with these marks.
Acapela group NVDA addon has this problem, too.
I’ve thought that it’s on their end, and I reported the problem to them.
Text to reproduce this with Onecore:
```
1.
2.
3.
4.

5.
6.
7.
8.
```
If you get OneCore to read this with sayAll, it will reach 5. and stop.
Yet if you remove the blank line, it will continue on down to 8.

Resolving patch:
diff --git a/source/speech/manager.py b/source/speech/manager.py
--- a/source/speech/manager.py
+++ b/source/speech/manager.py
@@ -8,6 +8,7 @@
 import queueHandler
 import synthDriverHandler
 from .commands import *
+from .commands import IndexCommand
 from .priorities import Spri, SPEECH_PRIORITIES
 
 class ParamChangeTracker(object):
@@ -147,6 +148,8 @@ def _reset(self):
 		self._curPriQueue = None
 		#: Maps indexes to BaseCallbackCommands.
 		self._indexesToCallbacks = {}
+		#: a list of indexes currently being spoken by the synthesizer
+		self._indexesSpeaking = []
 		#: Whether to push more speech when the synth reports it is done speaking.
 		self._shouldPushWhenDoneSpeaking = False
 
@@ -287,6 +290,11 @@ def _pushNextSpeech(self, doneSpeaking):
 			return self._pushNextSpeech(True)
 		seq = self._buildNextUtterance()
 		if seq:
+			# Record all indexes that will be sent to the synthesizer
+			# So that we can handle any accidentally skipped indexes.
+			for item in seq:
+				if isinstance(item, IndexCommand):
+					self._indexesSpeaking.append(item.index)
 			getSynth().speak(seq)
 
 	def _getNextPriority(self):
@@ -366,16 +374,38 @@ def _removeCompletedFromQueue(self, index):
 		return True, endOfUtterance
 
 	def _handleIndex(self, index):
-		valid, endOfUtterance = self._removeCompletedFromQueue(index)
-		if not valid:
-			return
-		callbackCommand = self._indexesToCallbacks.pop(index, None)
-		if callbackCommand:
+		# A synth (such as OneCore) may skip indexes
+		# If before another index, with no text content in between.
+		# Therefore, detect this and ensure we handle all skipped indexes.
+		handleIndexes = []
+		for oldIndex in list(self._indexesSpeaking):
+			if oldIndex < index:
+				log.debugWarning("Handling skipped index %s" % oldIndex)
+				handleIndexes.append(oldIndex)
+		handleIndexes.append(index)
+		valid, endOfUtterance = False, False
+		for i in handleIndexes:
 			try:
-				callbackCommand.run()
-			except:
-				log.exception("Error running speech callback")
+				self._indexesSpeaking.remove(i)
+			except ValueError:
+				log.debug("Unknown index %s, speech probably cancelled from main thread." % i)
+				break  # try the rest, this is a very unexpected path.
+			if i != index:
+				log.debugWarning("Handling skipped index %s" % i)
+			# we must do the following for each index, any/all of them may be end of utterance, which must
+			# trigger _pushNextSpeech
+			_valid, _endOfUtterance = self._removeCompletedFromQueue(i)
+			valid = valid or _valid
+			endOfUtterance = endOfUtterance or _endOfUtterance
+			if _valid:
+				callbackCommand = self._indexesToCallbacks.pop(i, None)
+				if callbackCommand:
+					try:
+						callbackCommand.run()
+					except Exception:
+						log.exception("Error running speech callback")
 		if endOfUtterance:
+			# Even if we have many indexes, we should only push next speech once.
 			self._pushNextSpeech(False)
 
 	def _onSynthDoneSpeaking(self, synth=None):


Test patch: