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

Skip formatting if data unchanged on Android #568

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tomekzaw
Copy link
Collaborator

@tomekzaw tomekzaw commented Dec 7, 2024

Details

This PR skips removing and applying spans on Android if the text, ranges and styles are unchanged to previous run of MarkdownFormatter as span operations are relatively time-consuming on Android.

In particular, this lets us save some time during mounting phase as per systraces below:

Before

Screenshot 2024-12-07 at 12 04 14

After

Screenshot 2024-12-07 at 12 03 13

Related Issues

GH_LINK

Manual Tests

Linked PRs

@tomekzaw tomekzaw requested a review from j-piasecki December 7, 2024 11:12
@tomekzaw
Copy link
Collaborator Author

tomekzaw commented Dec 7, 2024

Note: I feel like there could be some edge-cases where such optimization leads to incorrect result but I wasn't able to find one so far. This needs a bit of thought prior to merging.

@289Adam289 Could you please help me test this PR for regressions? Thanks in advance.

@289Adam289
Copy link

Sure, happy to help. I will get to it soon

Comment on lines +32 to +36
if (text.equals(mPrevText) && markdownRanges == mPrevMarkdownRanges && markdownStyle == mPrevMarkdownStyle) {
// Use shallow comparison of markdown ranges and markdown style
// to optimistically skip removing and applying the same spans
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't there anything that could alter the styles in between format passes? I'm not sure how it will behave with the commit hook when the text doesn't change but the node is cloned.

@tomekzaw tomekzaw marked this pull request as draft December 9, 2024 11:05
@289Adam289
Copy link

BUG:
Coping and pasting text on top of exactly the same text formatted range breaks markdown formatting
Reproduction steps:

  1. Write *world*
  2. Copy exactly *world*
  3. select *world*
  4. Paste
Screen.Recording.2024-12-11.at.12.58.30.mov

@289Adam289
Copy link

BUG:
Emotes are clipped when toggling text font size.

Screen.Recording.2024-12-11.at.12.59.46.mov

I've confirmed that both bug are not reproducible on main and are regressions from this PR
I will try to test this PR on E/App tomorrow.

@tomekzaw
Copy link
Collaborator Author

tomekzaw commented Dec 12, 2024

Thanks @289Adam289 for testing out this PR and finding the regressions.

As for #568 (comment), right now I don't have any idea on how to modify the logic to avoid this bug.

Let's keep this PR as draft for now.

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.

3 participants