Skip to content

Issue/880 center point not in rectangle #1044

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

Merged
merged 5 commits into from
Apr 19, 2023

Conversation

nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Apr 12, 2023

Fixes #880

We have 37 Sentry users experiencing the "IllegalArgumentException: Center point is not inside any of the rectangles" crash in Day One, all of which are on Android 13 (Tiramisu). This appears to be a platform issue rather than a problem with Aztec itself.

Update: It turns out the crash isn't limited to Android 13.

This PR resolves the problem by detecting and ignoring that crash on Android 13. I'm not well-versed with the Aztec codebase, so if there's a better way to resolve this please let me know.

To test:

  • In trunk, clear the example app's editor

  • Long press in the empty editor

  • Choose "Select all"

  • Boom!

  • Then pull this branch and observe the problem no longer occurs

  • If there are new strings that have to be translated, I have added them to the client's strings.xml as a part of the integration PR.

@cameocoder
Copy link

cameocoder commented Apr 12, 2023

This issue is not limited to TIRAMISU.

It happens when you "Select All" and the editor just contains empty spans. Spans that are started but do not actually contain any text/content.

Another way to reproduce the crash is to start the example app with a blank editor (no EXAMPLE text)

  1. Start an ordered/unordered list
  2. Select All

The reason it is reproducible from the example app when you clear the Example text may be because there are a number of empty spans that are left behind after trying to clear the text. In particular many AztecVisualLinebreak spans left behind which is a separate issue.

My guess is that the fix for this may be in handling onTextContextMenuItem and Aztec may need to implement its own selectAllText similar to how it custom handles cut/copy/paste. This may also fix the issue of spans being left behind when you select all of the EXAMPLE text and delete it.

@nbradbury
Copy link
Contributor Author

This issue is not limited to TIRAMISU.

@cameocoder Thanks for the clarification! I've removed the version check in 690ae78. I'm not well-versed with this codebase, so I'll wait for someone on the team to chime in about other solutions.

@danilo04 danilo04 requested a review from khaykov April 14, 2023 11:11
@khaykov khaykov self-assigned this Apr 14, 2023
@khaykov
Copy link
Contributor

khaykov commented Apr 14, 2023

While the fix prevents the crash, if you start typing after selecting empty span, the app will hang :)
Ideally we do not want to show the context menu when there is only empty span in editor, but I'm not sure we can do it on the library level.

As @cameocoder suggested, we can a add a bit of logic to onTextContextMenuItem to deal with it. I think not selecting anything when there is only a block span in editor is a valid option.

Something like this should handle it (have not tested it extensively):

android.R.id.selectAll -> {
               return if (text.toString() == Constants.END_OF_BUFFER_MARKER.toString()) {
                   deleteInlineStyleFromTheBeginning()
                   return true
               } else {
                   super.onTextContextMenuItem(id)
               }
           }

@nbradbury
Copy link
Contributor Author

@khaykov Thanks for the assist! I made the changes you suggested.

Copy link
Contributor

@planarvoid planarvoid left a comment

Choose a reason for hiding this comment

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

Thanks for the changes 👍 . I've tested this fixes the crash

@nbradbury nbradbury merged commit c51283d into trunk Apr 19, 2023
@nbradbury nbradbury deleted the issue/880-center-point-not-in-rectangle branch April 19, 2023 13:40
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.

Crash IllegalArgumentException: Center point is not inside any of the rectangles
4 participants