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

Performance: use React Native Render HTML explicit composite architecture #4502

Merged
merged 2 commits into from
Aug 11, 2021

Conversation

jsamr
Copy link
Collaborator

@jsamr jsamr commented Aug 7, 2021

@marcaaron

Details

Summary of changes:

  1. A new component, HTMLEngineProvider, has been created. This component renders TRenderEngineProvider and RenderHTMLConfigProvider. All configuration props, including custom renderers, are now handled by this component, which is rendered at the root of the application (App.js).
  2. RenderHTML component has been greatly simplified to a one-file component rendering RenderHTMLSource component.
  3. A little fix has been provided regarding the <edited> element (see commit).

This refactoring follows closely guidance provided in the docs: https://git.io/JRcZb

Fixed Issues

#4123

Tests

There are no behavioral changes. If something should not work, it would break immediately.

QA Steps

N/A

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

N/A

@jsamr
Copy link
Collaborator Author

jsamr commented Aug 7, 2021

@marcaaron I am planning to do two benchmarks as we discussed in #4123; the only thing I am unsure is this:

I build the release native app then time when the FlatList onLayout is called (I know, not perfect) and log this to our log server

Can you provide me guidance on how to "log to your log server", and how to check those logs?

@marcaaron
Copy link
Contributor

Can you provide me guidance on how to "log to your log server", and how to check those logs?

Ah to clarify, only Expensify staff can check these logs. But it's something I can help you with no problem.

@marcaaron
Copy link
Contributor

Ok! Did some pretty basic benchmarking here on an Android release build. Unfortunately, I didn't see a huge difference in how long it takes to lists of chat messages. This PR is maybe 10 ms faster than the main branch - which seems inconclusive.

Not sure whether you have other ideas about what to test?

On the positive side, things didn't get slower and everything appears to work fine so I can't think of a reason not to recommend these changes.

@jsamr
Copy link
Collaborator Author

jsamr commented Aug 10, 2021

@marcaaron The thing is that onLayout will give you the first paint (depending on initialNumToRender, while this patch is interesting considering the cumulative cost of rendering each cell. My expectation would be a 200ms gain for 100 items; so you would have to set initialNumToRender to 100 to test my hypothesis :-) Moreover, if the render time of RenderHTML (7 to 11ms in my audit) is negligible compared to the render time of each cell, you might find 200ms negligible compared to the total render time of the first paint...

@marcaaron
Copy link
Contributor

My expectation would be a 200ms gain for 100 items; so you would have to set initialNumToRender to 100 to test my hypothesis

Got it. That makes sense. I'm not sure there is any requirement that we load 100 or more items at once (at least not yet), but it's good to know it will be faster if we did.

@jsamr jsamr marked this pull request as ready for review August 11, 2021 18:36
@jsamr jsamr requested a review from a team as a code owner August 11, 2021 18:36
@MelvinBot MelvinBot requested review from Luke9389 and removed request for a team August 11, 2021 18:37
This allows to avoid the cost of instantiating a new engine for each
HTML snippet, see https://git.io/JRcZb

fix Expensify#4123
Self-closing tags are only allowed for void elements in HTML5.
Otherwise, the required behavior for parsers is to ignore the slash and
consider the expression as a tag opening. This will lead to bugs with
htmlparser2 if `<edited />` was followed by other tags, where those tags
would be parsed as children of `<edited>` instead of siblings.
@jsamr
Copy link
Collaborator Author

jsamr commented Aug 11, 2021

@marcaaron Great! I fixed some conflicts with main and marked this PR as ready for review. Tell me if there is anything else I should do!

Copy link
Contributor

@Luke9389 Luke9389 left a comment

Choose a reason for hiding this comment

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

No changes to request.

@marcaaron marcaaron merged commit e60b62b into Expensify:main Aug 11, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @marcaaron in version: 1.0.85-10 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@botify
Copy link

botify commented Aug 25, 2021

This has been deployed to production and is now subject to a 7-day regression period.
If no regressions arise, payment will be issued on 2021-09-01. 🎊

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.0.86-11 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@botify
Copy link

botify commented Aug 30, 2021

This has been deployed to production and is now subject to a 7-day regression period.
If no regressions arise, payment will be issued on 2021-09-06. 🎊

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.

5 participants