Skip to content

perf(r8): keep exception names without keeping every exception - #1373

Merged
bmc08gt merged 1 commit into
code/cashfrom
perf/r8-keepnames-throwable
Aug 30, 2026
Merged

perf(r8): keep exception names without keeping every exception#1373
bmc08gt merged 1 commit into
code/cashfrom
perf/r8-keepnames-throwable

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

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.Throwable kept 972 classes whole. Only their names are load-bearing.

Why the names have to stay

The Coinbase onramp traces send it::class.simpleName as errorType (CoinbaseOnRampController.kt:326,385,451), and Events.kt:90,103 does 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 every errorType in 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. -keepnames is the rule that states exactly that.

Measured, release build

-keep -keepnames
DEX (uncompressed) 16,101,032 16,028,404
classes 21,361 21,020
members 1,330,404 1,329,949

72,628 bytes, 341 classes.

The dropped set is what the old rule was propping up — 316 of 357 have Error or Exception in the name, led by com.flipcash.services.models (94) and com.getcode.opencode.model (41). AddReactionError and its six subclasses are representative: ChatMessagingService.addReaction has 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.

CoinbaseOnRampApiError and GetJwtError subclass names are unchanged in the new mapping.

Two comment corrections

Both rules were described as doing something other than 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 every screen-root resource-id the UI tests address. The rule stays; the comment now says why.

The com.kik.scan wildcard is genuinely load-bearing. The scanner's JNI constructs those classes by name from C++ (FindClass("com/kik/scan/UsernameKikCode"), GetMethodID for <init>) and reads their backing fields through GetFieldID (_username, nativePtr) — none of which AGP's default -keepclasseswithmembernames class * { native <methods>; } covers. Five classes, so the wildcard costs little.

-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.
@bmc08gt bmc08gt self-assigned this Aug 30, 2026
@bmc08gt
bmc08gt merged commit efbe3e7 into code/cash Aug 30, 2026
3 checks passed
bmc08gt added a commit that referenced this pull request Aug 31, 2026
…obuf-keep-rules

* origin/code/cash:
  perf(r8): keep exception names without keeping every exception (#1373)
  fix(bugsnag): give the app and the uploaded mapping the same build UUID (#1374)
  chore(r8): drop R8 options that no longer do anything (#1371)
@bmc08gt
bmc08gt deleted the perf/r8-keepnames-throwable branch August 31, 2026 13:59
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.

1 participant