Skip to content

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Oct 9, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

  • This moves the entire script logic from afterEvaluate (which is too late to register tasks) into androidComponents.onVariants. Since our tasks only run when there's an android app being build, it's a good place to hook our logic into. It also gives us direct access to the variant, so we don't have to search for it and build a releases map anymore. The tasks are configured per-variant, omitting the debug variant.
  • Register our tasks lazily to avoid early resolution via register instead of create

I tested it locally both debug and release builds and the react-native-legal json file is correctly generated in both cases. Also, our tasks run correctly for the release build, you can see here I uploaded sourcemaps: https://sentry-sdks.sentry.io/settings/projects/sentry-react-native/source-maps/23317267-0d24-5f07-9852-28630b8cf98a/

The only thing that probably needs more testing is modules collection, because it generated an empty json locally for me, but perhaps I was doing something unexpected, because I was running gradle builds directly as opposed calling yarn/npx. If someone could verify it works, that'd be great.

💡 Motivation and Context

Closes #5236

💚 How did you test it?

manually

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Contributor

github-actions bot commented Oct 9, 2025

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 441.30 ms 438.43 ms -2.87 ms
Size 17.75 MiB 19.70 MiB 1.95 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
8a4ce6f 422.88 ms 408.33 ms -14.55 ms
95aaf8a 437.89 ms 419.45 ms -18.44 ms
1bea095+dirty 401.42 ms 426.93 ms 25.52 ms
c08359e 421.87 ms 445.37 ms 23.50 ms
ba75c7c 367.72 ms 369.16 ms 1.44 ms
0b64753+dirty 448.67 ms 474.61 ms 25.94 ms
bfe454a+dirty 573.44 ms 579.46 ms 6.02 ms
49ef936+dirty 405.96 ms 417.22 ms 11.26 ms
a0b15d6 423.06 ms 437.77 ms 14.71 ms
c9e95bd 428.04 ms 458.70 ms 30.65 ms

App size

Revision Plain With Sentry Diff
8a4ce6f 17.75 MiB 19.68 MiB 1.94 MiB
95aaf8a 17.75 MiB 19.68 MiB 1.93 MiB
1bea095+dirty 17.75 MiB 19.70 MiB 1.95 MiB
c08359e 17.75 MiB 20.15 MiB 2.41 MiB
ba75c7c 17.75 MiB 20.15 MiB 2.41 MiB
0b64753+dirty 17.75 MiB 19.70 MiB 1.95 MiB
bfe454a+dirty 17.75 MiB 19.69 MiB 1.94 MiB
49ef936+dirty 17.75 MiB 19.69 MiB 1.94 MiB
a0b15d6 17.75 MiB 20.15 MiB 2.41 MiB
c9e95bd 17.75 MiB 19.68 MiB 1.93 MiB

Previous results on branch: rz/fix/react-native-legal-compat

Startup times

Revision Plain With Sentry Diff
c5a3d21+dirty 462.63 ms 475.18 ms 12.55 ms

App size

Revision Plain With Sentry Diff
c5a3d21+dirty 17.75 MiB 19.70 MiB 1.95 MiB

Copy link
Contributor

github-actions bot commented Oct 9, 2025

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 341.60 ms 391.98 ms 50.38 ms
Size 7.15 MiB 8.43 MiB 1.28 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
49ef936+dirty 333.72 ms 387.51 ms 53.79 ms
5526494+dirty 380.79 ms 432.70 ms 51.91 ms
3bd3f0d+dirty 334.38 ms 402.19 ms 67.81 ms
1853710+dirty 360.67 ms 396.28 ms 35.61 ms
8d89cc9+dirty 357.69 ms 415.79 ms 58.10 ms
000da7a+dirty 347.89 ms 381.98 ms 34.09 ms
6fee48d+dirty 370.23 ms 427.86 ms 57.63 ms
c4e097a+dirty 382.43 ms 443.77 ms 61.34 ms
c9e95bd+dirty 339.32 ms 401.24 ms 61.92 ms
6479fd5+dirty 393.06 ms 434.04 ms 40.98 ms

App size

Revision Plain With Sentry Diff
49ef936+dirty 7.15 MiB 8.42 MiB 1.26 MiB
5526494+dirty 7.15 MiB 8.41 MiB 1.26 MiB
3bd3f0d+dirty 7.15 MiB 8.43 MiB 1.28 MiB
1853710+dirty 7.15 MiB 8.41 MiB 1.26 MiB
8d89cc9+dirty 7.15 MiB 8.41 MiB 1.26 MiB
000da7a+dirty 7.15 MiB 8.41 MiB 1.26 MiB
6fee48d+dirty 7.15 MiB 8.41 MiB 1.26 MiB
c4e097a+dirty 7.15 MiB 8.41 MiB 1.26 MiB
c9e95bd+dirty 7.15 MiB 8.41 MiB 1.26 MiB
6479fd5+dirty 7.15 MiB 8.41 MiB 1.26 MiB

Copy link
Contributor

github-actions bot commented Oct 9, 2025

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1238.26 ms 1237.27 ms -0.99 ms
Size 3.19 MiB 4.56 MiB 1.37 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d751a5d+dirty 1212.22 ms 1217.94 ms 5.71 ms
9f211e3+dirty 1215.38 ms 1218.15 ms 2.77 ms
785ffb1+dirty 1213.71 ms 1213.37 ms -0.35 ms
95aaf8a+dirty 1206.83 ms 1213.65 ms 6.81 ms
c94a927+dirty 1211.33 ms 1223.31 ms 11.97 ms
98f632c+dirty 1221.38 ms 1229.26 ms 7.88 ms
459a438+dirty 1218.39 ms 1226.14 ms 7.75 ms
46bd012+dirty 1231.78 ms 1212.30 ms -19.47 ms
93137d1+dirty 1232.69 ms 1245.18 ms 12.49 ms
3e0a5f9+dirty 1233.65 ms 1239.10 ms 5.45 ms

App size

Revision Plain With Sentry Diff
d751a5d+dirty 3.19 MiB 4.54 MiB 1.36 MiB
9f211e3+dirty 3.19 MiB 4.48 MiB 1.29 MiB
785ffb1+dirty 3.19 MiB 4.38 MiB 1.19 MiB
95aaf8a+dirty 3.19 MiB 4.44 MiB 1.25 MiB
c94a927+dirty 3.19 MiB 4.56 MiB 1.37 MiB
98f632c+dirty 3.19 MiB 4.38 MiB 1.19 MiB
459a438+dirty 3.19 MiB 4.55 MiB 1.36 MiB
46bd012+dirty 3.19 MiB 4.38 MiB 1.19 MiB
93137d1+dirty 3.19 MiB 4.55 MiB 1.37 MiB
3e0a5f9+dirty 3.19 MiB 4.38 MiB 1.19 MiB

Previous results on branch: rz/fix/react-native-legal-compat

Startup times

Revision Plain With Sentry Diff
c5a3d21+dirty 1219.57 ms 1233.40 ms 13.83 ms

App size

Revision Plain With Sentry Diff
c5a3d21+dirty 3.19 MiB 4.56 MiB 1.37 MiB

Copy link
Contributor

github-actions bot commented Oct 9, 2025

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1229.21 ms 1228.21 ms -1.00 ms
Size 2.63 MiB 3.99 MiB 1.36 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d751a5d+dirty 1215.57 ms 1220.56 ms 4.99 ms
9f211e3+dirty 1218.80 ms 1233.88 ms 15.08 ms
785ffb1+dirty 1237.63 ms 1240.50 ms 2.87 ms
95aaf8a+dirty 1234.78 ms 1241.94 ms 7.16 ms
c94a927+dirty 1227.14 ms 1239.64 ms 12.50 ms
98f632c+dirty 1236.40 ms 1241.62 ms 5.22 ms
459a438+dirty 1222.12 ms 1214.60 ms -7.53 ms
46bd012+dirty 1220.49 ms 1226.89 ms 6.40 ms
93137d1+dirty 1230.73 ms 1230.98 ms 0.25 ms
3e0a5f9+dirty 1226.94 ms 1230.02 ms 3.08 ms

App size

Revision Plain With Sentry Diff
d751a5d+dirty 2.63 MiB 3.98 MiB 1.34 MiB
9f211e3+dirty 2.63 MiB 3.91 MiB 1.28 MiB
785ffb1+dirty 2.63 MiB 3.81 MiB 1.18 MiB
95aaf8a+dirty 2.63 MiB 3.87 MiB 1.24 MiB
c94a927+dirty 2.63 MiB 3.99 MiB 1.36 MiB
98f632c+dirty 2.63 MiB 3.81 MiB 1.18 MiB
459a438+dirty 2.63 MiB 3.98 MiB 1.35 MiB
46bd012+dirty 2.63 MiB 3.81 MiB 1.18 MiB
93137d1+dirty 2.63 MiB 3.99 MiB 1.35 MiB
3e0a5f9+dirty 2.63 MiB 3.81 MiB 1.18 MiB

Previous results on branch: rz/fix/react-native-legal-compat

Startup times

Revision Plain With Sentry Diff
c5a3d21+dirty 1222.29 ms 1215.84 ms -6.45 ms

App size

Revision Plain With Sentry Diff
c5a3d21+dirty 2.63 MiB 3.99 MiB 1.36 MiB

Copy link
Contributor

@alwx alwx left a comment

Choose a reason for hiding this comment

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

Have just checked it — it works and solves the issue. Thanks a lot!

plugins.withId('com.android.application') {
def ac = extensions.getByName("androidComponents")

ac.onVariants(androidComponents.selector().all()) { v ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: v is the release?

Copy link
Member Author

Choose a reason for hiding this comment

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

v is variant, but since we have one down there already, I just named it v

@lucas-zimerman
Copy link
Collaborator

Thank you for the PR! is it ready for review?

@romtsn
Copy link
Member Author

romtsn commented Oct 9, 2025

@lucas-zimerman not yet, I will mark it as ready soonish, still sorting out some stuff

@romtsn romtsn force-pushed the rz/fix/react-native-legal-compat branch from 14b894b to 6decb5a Compare October 10, 2025 11:30
@romtsn romtsn marked this pull request as ready for review October 10, 2025 11:32
@romtsn romtsn requested a review from antonis as a code owner October 10, 2025 11:32
@romtsn
Copy link
Member Author

romtsn commented Oct 10, 2025

@lucas-zimerman this is ready for review now.

Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@antonis antonis enabled auto-merge (squash) October 13, 2025 13:16
@antonis antonis merged commit 161947d into main Oct 13, 2025
64 of 65 checks passed
@antonis antonis deleted the rz/fix/react-native-legal-compat branch October 13, 2025 13:19
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.

Conflict with react-native-legal on Android

4 participants