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

[Android] Patch react-native-svg to cache parsed paths #6583

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Nov 21, 2024

Kind of a hackfix. See software-mansion/react-native-svg#2548.

We don't want to parse these icons' paths every time we create a view with them — this is downright silly.

This caches them forever but it's ok because our SVGs are not dynamic and we have a limited number of them.

Test Plan

Verify we're hitting the cache as expected. As you scroll feed, you have fewer cold parses and soon run out of them.

cache.mov

Before

This function is a significant part of the createViewInstance trace.

Screenshot 2024-11-21 at 00 40 30

After

It's a smaller part of the overall picture.

Screenshot 2024-11-21 at 01 14 22

Proper fix

This doesn't fully solve the issue — this library is still showing up in onDraw, for example. I think ideally we'd move to https://github.com/zamplyy/react-native-vector-image-plugin or something like it, but let's land this for now.

@arcalinea arcalinea temporarily deployed to patch-svg-paths - social-app PR #6583 November 21, 2024 01:30 — with Render Destroyed
Copy link

The Pull Request introduced fingerprint changes against the base commit:

Fingerprint diff
[{"type":"dir","filePath":"node_modules/react-native-svg","reasons":["bareRncliAutolinking"],"hash":"2fe338f8d82e5ee1d2f307a81b07a0cb6924fa83"},{"type":"dir","filePath":"patches","reasons":["patchPackage"],"hash":"df78155a2cbb249ca26ea0a2e4d1b54cf88122ae"}]

Generated by PR labeler 🤖

Copy link

Old size New size Diff
8.06 MB 8.06 MB 0 B (0.00%)

Copy link
Contributor

@haileyok haileyok left a comment

Choose a reason for hiding this comment

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

Nice. This makes sense, great find.

@gaearon gaearon merged commit 84724bb into main Nov 21, 2024
6 checks passed
@gaearon gaearon deleted the patch-svg-paths branch November 21, 2024 22:32
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