perf(r8): keep exception names without keeping every exception - #1373
Merged
Conversation
-keep public class * extends java.lang.Throwable kept 972 classes whole. Only their names are load-bearing: the Coinbase onramp traces send `it::class.simpleName` as `errorType`, and Events.kt does the same for analytics. Those have become plain strings by the time they leave the device, so the Bugsnag mapping upload cannot repair them, which is why the rule cannot simply be deleted. Nothing reads the members, and an exception nothing constructs need not survive, so -keepnames is the rule that matches the requirement. Release R8 drops 341 classes and 455 members, and DEX falls 72,628 bytes (16,101,032 -> 16,028,404). The dropped classes are what the old rule was propping up: AddReactionError and its six subclasses go, because ChatMessagingService.addReaction has no caller outside tests and R8 had already shrunk it in both builds. CoinbaseOnRampApiError and GetJwtError subclass names are unchanged in the mapping. Also corrects two comments against what the code does. The AppRoute rule is not for analytics: annotatedEntry derives each screen's root test tag from the route's simple name via NavMetadata.screenRootTag, so obfuscating those renames the resource-ids the UI tests address. The com.kik.scan wildcard is load-bearing for JNI, which constructs those classes by name from C++ and reads their backing fields through GetFieldID.
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.
Replaces #1372, which GitHub auto-closed when #1371 merged and its base branch was deleted. Same change, rebased onto
code/cash.-keep public class * extends java.lang.Throwablekept 972 classes whole. Only their names are load-bearing.Why the names have to stay
The Coinbase onramp traces send
it::class.simpleNameaserrorType(CoinbaseOnRampController.kt:326,385,451), andEvents.kt:90,103does the same for analytics. By the time those leave the device they are plain strings, so the Bugsnag mapping upload cannot repair them. Deleting the rule outright would turn everyerrorTypein telemetry into a one-character name.Why the members and the classes themselves need not
Nothing reads the members, and an exception nothing constructs need not survive.
-keepnamesis the rule that states exactly that.Measured, release build
-keep-keepnames72,628 bytes, 341 classes.
The dropped set is what the old rule was propping up — 316 of 357 have
ErrororExceptionin the name, led bycom.flipcash.services.models(94) andcom.getcode.opencode.model(41).AddReactionErrorand its six subclasses are representative:ChatMessagingService.addReactionhas no caller outside tests, and R8 had already shrunk the method in both builds, so the rule was holding the error classes alive on their own.CoinbaseOnRampApiErrorandGetJwtErrorsubclass names are unchanged in the new mapping.Two comment corrections
Both rules were described as doing something other than what the code does.
The
AppRouterule is not for analytics.annotatedEntryderives each screen's root test tag from the route's simple name viaNavMetadata.screenRootTag, so obfuscating those renames every screen-root resource-id the UI tests address. The rule stays; the comment now says why.The
com.kik.scanwildcard is genuinely load-bearing. The scanner's JNI constructs those classes by name from C++ (FindClass("com/kik/scan/UsernameKikCode"),GetMethodIDfor<init>) and reads their backing fields throughGetFieldID(_username,nativePtr) — none of which AGP's default-keepclasseswithmembernames class * { native <methods>; }covers. Five classes, so the wildcard costs little.