android-compose-realtime

Reduce Jetpack Compose recomposition from high-frequency StateFlow telemetry reads.

8|1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/drewid74/ai_skills --skill android-compose-realtime
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: android-compose-realtime
Source: https://github.com/drewid74/ai_skills/tree/main/android-compose-realtime
Command: npx skills add https://github.com/drewid74/ai_skills --skill android-compose-realtime

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Jetpack Compose can trigger expensive recompositions when high-frequency data streams are read directly inside composables, causing UI jank and unstable rendering at sensor/telemetry rates.

Core Features & Use Cases

  • Granular State Management: Avoid collecting whole telemetry frames in a single composable by splitting StateFlow into per-metric StateFlows and applying distinctUntilChanged() to prevent unnecessary recomposition.
  • Derived UI Values: Use derivedStateOf to recompute and re-render only when the derived result changes, not on every upstream update.
  • Stable Data Patterns: Apply @Immutable and @Stable to data classes and state containers to reduce conservative recomposition behavior.
  • Canvas-Based Gauges & Graphs: Render gauges and live line graphs using Canvas so drawing work stays in the draw phase with minimal composition churn.
  • Lifecycle-Safe Flow Collection: Prefer collectAsStateWithLifecycle for StateFlow-to-Compose wiring, preventing leaks and unwanted updates.

Quick Start

Optimize a Compose real-time dashboard that updates at 25Hz or faster by splitting the telemetry stream into per-metric StateFlows, filtering with distinctUntilChanged(), and rendering gauges/graphs with Canvas and derived state.

Frequently Asked Questions about android-compose-realtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Jetpack Compose UI jank when rendering high-frequency telemetry data?▼

Jetpack Compose UI jank occurs when high-frequency telemetry streams trigger expensive recompositions by reading state directly inside composables. Splitting StateFlow into per-metric streams and applying distinctUntilChanged prevents unnecessary recomposition at sensor update rates.

How do I optimize a Compose dashboard updating at 25Hz or faster?▼

Optimize a 25Hz Compose dashboard by splitting telemetry StateFlows per metric, filtering with distinctUntilChanged, and rendering gauges with Canvas. Use derivedStateOf for computed values and collectAsStateWithLifecycle for lifecycle-safe flow collection.

When should I use derivedStateOf in a real-time Compose UI?▼

Use derivedStateOf in a real-time Compose UI to recompute and re-render only when the derived result changes, not on every upstream StateFlow update. This prevents excessive recomposition when handling high-frequency telemetry data streams.

Does collectAsStateWithLifecycle prevent state leaks in Compose telemetry dashboards?▼

collectAsStateWithLifecycle prevents leaks and unwanted updates in Compose telemetry dashboards by safely wiring StateFlow collection to the lifecycle. It stops high-frequency state emissions from triggering recomposition when the composable is not in an active lifecycle state.

What is the best way to render live sliding-window graphs in Jetpack Compose?▼

The best way to render live sliding-window graphs in Jetpack Compose is using Canvas so drawing work stays in the draw phase with minimal composition churn. Pair Canvas with @Immutable data classes and derivedStateOf to maintain stable rendering at 25Hz+.

Can I use @Immutable and @Stable annotations to reduce Compose recomposition?▼

Apply @Immutable and @Stable annotations to data classes and state containers to reduce conservative recomposition behavior in Compose. These stable data patterns help the compiler skip unnecessary recompositions when handling high-frequency telemetry updates.