fix(ios): perf issues border masks#57413
Open
hannojg wants to merge 6 commits into
Open
Conversation
… RCTApplyLayerCornerConfiguration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Note
Follow up fix to:
^ This PR can either merged first, or closed, and we merge only this PR?
In discord we noticed performance regression when switching to the new arch in a few of our iOS surfaces, which after profiling turned out to be related to how borders are handled on the new architecture.
Before, on the old arch, none uniform border would be drawn as UIImages and would be drawn as background layer, where on new arch we start to use masks for none uniform borders. Using masks has the draw back of iOS needing to do offscreen render passes, which are expensive in the rendering pipeline, leading to hitches / frame drops.
In #57399 I addressed the issue by making sure to not masks UIImages explicitly if borders are uniform & circular. In this PR I extend the fix to also work for border radii that are only applied to few edges, but are otherwise uniform & circular.
I created this synthetic benchmark example, where we render many images with only bottom border radii, which highlights the perf issue. See before, after the fix:
Code for `RNTesterPlayground.js`
before_compressed.mp4
after_compressed.mp4
Investigating the issue with the xcode performance profiling tools we can see that with the mask approach we have over >300 offscreen passes which cause very long frames on the render server, averaging around ~20ms:
Performance comparison in numbers:
This fix is also more generic, so addressing any view extending
RCTViewComponentViewand using not-all-edges border radii.Changelog:
[IOS] [FIXED] - Performance: improve performance for border radii in
RCTViewComponentViewthat are uniform but don't cover all edgesTest Plan: