build: Add animalsniffer to check that source is compatible with Android API#4705
build: Add animalsniffer to check that source is compatible with Android API#4705alexander-alderman-webb merged 6 commits intomainfrom
Conversation
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c8125f3 | 383.82 ms | 441.66 ms | 57.84 ms |
| 85d7417 | 347.21 ms | 394.35 ms | 47.15 ms |
| ce0a49e | 532.00 ms | 609.96 ms | 77.96 ms |
| 1df7eb6 | 397.04 ms | 429.64 ms | 32.60 ms |
| 7314dbe | 437.83 ms | 505.64 ms | 67.81 ms |
| ee747ae | 554.98 ms | 611.50 ms | 56.52 ms |
| b750b96 | 421.25 ms | 444.09 ms | 22.84 ms |
| ee747ae | 382.73 ms | 435.41 ms | 52.68 ms |
| ee747ae | 358.21 ms | 389.41 ms | 31.20 ms |
| 674d437 | 355.28 ms | 504.18 ms | 148.90 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c8125f3 | 1.58 MiB | 2.10 MiB | 532.32 KiB |
| 85d7417 | 1.58 MiB | 2.10 MiB | 533.44 KiB |
| ce0a49e | 1.58 MiB | 2.10 MiB | 532.94 KiB |
| 1df7eb6 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| 7314dbe | 1.58 MiB | 2.10 MiB | 533.45 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| b750b96 | 1.58 MiB | 2.10 MiB | 533.20 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| 674d437 | 1.58 MiB | 2.10 MiB | 530.94 KiB |
Previous results on branch: webb/animalsniffer
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 25d5617 | 387.37 ms | 451.94 ms | 64.57 ms |
| 6284e75 | 339.72 ms | 384.49 ms | 44.77 ms |
| 9a790dc | 361.04 ms | 422.85 ms | 61.81 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 25d5617 | 1.58 MiB | 2.10 MiB | 533.20 KiB |
| 6284e75 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| 9a790dc | 1.58 MiB | 2.10 MiB | 533.20 KiB |
lcian
left a comment
There was a problem hiding this comment.
Nice! 🎉
I imagine this also runs in CI during the build, right?
I'll defer to the Android team for approval as I don't know enough about this topic.
sentry/build.gradle.kts
Outdated
| testImplementation(projects.sentryTestSupport) | ||
|
|
||
| val gummyBearsModule = libs.gummy.bears.api21.get().module | ||
| signature("${gummyBearsModule}:${libs.versions.gummyBears.get()}:coreLib2@signature") |
There was a problem hiding this comment.
unfortunately, we cannot guarantee that core-library desugaring is enabled by our customers, so we have to be conservative here and test against the plain Android APIs assuming there's no desugaring and our SDK should still work.
There was a problem hiding this comment.
what are the failures you're experiencing? If it fails, we should actually fix those
There was a problem hiding this comment.
Only one task fails when I use the list of modules you gave below. Do these need to be fixed?
> Task :sentry:animalsnifferMain FAILED
[Undefined reference] io.sentry.(SentryInstantDate.java:1) #date
>> java.time.Instant
[Undefined reference] io.sentry.(SentryInstantDate.java:16)
>> java.time.Instant java.time.Instant.now()
[Undefined reference] io.sentry.(SentryInstantDate.java:26)
>> long java.time.Instant.getEpochSecond()
[Undefined reference] io.sentry.(SentryInstantDate.java:26)
>> int java.time.Instant.getNano()
[Undefined reference] io.sentry.(SentryWrapper.java:54)
>> java.util.function.Supplier
[Undefined reference] io.sentry.(SentryWrapper.java:56)
>> Object java.util.function.Supplier.get()
There was a problem hiding this comment.
is there a way to suppress these? For Instant we actually have a check on Android if it's available (API 26+) and then use it, for SentryWrapper - it's not used unless the customers use it, which won't be the case for Android (Virtual Threads is not available I believe).
There was a problem hiding this comment.
Thanks for the context!
I added config to ignore all java.time.Instant warnings and exclude SentryWrapper.java from the check.
romtsn
left a comment
There was a problem hiding this comment.
LGTM, very impactful change, thanks!
📜 Description
#skip-changelog
Add
animalsnifferto check the source files in themaindirectories of plain Java repositories. The signature incoreLib2allows classes and methods in the Android API and JDK APIs available through desugaring. Using a less permissive signature that does not allow desugaring causes failures, so I opted forcoreLib2for now.Closes #4679
Closes JAVA-156
💡 Motivation and Context
Prevent issues like #4651 reaching users.
The
animalsnifferMaintask would have failed the responsible PR: #4604.💚 How did you test it?
Run
./gradlew animalsnifferMain.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps