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

Improve performance of toHtml method by moving it to background thread #1092

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

planarvoid
Copy link
Contributor

Fix

In this PR I'm introducing a new approach to toHtml method. Previously it would block the UI thread. The reason was that the toHtml would work with the Editable object that represents the content of the editor. However, the object could change if the user would type anything. This is normally not an issue but since our toHtml method is not the fastest, there would be times where the user would change the span at the same time when we were trying to read it and we would have crashes.

The new approach introduced here is to make copy of the Editable object on the main thread and handle the processing from spannable to HTML on a background thread asynchronously. Since there is no standard way to make a copy of an Editable object, I'm simply copying the string content and reapplying the spans again. I think this works well but we should watch carefully if there are any new crashes appearing.

The libraries are upgraded because the app wouldn't let me run otherwise.

Test

  1. Run the new test
  2. Try editing/applying spans/saving in the DO app

Make sure strings will be translated:

  • 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.

@AmandaRiu AmandaRiu self-assigned this Nov 1, 2024
Copy link
Contributor

@AmandaRiu AmandaRiu left a comment

Choose a reason for hiding this comment

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

Reviewed the code, ran the automated test, and verified all works well on the Day One side. :shipit:

@AmandaRiu AmandaRiu merged commit cbb43e3 into trunk Nov 1, 2024
14 checks passed
@AmandaRiu AmandaRiu deleted the feature/improve-performance-of-to-html-method branch November 1, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants