Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvda logs a lot of '\r\n\r\n' if UIA support for Windows console is enabled #14689

Closed
cary-rowen opened this issue Mar 2, 2023 · 9 comments · Fixed by #14703 or #14822
Closed

nvda logs a lot of '\r\n\r\n' if UIA support for Windows console is enabled #14689

cary-rowen opened this issue Mar 2, 2023 · 9 comments · Fixed by #14703 or #14822
Labels
api/uia Feature or bug requires an understanding of UIA app/windows-console Legacy console in Windows, potentially will superseded by the app/windows-terminal p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Milestone

Comments

@cary-rowen
Copy link
Contributor

Steps to reproduce:

  1. In NVDA's Advanced Settings panel, make the following settings:
  • Windows Console support: combo box: UIA when available
  1. Open cmd or git bash and press NVDA+Shift+M(Laptop);

Actual behavior:

There are a lot of '\r\n' in the log.

Expected behavior:

There won't be so many '\r\n' in the log

NVDA logs, crash dumps and other attachments:

log.txt

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

2023.1Beta2

Windows version:

Windows 10 22H2 (AMD64) build 19045.2604

Name and version of other software in use when reproducing the issue:

None

Other information about your system:

None

Other questions

Does the issue still occur after restarting your computer?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

2022.4 is the same

If NVDA add-ons are disabled, is your problem still occurring?

Yes

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

Yes

@CyrilleB79
Copy link
Collaborator

According to your log, the spoken string is 18095 character long. And there are 17994 characters after the last '>', i.e. 8997 '\r\n'.

@codeofdusk: any idea why so many new lines are captured in the command window when it becomes the foreground?

@codeofdusk
Copy link
Contributor

This is a known bug in API level 0 consoles (see microsoft/terminal#6986). In consoles with less than API level 2, no support is provided as indicated in the user guide.

Mitigation strategies:

  • Ideally, upgrade to Windows 11 Sun Valley 2.
  • If possible, use Windows Terminal (wt.exe), which is continuously updated.
  • If all else fails, upgrade conhost.exe to the version included with Windows Terminal. I've provided guidance in other issues, etc. on how to do that.

@seanbudd I recommend closing as duplicate of microsoft/terminal#6986.

CC @carlos-zamora, @DHowett.

@cary-rowen
Copy link
Contributor Author

@codeofdusk
If I can't upgrade to windows11 now, can you provide other solutions?

This problem bothers me because of: ABuffEr/numberProcessing#4

But due to another issue, not forcing UIA support for Windows Console under Chinese operating systems will cause every Chinese character displayed on the screen to be reported twice by NVDA.

@codeofdusk
Copy link
Contributor

If you can't upgrade, either use Windows Terminal (wt.exe) or replace your conhost.

@ABuffEr
Copy link
Contributor

ABuffEr commented Mar 2, 2023

Hi,
just for documentation, the freeze seems to born in speechDictHandler.processText function. Adding something like:

	try:
		if config.conf["UIA"]["winConsoleImplementation"] == "UIA":
			stripText = text.rstrip()
			if len(text)-len(stripText) > 10000:
				text = stripText
	except KeyError:
		pass

before the dictionaries loop, no freeze happens. But I doubt it would be considered an acceptable solution for a PR...

@cary-rowen
Copy link
Contributor Author

@codeofdusk
You wrote:

If all else fails, upgrade conhost.exe to the version included with Windows Terminal. I've provided guidance in other issues, etc. on how to do that.


Can you provide a link on how to do this?

@codeofdusk
Copy link
Contributor

I've updated my console test package to the latest released build of OpenConsole. Hopefully this can provide a stopgap solution until you upgrade to SV2 or switch to wt.

@seanbudd
Copy link
Member

seanbudd commented Mar 7, 2023

@ABuffEr a fix similar to what you suggested is appropriate

@seanbudd seanbudd added p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation. app/windows-console Legacy console in Windows, potentially will superseded by the app/windows-terminal api/uia Feature or bug requires an understanding of UIA labels Mar 7, 2023
@ABuffEr
Copy link
Contributor

ABuffEr commented Mar 7, 2023

Ok, I'll provide a PR in next hours.

seanbudd pushed a commit that referenced this issue Apr 5, 2023
… enabled (#14703)

Fixes #14689

Summary of the issue:
Due to a bug in API Level 0 and 1 consoles (see microsoft/terminal/#5243), sometimes NVDA freezes during dictionary processing of console text, containing a huge amount of blank lines.

Description of user facing changes
None.

Description of development approach
If current focus object has apiLevel 0 or 1, and difference between regular text and text with rightside blank lines stripped is greater than 100, we use cleaned text for dictionary processing.
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Apr 5, 2023
seanbudd pushed a commit that referenced this issue Apr 18, 2023
… consoles (#14822)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/uia Feature or bug requires an understanding of UIA app/windows-console Legacy console in Windows, potentially will superseded by the app/windows-terminal p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
6 participants