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

Remove most uses of CompareInBounds #13244

Merged
7 commits merged into from Jul 1, 2022
Merged

Conversation

carlos-zamora
Copy link
Member

Summary of the Pull Request

Replaces most uses of Viewport::CompareInBounds() with til::point's < and > operators. CompareInBounds has been the cause of a bunch of UIA crashes over the years. Replacing them entirely ensures that the FAILFAST_IF isn't ever touched.

Unfortunately, we still need IncrementInBounds and DecrementInBounds to have support for that exclusive end.

References

#13183

@carlos-zamora

This comment was marked as outdated.

src/types/UiaTextRangeBase.cpp Outdated Show resolved Hide resolved
src/types/UiaTextRangeBase.cpp Outdated Show resolved Hide resolved
src/types/viewport.cpp Show resolved Hide resolved
src/types/viewport.cpp Outdated Show resolved Hide resolved
@carlos-zamora carlos-zamora marked this pull request as ready for review June 9, 2022 20:48
@carlos-zamora
Copy link
Member Author

ok, this works really well.

@carlos-zamora carlos-zamora added the Needs-Second It's a PR that needs another sign-off label Jun 10, 2022
@ghost ghost requested review from zadjii-msft, PankajBhojwani and DHowett June 10, 2022 19:45
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

I'll throw myself on the block list to review it -- especially because we've been talking about backporting it as part of also backporting a conversion of UIA to til::point

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 10, 2022
@carlos-zamora
Copy link
Member Author

I'll throw myself on the block list to review it -- especially because we've been talking about backporting it as part of also backporting a conversion of UIA to til::point

Created the 1.14 port version in #13313

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 16, 2022
src/types/viewport.cpp Outdated Show resolved Hide resolved
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jun 30, 2022
@ghost
Copy link

ghost commented Jun 30, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit f785168 into main Jul 1, 2022
@ghost ghost deleted the dev/cazamor/remove-compareInBounds branch July 1, 2022 00:06
@codeofdusk
Copy link
Contributor

Will this make it to SV2 as well? Any stability fixes will be good to help strengthen our case for nvaccess/nvda#10964 making it into the next release!

@zadjii-msft zadjii-msft added the Needs-Discussion Something that requires a team discussion before we can proceed label Jul 5, 2022
@zadjii-msft
Copy link
Member

Marking for discussion to see if this can be backported. I'm guessing that the servicing bar is too high for this 😕 but we'll discuss.

@DHowett
Copy link
Member

DHowett commented Jul 5, 2022

This definitely can't make it into SV2; the boarding doors are closed for sure. Sorry.

@codeofdusk
Copy link
Contributor

Makes sense, thanks for letting me know.

@ghost
Copy link

ghost commented Jul 6, 2022

🎉Windows Terminal Preview v1.15.186 has been released which incorporates this pull request.:tada:

Handy links:

@zadjii-msft zadjii-msft removed the Needs-Discussion Something that requires a team discussion before we can proceed label Jul 11, 2022
carlos-zamora added a commit that referenced this pull request Sep 1, 2022
ghost pushed a commit that referenced this pull request Sep 2, 2022
This reverts commit f785168 (PR #13244)

The error logged to NVDA was caused by the following line of code in `_getTextValue()`:
`THROW_HR_IF(E_FAIL, !bufferSize.IsInBounds(_start) || !bufferSize.IsInBounds(_end));`
NVDA would expand a text range to encompass the document in the alt buffer. This means that the "end" would be set to the dangling "endExclusive" point (x = left, y = one past the end of the buffer). This is a valid range!
However, upon extracting the text, we would hit the code above. The exclusive end doesn't actually point to anything in the buffer, so we would falsly throw `E_FAIL`.

Though this could be fixed by adding a special check for the `endExclusive` in the line above, I suspect there are other places throughout the UIA code that hit this problem too. The safest course of action is to revert this commit entirely since it was a code health commit (it doesn't actually close an issue).

Closes #13866
DHowett pushed a commit that referenced this pull request Sep 6, 2022
This reverts commit f785168 (PR #13244)

The error logged to NVDA was caused by the following line of code in `_getTextValue()`:
`THROW_HR_IF(E_FAIL, !bufferSize.IsInBounds(_start) || !bufferSize.IsInBounds(_end));`
NVDA would expand a text range to encompass the document in the alt buffer. This means that the "end" would be set to the dangling "endExclusive" point (x = left, y = one past the end of the buffer). This is a valid range!
However, upon extracting the text, we would hit the code above. The exclusive end doesn't actually point to anything in the buffer, so we would falsly throw `E_FAIL`.

Though this could be fixed by adding a special check for the `endExclusive` in the line above, I suspect there are other places throughout the UIA code that hit this problem too. The safest course of action is to revert this commit entirely since it was a code health commit (it doesn't actually close an issue).

Closes #13866

(cherry picked from commit bfd5248)
Service-Card-Id: 85405833
Service-Version: 1.15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants