Commit 5b7f32b
URGENT ADFA-3604: Fix R8 shrink/optimize crashes live on stage (#1609)
ADFA-3604: Fix R8 shrink/optimize bugs found in on-device testing
On-device verification of the shrunk release build (requested in review)
surfaced five distinct R8 bugs, each fixed here:
1. R8's optimize pass retargeted a call to CoGo's own isTestMode() to the
unrelated, device-missing dalvik.system.VMRuntime.isTestMode, crashing
every release build on launch. Disabled optimization (-dontoptimize);
shrinking is what actually cuts dex size, optimization was the unsafe
part given the R8/Kotlin 2.3.0 metadata mismatch already on record in
this file (see the existing StopWatch workaround).
2. Protobuf-lite resolves generated message fields by name via reflection;
shrinking removed a "field with no direct bytecode reference"
(SyncMetaModels$SyncMeta.projectModelInfo_), crashing project sync.
3-5. lsp/kotlin's own service registrations (kt-lsp.xml and
AnalysisApiServiceProviders.kt's ::class-literal registrar, which
PicoContainer instantiates reflectively) and Caffeine's runtime cache
implementation selection all hit the same class of bug: a reflective
lookup R8 can't trace from static analysis. Each fix revealed another
instance elsewhere in the same dependency graph, so rather than keep
discovering them one on-device crash at a time, keep the whole
lsp/kotlin runtime dependency graph (org.jetbrains.kotlin, Caffeine,
kotlin-reflect, kotlin-script, coroutines internals, streamex, Trove)
whole.
Verified end to end on a physical device: clean Kotlin analysis session
init, and a live diagnostic ("Expecting member declaration") confirming
the analysis engine correctly parses and resolves code post-shrink.
Net result: release dex settles at ~85 MB (down from the 119.4 MB
baseline), short of the initially-measured 28.8 MB because that number
came from a build that silently corrupted the Kotlin LSP -- this is the
verified-correct number.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent bd022d8 commit 5b7f32b
1 file changed
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
7 | 17 | | |
8 | 18 | | |
9 | 19 | | |
| |||
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
22 | 68 | | |
23 | 69 | | |
24 | 70 | | |
| |||
88 | 134 | | |
89 | 135 | | |
90 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
91 | 145 | | |
92 | 146 | | |
93 | 147 | | |
| |||
0 commit comments