Improve speech performance, especially for lazy typesetting #1107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the PR that we discussed today in our meeting. I have reworked the handling of the speech-generation loop using the idea I mentioned toward the end: I record the return value from the
setTimeout()
command and useclearTimeout()
to prevent the next iteration of the loop from running if theattachSpeech()
render-action is called (e.g., the page is retypeset) while there are still MathItems waiting to be processed. That turns out to be much cleaner, and you can even eliminate theattachSpeechStart()
method along the way. So I think these are good changes.Just to have it in the record, this PR:
Timing
values to document options, where a page author can adjust them if needed.setTimeout()
in the KeyExplorer to a direct call toattachSeech()
if there is no speech already attached.private
toprotected
in case any of this needs to be subclassed.speechTimeout
to record the value of thesetTimeout()
calls for the speech loop.attachSpeech()
is called while there are still MathItems in theawaitingSpeech
array.setTimeout()
.attachSpeech()
, indicating that the render-action has done its job (of starting the asynchronous loop). Without this, every typeset call will runattachSpeech()
, even if it is not needed.setTimeout()
to schedule the next loop and save the return value, otherwise, we clear the timer indicator and stop looping.attachSpeech()
method so that it is not performed until we actually typeset the math.