synchronizing-with-idle

Resolve asynchronous timing issues in Jetpack Compose UI tests with synchronization primitives.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill synchronizing-with-idle-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: synchronizing-with-idle
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/compose/synchronization/synchronizing-with-idle
Command: npx skills add https://github.com/trancee/MeshLink-template --skill synchronizing-with-idle-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves non-deterministic test failures caused by race conditions between the Compose recomposer and the test thread, preventing common issues like flaky tests and timeout exceptions.

Core Features & Use Cases

  • Synchronization Primitives: Provides a decision matrix for choosing the correct wait API, such as waitForIdle, waitUntil, or runOnIdle.
  • Idle Definition: Clarifies the three conditions required for Compose to be considered idle, including recomposition, draw passes, and IdlingResource status.
  • Use Case: If your UI test fails on CI but passes locally due to timing differences, use this skill to replace improper Thread.sleep calls with the correct Compose-aware synchronization primitives.

Quick Start

Use the synchronizing-with-idle skill to identify the correct wait primitive for a test that is failing with a ComposeTimeoutException.

Frequently Asked Questions about synchronizing-with-idle

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

FAQPage Schema
How do I fix flaky Jetpack Compose UI tests failing on CI but passing locally?

Flaky Compose UI tests are caused by race conditions between the recomposer and the test thread. Replacing improper Thread.sleep calls with Compose-aware synchronization primitives aligns execution timing to achieve deterministic test behavior.

What is the difference between waitForIdle and waitUntil in Compose UI testing?

The difference lies in their synchronization scope. waitForIdle pauses until the Compose snapshot system is completely idle, while waitUntil polls for a specific condition to become true, providing a decision matrix for targeted state observation.

How do I integrate external IdlingResources with Jetpack Compose test synchronization?

You integrate external IdlingResources by verifying their status alongside Compose's internal idle conditions. The framework considers Compose idle only when recomposition, draw passes, and registered IdlingResources are all completely finished.

Why does my Compose UI test throw a ComposeTimeoutException despite using runOnIdle?

A ComposeTimeoutException occurs when wall-clock timeouts are misaligned with the Compose MainTestClock. Using incorrect wait primitives causes the test thread to desynchronize from the recomposer during node existence verification.

Do I need to use synchronization primitives for simple Compose node existence verification?

Yes, you need synchronization primitives for node existence verification to prevent race conditions. Without aligning the test thread with the Compose snapshot system, asynchronous recomposition can cause non-deterministic test failures.