react-native-live-markdown icon indicating copy to clipboard operation
react-native-live-markdown copied to clipboard

Skip formatting if data unchanged on Android

Open tomekzaw opened this issue 1 year ago • 5 comments

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 avatar Dec 07 '24 11:12 tomekzaw

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.

tomekzaw avatar Dec 07 '24 11:12 tomekzaw

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

289Adam289 avatar Dec 09 '24 09:12 289Adam289

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

https://github.com/user-attachments/assets/96518f2c-705c-4dea-ab8a-0a33a3c35aeb

289Adam289 avatar Dec 11 '24 14:12 289Adam289

BUG: Emotes are clipped when toggling text font size.

https://github.com/user-attachments/assets/aa44e0ee-f4b6-41ca-952d-8dfe92cd18a6

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.

289Adam289 avatar Dec 11 '24 14:12 289Adam289

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

As for https://github.com/Expensify/react-native-live-markdown/pull/568#issuecomment-2536202684, 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.

tomekzaw avatar Dec 12 '24 16:12 tomekzaw