avoiding-subcomposition-pitfalls

Detect and mitigate subcomposition pitfalls in Compose UI applications.

8|Updated May 18, 2025
One-click install
npx skills add https://github.com/decoutkhanqindev/DexReader --skill avoiding-subcomposition-pitfalls-decoutkhanqindev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: avoiding-subcomposition-pitfalls
Source: https://github.com/decoutkhanqindev/DexReader/tree/main/.claude/skills/avoiding-subcomposition-pitfalls
Command: npx skills add https://github.com/decoutkhanqindev/DexReader --skill avoiding-subcomposition-pitfalls-decoutkhanqindev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps developers optimize performance in Compose applications by identifying and resolving unnecessary subcompositions that can lead to performance issues like extra measure passes and slow rendering.

Core Features & Use Cases

  • Identifies Subcomposition Issues: Detects misuse of SubcomposeLayout, BoxWithConstraints, and Scaffold.
  • Replacement Strategies: Provides guidance on replacing SubcomposeLayout with cheaper alternatives when appropriate.
  • Performance Tips: Offers advice on maintaining efficient usage of SubcomposeLayout and BoxWithConstraints.
  • Use Case: If a developer is experiencing slow first frames or layout jank due to improper use of BoxWithConstraints within a LazyColumn, this Skill provides solutions.

Quick Start

Apply the 'avoiding-subcomposition-pitfalls' skill to analyze Compose tree and improve performance.

Frequently Asked Questions about avoiding-subcomposition-pitfalls

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

FAQPage Schema
Why does BoxWithConstraints cause layout jank in my Compose UI application?

BoxWithConstraints causes layout jank because it triggers an extra measure pass through subcomposition to pass constraints down. This overhead leads to slow rendering, especially noticeable when used improperly inside scrolling containers like a LazyColumn.

How do I optimize Compose performance by replacing SubcomposeLayout?

To optimize Compose performance, replace SubcomposeLayout with cheaper layout alternatives when appropriate. This avoids unnecessary subcompositions, eliminates extra measure passes, and significantly improves rendering speed during the UI layout phase.

What is subcomposition in Compose UI and when does it create performance pitfalls?

Subcomposition in Compose UI is a secondary composition pass used by APIs like SubcomposeLayout and Scaffold to dynamically build layouts based on constraints. It creates performance pitfalls when misused, causing slow first frames and rendering jank due to extra measure passes.

Do I need to understand Compose measure passes to fix slow rendering issues?

Yes, understanding Compose composition and layout phases is required. Knowledge of how measure passes and subcompositions work is essential to correctly identify subcomposition pitfalls and apply effective performance optimization strategies in your UI application.

When should I not use SubcomposeLayout or BoxWithConstraints for layout?

You should not use SubcomposeLayout or BoxWithConstraints when cheaper alternatives can achieve the same layout result. Avoid them in performance-critical areas like LazyColumn to prevent extra measure passes and avoid slow first frames caused by subcomposition overhead.