Repository navigation
Conversation
`BorderDrawable` allocated a `Path` on every draw of a single-color rectangular border and a `DashPathEffect` for every edge of a dashed or dotted border on every draw. Each time it rebuilt the paths of a rounded border, it also built an outline path that nothing reads. It now keeps the single-border path, replaces the dash effect only when the border style or width changes, and no longer builds the outline path. `BorderDrawableTest` passes, including new checks that an unchanged dashed border draws with the same path and dash effect and that a width change replaces the effect. Both checks fail without this change. On an arm64 Android 16 emulator, a benchmark in RNTester's Release build recorded one border into a `RenderNode` per draw, with both versions of `BorderDrawable` in one process, alternating which ran first, over three rounds of 21 samples: | Border | Before | After | | --- | --- | --- | | 1px, one color | 595–721 ns, 164 B | 405–555 ns, 66 B | | 2px, dashed | 1,480–1,594 ns, 606 B | 425–528 ns, 66 B | | 1px, rounded, after `invalidateSelf()` | 1,448–1,685 ns, 623 B | 1,177–1,320 ns, 442 B | The bytes are Java heap allocated per draw, including the `RenderNode` recording. A rounded border drawn again without invalidation takes the same time and allocation in both versions. Signed-off-by: James Ide <ide@expo.dev>
Visual regressionNo visual differences at ios: no capture |
ide
marked this pull request as ready for review
December 4, 2026 19:36
This branch has not been deployed
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:
BorderDrawableallocated aPathon every draw of a single-color rectangular border and aDashPathEffectfor every edge of a dashed or dotted border on every draw. Each time it rebuilt the paths of a rounded border, it also built an outline path that nothing reads. It now keeps the single-border path, replaces the dash effect only when the border style or width changes, and no longer builds the outline path.Changelog:
[INTERNAL] [CHANGED] - Reuse
BorderDrawable's paths and dash effects across draws.Test Plan:
BorderDrawableTestpasses, including new checks that an unchanged dashed border draws with the same path and dash effect and that a width change replaces the effect. Both checks fail without this change.On an arm64 Android 16 emulator, a benchmark in RNTester's Release build recorded one border into a
RenderNodeper draw, with both versions ofBorderDrawablein one process, alternating which ran first, over three rounds of 21 samples:invalidateSelf()The bytes are Java heap allocated per draw, including the
RenderNoderecording. A rounded border drawn again without invalidation takes the same time and allocation in both versions.