Skip to content

Another fix for dismiss braille message issue of remove redundant braille.BrailleHandler.update executions#16506

Closed
burmancomp wants to merge 3 commits into
nvaccess:masterfrom
burmancomp:yetAnotherBrailleRedundantUpdatesFix
Closed

Another fix for dismiss braille message issue of remove redundant braille.BrailleHandler.update executions#16506
burmancomp wants to merge 3 commits into
nvaccess:masterfrom
burmancomp:yetAnotherBrailleRedundantUpdatesFix

Conversation

@burmancomp

Copy link
Copy Markdown
Contributor

Link to issue number:

fixes #16501

Summary of the issue:

Braille message was not dismissed when moving to new object where region was TextInfoRegion.
I noticed that when messages were shown infinitely. I typed in start menu search box "wordpad" and pressed enter. Although Wordpad edit window was activated, braille was not updated.
Also, what triggered message dismiss, changed although this was not intention.

Description of user facing changes

Hopefully above issues are fixed.

Description of development approach

Testing strategy:

Tested locally

Known issues with pull request:

none at this moment

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@burmancomp burmancomp marked this pull request as ready for review May 8, 2024 11:28
@burmancomp burmancomp requested a review from a team as a code owner May 8, 2024 11:28
@burmancomp burmancomp requested a review from michaelDCurran May 8, 2024 11:28
@LeonarddeR

Copy link
Copy Markdown
Collaborator

This is why I was for a revert initially. Now, it is no longer possible to see from the diff were we came from.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, but if a third fixup would be necessary, I'd rather see a revert of the former prs and have a broader test with try builds first.

@XLTechie

XLTechie commented May 9, 2024 via email

Copy link
Copy Markdown
Collaborator

@burmancomp

Copy link
Copy Markdown
Contributor Author

I try to revert if new issues are found.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Here is a diff against the original code:

diff --git a/source/braille.py b/source/braille.py
index 450594c8b..3e5c1595d 100644
--- a/source/braille.py
+++ b/source/braille.py
@@ -2560,9 +2560,11 @@ class BrailleHandler(baseObject.AutoPropertyObject):
 		self.mainBuffer.update()
 		# Last region should receive focus.
 		self.mainBuffer.focus(region)
-		self.scrollToCursorOrSelection(region)
 		if self.buffer is self.mainBuffer:
-			self.update()
+			if isinstance(region, TextInfoRegion):
+				self.scrollToCursorOrSelection(region)
+			else:
+				self.update()
 		elif self.buffer is self.messageBuffer and keyboardHandler.keyCounter>self._keyCountForLastMessage:
 			self._dismissMessage()
 
@@ -2614,10 +2616,11 @@ class BrailleHandler(baseObject.AutoPropertyObject):
 					region.pendingCaretUpdate = False
 			self.mainBuffer.update()
 			self.mainBuffer.restoreWindow()
-			if scrollTo is not None:
-				self.scrollToCursorOrSelection(scrollTo)
 			if self.buffer is self.mainBuffer:
-				self.update()
+				if scrollTo is not None:
+					self.scrollToCursorOrSelection(scrollTo)
+				else:
+					self.update()
 			elif (
 				self.buffer is self.messageBuffer
 				and keyboardHandler.keyCounter > self._keyCountForLastMessage

Comment thread source/braille.py Outdated
elif self.buffer is self.mainBuffer:
self.update()
if self.buffer is self.mainBuffer:
if isinstance(region, TextInfoRegion):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only call scrollToCursorOrSelection for TextInfoRegion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware about other regions with cursor or selection. I suppose that scrollToCursorOrSelection does nothing if there is no cursor nor selection.
If there is cursor or selection scrollTo executes BrailleHandler.update.
Regions without cursor or selection needs that BrailleHandler.update is executed but if there is cursor or selection scrollTo executes it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scrollToCursorOrSelection has an explicit check where region is not a TextInfoRegion. I guess that code is there for a reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for mentioning this. I am sorry. I ignored it because I did not understand it, and things seemed to work. I should have considered it more.
It seems that not isinstance(region, TextInfoRegion) might be (is) there for situation that sometimes some other type of regions which are not class of TextInfoRegion or its descendants would have selection feature.

Simple solution which does not have issues of #16499 or #16501 would be to go back to code before #16463 except removing line
self.updateDisplay()
from BrailleBuffer.scrollTo function.

Do you have considerations against this?

@burmancomp burmancomp marked this pull request as draft May 9, 2024 15:22
@burmancomp burmancomp marked this pull request as ready for review May 9, 2024 16:45
@LeonarddeR

Copy link
Copy Markdown
Collaborator

I think I'd like to go back to before #16463 and just leave this code alone.

@burmancomp

Copy link
Copy Markdown
Contributor Author

I think I'd like to go back to before #16463 and just leave this code alone.

May I ask what you see is problem with last commit?

When going before #16463 there are redundant BrailleHandler.update executions. Why same update should be done more than once?

@burmancomp

Copy link
Copy Markdown
Contributor Author

@dkager could you kindly explain me this code line in scrollToCursorOrSelection function:

elif not isinstance(region, TextInfoRegion) or not region.obj.isTextSelectionAnchoredAtStart:

When region is not TextInfoRegion or its descendant but scrollTo function is executed?

@seanbudd

Copy link
Copy Markdown
Member

Could you please open a PR to revert #16463 and #16501?
Considering this was initially designed to improve performance, and there is no significant performance improvements, it's not worthwhile to increase code complexity.
These changes have gone from a theoretical performance improvement and code complexity reduction to more complex and harder to maintain code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants