android-compose-performance
1
总安装量
1
周安装量
#44579
全站排名
安装命令
npx skills add https://github.com/hexoplon/skills --skill android-compose-performance
Agent 安装分布
amp
1
opencode
1
kimi-cli
1
codex
1
github-copilot
1
gemini-cli
1
Skill 文档
Android Compose & Kotlin Performance
Workflow
-
Identify the problem area:
- Compose UI jank / recomposition â See references/compose.md
- Coroutine communication / threading â See references/coroutines.md
-
Apply targeted fixes using the patterns in the relevant reference file.
-
Verify in release mode â debug builds disable Compose compiler optimizations and skippability, making profiling unreliable.
Quick Reference: Most Common Mistakes
Compose
- Reading state in parent when only child needs it â pass
() -> Tlambdas instead - Using
List/Map/Setparams (unstable) â usekotlinx.collections.immutableor@Immutable - Missing
keyinLazyColumn/LazyRowitems - Using
Modifier.offset(x, y)instead ofModifier.offset { IntOffset(x, y) }for animated values - Sorting/filtering inside composables instead of ViewModel
- Profiling in debug builds
Coroutines
- Using
GlobalScopeinstead ofviewModelScope/lifecycleScope - Using
synchronized/ReentrantLockinstead ofMutex.withLockin coroutine code - Collecting
StateFlowwithoutrepeatOnLifecycleorcollectAsStateWithLifecycle() - Using
ChannelwhenSharedFlowis appropriate (one-to-many) or vice versa - Running IO work on
Dispatchers.DefaultorDispatchers.Main
Recommended Architecture
- ViewModel:
MutableStateFlowfor UI state, exposed asStateFlow. Logic inviewModelScope. - Repository/data layer:
withContext(Dispatchers.IO)for disk/network. ExposeFlow. - Compose UI: Collect via
collectAsStateWithLifecycle(). Defer reads via lambdas. Use stable types. Provide keys to lazy layouts. - Cross-coroutine:
Channelfor one-to-one delivery,SharedFlowfor one-to-many broadcast. - Synchronization:
Mutex.withLockoversynchronizedin coroutine code.