Skip to main content

Detecting a dependency performance issue

In this tutorial, we’ll guide you through identifying a slow component within your app that may be slowing down the overall performance using the Kotzilla Platform.

info

Issue context

A dependency performance issue occurs when a component takes too long to resolve due to its complexity and the number of dependencies it retrieves. This can lead to performance bottlenecks, affecting app responsiveness and slowing down critical operations.

Why it matters?

  • Cascading impact: When a dependency has too many sub-dependencies or takes longer than 5 ms per call, it can delay multiple components relying on it.
  • Complex dependency graph: If too many dependencies are involved, the resolution process can slow down the main thread or background operations
  • Difficult to debug: These issues are not always caused by a single slow dependency but rather by the overall complexity of the dependency graph, making them harder to detect without proper analysis tools.

Suggested user resolution actions

  • Monitor dependency resolution time: Use the Kotzilla Platform to identify any component resolution times exceeding 5 ms per call and analyze their complexity.
  • Reduce complexity: Detect components with too many dependencies and consider refactoring them into smaller, more focused services.
  • Optimize dependency scope: Use Koin’s single vs. factory scopes effectively to avoid unnecessary re-creation of instances.
  • Apply best practices: Follow MVVM or Clean Architecture to structure dependencies efficiently, decouple large components into modular and reusable services, and cache expensive computations to avoid repeated slow resolutions.
  • Break down large dependency chains: If a component relies on too many dependencies, consider splitting them into smaller, more manageable parts.

Prerequisites

In this tutorial, we will be using the NowInAndroid app as an example. Before you begin, ensure you've completed the first two steps of the Get started with Kotzilla Platform

Step 1 - Simulate a slow dependency resolution

We will simulate a delay in the constructor of the OfflineFirstUserDataRepository, which is a key dependency within the app. This delay will help us observe the impact of slow resolutions on the app’s performance.

Here’s the code to introduce a 1-second delay in the OfflineFirstUserDataRepository:

internal class OfflineFirstUserDataRepository(
private val niaPreferencesDataSource: NiaPreferencesDataSource,
private val analyticsHelper: AnalyticsHelper,
) : UserDataRepository {

// Simulate a slow dependency resolution with a 1-second delay
init {
Thread.sleep(1000)
}

Step 2 - Create user sessions to capture execution data

Once the delay is introduced in the component, create user sessions to capture data about how the slow initialization impacts the app. Repeat this process three times to gather consistent performance data.

Run the Now In Android app as described in this guide to simulate a repeatable sequence of interactions. Repeat this three times to create consistent data on Kotzilla Platform.

Step 3- Investigate root cause of issues

With the simulated delay in place, we will use the Koin IDE Plugin to visualise dependency resolution issues detected by the platform and affecting the performance. Open the Issues Panel in the Koin IDE Plugin and navigate to the Application Issues section.

You should see different issues including

  • Slow dependency performance impacting MainActivityViewModel
  • MainActivityViewModel resolution blocking the main Thread

3.2 Investigating the root cause of issues

To investigate the details of this issue double-click on the MainActivityViewModel has Slow Resolution Performance issue in the Koin IDE Plugin. This will redirect you to the Issue Details view in the Kotzilla Console.

Here, you will see:

  • A list of 3 impacted user sessions.
  • A detailed description of the issue, including that the MainActivityViewModel resolution is slow regarding the number of dependencies to retrive and causing a cascading slowdown of the app.

3.3 User session analysis to trace the slow resolution performance

Click on the first impacted user session to drill down into the specific events and components related to the issue. This will take you directly to the Timeline View, where you will observe:

  • The MainActivityViewModel is blocking the main thread for over 1s.
  • The 1-second delay can be seen during the screen lifecycle transitions, especially between the started and resumed states, causing the main thread to be blocked.

Click on the MainActivityViewModel in the event sequence. The tree graph view will display all child nodes involved in the resolution. Most of the time is spent within the UserDataRepository.

While we don’t see the OfflineFirstUserDataRepository directly in the graph, the delay is being inherited through the UserDataRepository interface.

Step 4- Fix a dependency performance issue

If you’re using an AI coding assistant in your Android development, you can rely on Kotzilla’s contextual prompt generation to help you fix this issue efficiently.

Otherwise, you can follow our recommended manual steps

4.1 Generate a contextual prompt for the issue

You can generate contextual fix prompts either from the Koin IDE Plugin or directly from the Kotzilla Console. In this example, we’ll use the IDE Plugin to create the prompt and execute it with your AI coding assistant:

  • Open the Application Issues tab of the Koin IDE Plugin in your Android Studio
  • Select the issue MainActivityViewModel has Slow Resolution Performance
  • Click on the AI icon on the right to generate and view the prompt

The plugin will generate a ready-to-use prompt with all the necessary context so your AI coding assistant can suggest fixes. Each prompt includes the impacted components, dependency chains, and performance insights.

4.2 Execute the fix with your preferred AI Coding Assistant

You can now copy the generated prompt and execute it using the AI Coding Assistant of your choice in the IDE. In this example, we use GitHub Copilot with the Claude Sonnet 4.5 model:

  • Open your AI assistant panel (i.e, Copilot Chat)
  • Paste the generated prompt
  • Run it with Agent Mode (or equivalent), so the assistant can apply code changes directly with full project context
  • Review and approve the changes suggested by the assistant

Key takeaways

By simulating a 1-second delay in OfflineFirstUserDataRepository, we reproduced a slow dependency resolution and observed how it cascades to MainActivityViewModel, blocking the main thread and slowing down screen transitions. Using the Kotzilla Platform and Koin IDE Plugin, we inspected the affected sessions, visualized the dependency tree, and identified which components were contributing most to the delay.

The issue can be addressed using Kotzilla’s AI-generated contextual prompts or by manually optimizing the dependency graph, splitting heavy dependencies, and offloading slow work to background threads.