sentry-android-gradle-plugin
sentry-android-gradle-plugin copied to clipboard
Re-running the same build gives two different io.sentry.ProguardUuids
Platform:
- [x] Android -> compile 31, min 23, target 28
Build system:
- [x] Gradle -> 7.4
Android Gradle Plugin:
- [x] Yes -> 7.1.1
- [ ] No
Sentry Android Gradle Plugin:
- [x] Yes -> 2.1.5
- [ ] No
Proguard/R8:
- [x] Enabled
- [ ] Disabled
Platform installed with:
- [ ] Maven Central
- [x] Manually
The version of the SDK: 5.6.1
Steps to reproduce:
Run a release build with r8 and check the assets/sentry-debug-meta.properties
file in the APK.
Re-run the build without making any changes.
Actual result:
io.sentry.ProguardUuids
inside of sentry-debug-meta.properties
changes even though the build is otherwise identical. This lack of idempotent builds is causing issues for internal infrastructure checks we have when re-running CI builds. R8 was definitely up to date and did not re-run in between builds.
Expected result: If the inputs to sentry don't change, don't generate a new uuid.
thanks @gpeal for the report (I just transferred the issue under sentry-gradle-plugin repo as I think it's a better place for it).
Indeed, it looks like the task is always run https://github.com/getsentry/sentry-android-gradle-plugin/blob/d8f1ab314ae113fef8c6404c9de39dd72d85c839/plugin-build/src/main/kotlin/io/sentry/android/gradle/tasks/SentryGenerateProguardUuidTask.kt#L13-L19
@cortinico @marandaneto what's the reason for that actually? No inputs? Could we depend on the r8 task perhaps, or is it gonna be too late already?
what's the reason for that actually? No inputs? Could we depend on the r8 task perhaps, or is it gonna be too late already?
IIRC it was a requirement to always create a new UUID. I remember bringing this point up, mostly for perf issues and there was potentially a concern of avoiding false negatives.
io.sentry.ProguardUuids
inside ofsentry-debug-meta.properties
changes even though the build is otherwise identical. This lack of idempotent builds is causing issues for internal infrastructure checks we have when re-running CI builds. R8 was definitely up to date and did not re-run in between builds.
I think we can fix this by either:
- updating this to be a
SourceTask
and set assource
the wholesrc
folder. - check what's the
input
for the R8 task inside AGP source code, and set the same for this task.
check what's the input for the R8 task inside AGP source code, and set the same for this task.
Or can we depend on the outputs of R8 task?
Or can we depend on the outputs of R8 task?
Yes but I'd like this task to be minifier-agnostic (i.e. I don't want to assume that R8 is actually running).
sentry-cli
itself hashes the file before doing something, so in the server-side point of view, is fine.
Indeed, the plugin could not redo the whole thing if nothing has really changed, and @cortinico is right, there were cases of false-negatives, I don't recall if it was a specific range of AGP or Gradle itself.
If we can optimize that, it'd be great, but let's be sure that it works correctly this time from AGP 7+ on.
So looks like #313 is actually a prerequisite for this one (or rather, implementing #313 would actually fix this issue, so I guess I'd proceed with #313 and then test this one out)
I'd not say that #313 would fix that alone, because even using the Manifest, you can still generate a new uuid
every time, so both have to be done, together.
Most likely it would, because we'd use AGP apis to transform the manifest, and they know when to trigger the manifest merging. See recipe here -> https://github.com/android/gradle-recipes/blob/c23620879ef024529605d2b2f7ab27ebadbe55c2/Kotlin/manifestTransformerTest/app/build.gradle.kts#L72-L76
But yeah, it needs to be verified.
This might be fixed with AGP 7.4+ and our 3.4.1
gradle plugin release.
Still happening with sentry 3.4.1
and Gradle 8+
$ ../gradlew --version
Gradle 8.0-rc-2 Build time: 2023-01-17 10:25:18 UTC Revision: 8dcd942c9efaac6cb7f577f3b7a7521d0801704dKotlin: 1.8.0 Groovy: 3.0.13 Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 JVM: 17.0.5 (Azul Systems, Inc. 17.0.5+8-LTS) OS: Mac OS X 13.2 aarch64
$ ../gradlew assembleRelease
Task :app:uploadSentryProguardMappingsRelease INFO 2023-02-17 12:02:04.674713 +01:00 Loaded file referenced by SENTRY_PROPERTIES compressing mappings uploading mappings Uploaded a total of 1 new mapping files Newly uploaded debug symbols: 8ac7c64f-[redacted]
BUILD SUCCESSFUL in 8s 44 actionable tasks: 6 executed, 38 up-to-date $ ../gradlew assembleRelease
Task :app:uploadSentryProguardMappingsRelease INFO 2023-02-17 12:02:14.928693 +01:00 Loaded file referenced by SENTRY_PROPERTIES compressing mappings uploading mappings Uploaded a total of 1 new mapping files Newly uploaded debug symbols: f3eb596d-[redacted]
BUILD SUCCESSFUL in 9s 44 actionable tasks: 6 executed, 38 up-to-date
Seems like this one is a culprit: https://github.com/getsentry/sentry-android-gradle-plugin/blob/1afd54f0d053369d996aaee23ebe60e5b70b6988/plugin-build/src/main/kotlin/io/sentry/android/gradle/tasks/SentryGenerateProguardUuidTask.kt#L16