cashapp / redwood

Multiplatform reactive UI for Android, iOS, and web using Kotlin and Jetpack Compose
https://cashapp.github.io/redwood/0.x/docs/
Apache License 2.0
1.63k stars 70 forks source link

Kotlin compiler plugin to optimize composables similar to R8 #1614

Open JakeWharton opened 11 months ago

JakeWharton commented 11 months ago

Things to do:

These functions are the source of a lot of bloat in the JS file and they are not needed in production. For native Redwood compilations to non-Android platforms, these calls add overhead that isn't needed.

JakeWharton commented 11 months ago

Filed https://issuetracker.google.com/issues/306428078 upstream since there seems to be some support for this being a first-party toggle of the Compose compiler itself.

JakeWharton commented 11 months ago

Realizing that even with toggles this won't fully eliminate these calls since we don't control the flag value in libraries (such as the Compose runtime itself, where they're enabled). So still need to build a solution that also applies somehow to libraries, not just the code in the compilation unit.

JakeWharton commented 7 months ago

We can do this during linking with a regular compiler plugin because linking sees all the IR, not just the compilation unit of the current module.

https://kotlinlang.slack.com/archives/C7L3JB43G/p1698130170671859?thread_ts=1698116255.957259&cid=C7L3JB43G

colinrtwhite commented 6 months ago

Might be worth stripping all calls functions in Preconditions.kt since the nullability for our code is already enforced at compile time and those functions are called very frequently. This is already possible via compiler flag for the JVM and will eventually be supported for JS.