Avoid freeze removing blank lines from IMPROVED and END_INCLUSIVE UIA consoles#14822
Conversation
|
CC: @codeofdusk |
There was a problem hiding this comment.
I like this: it's a small, targeted fix.
That said, I thought constraining ourselves to the visible text worked around the microsoft/terminal#6986 issues? CC @carlos-zamora
|
Also, consider a situation in which the console has (actual) empty lines at the end of output. If you call |
Yes, I considered it. But, for reasons I don't know exactly, even with no prompt string (that's beyond a condition of reasonable tradeoff, imho) I see blank lines of last output (I mean, I find them exploring with object navigation). I think exploration and voice work with slightly different sources. |
| # #14689: IMPROVED and END_INCLUSIVE UIA consoles have many blank lines, | ||
| # which slows speech dictionary processing to a halt | ||
| res = super()._get_text() | ||
| return res.rstrip("\r\n") |
There was a problem hiding this comment.
is there a reason why we are always stripping here, rather than checking the length of the tail like before e.g. 100 chars?
There was a problem hiding this comment.
Performance, and the fact it's a more targeted solution (even into striping only \r\n). I noticed that _get_text is called more times even when you write a single character in apiLevel 0 terminal (with no voice output). However, I can introduce it, if you think it's more reasonable.
There was a problem hiding this comment.
I am surprised there is a performance hit for checking the length of the tail, stripping is surely the most expensive operation.
My concern with this approach is that intentionally empty buffers that are just a few newlines might not be reported correctly.
For reference, you can probably cache _get_text, however that might cause other performance issues (not always getting the very latest text for a given core cycle).
There was a problem hiding this comment.
Ok, I added previous check with IGNORE_TRAILING_WHITESPACE_LENGTH.
Added typing Co-authored-by: Sean Budd <seanbudd123@gmail.com>
|
Thanks @ABuffEr |
Link to issue number:
Fixes #14689
Summary of the issue:
IMPROVED (apiLevel 1) and END_INCLUSIVE (apiLevel 0) UIA consoles produce a lot of blank lines (more than 17000) in some output, causing a NVDA freeze during speech dictionary processing.
Description of user facing changes
None.
Description of development approach
I added a _get_text method to ConsoleUIATextInfo class (for apiLevel 1 consoles), stripping all \r\n on the rightside of output from _get_text of superclass (implicitly used previously).
For apiLevel 0 consoles (ConsoleUIATextInfoWorkaroundEndInclusive class), I simply considered that the _get_text already present calls _get_text from superclass, that is, ConsoleUIATextInfo, so text is already cleaned.
Testing strategy:
Manual, with #14689 str, in apiLevel 1 console.
Known issues with pull request:
Hopefully none, this time.
Change log entries:
Bug fixes
Code Review Checklist: