<br />

Initializing an app with long waterfall mediation chains and multiple third
party adapters can increase ad request latency for critical impressions that
show first in the user's session. This increased first impression latency can
prevent the ad from showing as the ad request has not yet returned a response.

This guide covers the following to reduce first impression latency in your app
sessions:

- [Set an initialization timeout](https://developers.google.com/admob/android/reduce-first-impression-latency.md.txt#set_an_initialization_timeout)
- [Remove waterfall ad sources from your first request](https://developers.google.com/admob/android/reduce-first-impression-latency.md.txt#remove_waterfall_ad_sources_on_your_first_request)
- [Improve performance on less time-sensitive impressions](https://developers.google.com/admob/android/reduce-first-impression-latency.md.txt#improve_performance_on_less_time-sensitive_impressions)

## Before you begin

Before you continue, [set up Google Mobile Ads SDK (Legacy)](https://developers.google.com/admob/android/quick-start.md.txt).

## Set an initialization timeout

To avoid missing an impression opportunity, set an initialization timeout. This
approach prevents your app from exceeding the time limit you defined. You can
proceed with the ad request after the time limit you set, or after
initialization completes.

The following example sets an initialization timeout of five seconds:

### Kotlin

```kotlin

// Set up a CONFLATED channel that only buffers the latest event.
private val adLoadChannel = Channel<Unit>(Channel.CONFLATED)

fun initialize(context: Context) {
  // Coroutine to handle the 5-second timeout.
  CoroutineScope(Dispatchers.Default).launch {
    delay(5000L)

    // 5 second timer elapsed
    adLoadChannel.trySend(Unit)
  }

  // Coroutine to call MobileAds.initialize() on a background thread.
  CoroutineScope(Dispatchers.IO).launch {
    MobileAds.initialize(context) {
      // Mobile Ads SDK initialization finished.
      adLoadChannel.trySend(Unit)
    }
  }

  // Coroutine to listen for init complete or timer, whichever comes first.
  CoroutineScope(Dispatchers.Main).launch {
    // Wait on the first event.
    adLoadChannel.receive()
    loadAd()
    // Close the channel after receiving the first event.
    adLoadChannel.close()
  }
}

```

<br />

## Remove waterfall ad sources on your first request

> [!IMPORTANT]
> **Key Point:** This feature is limited to [AdMob Mediation
> Pro](https://support.google.com/admob/answer/16616136) partners.

To deliver ads without any additional latency from waterfall ad sources,
[implement key-value segmentation](https://developers.google.com/admob/android/mediation/segmentation.md.txt) to
remove waterfall ad sources on your first ad request. Complete the following
steps:

1. [Create a mediation group](https://support.google.com/admob/answer/13412127) and add bidding ad sources.
2. [Add key-value segmentation](https://support.google.com/admob/answer/14916631) to your new bidding-only mediation group using key `latency` and value `low`.
3. Prioritize your new bidding-only mediation group above your primary mediation group in the UI. To adjust the order, [change mediation group
   priority](https://support.google.com/admob/answer/7374967#priority).
4. In your first ad request, include the custom targeting key-value pair:

   ### Kotlin

   ```kotlin
   val request = AdRequest.Builder()
       .addCustomTargeting("latency", "low")
       .build()
   ```

   ### Java

   ```java
   AdRequest request = new AdRequest.Builder()
       .addCustomTargeting("latency", "low")
       .build();
   ```

   <br />

5. [Test the key-value segmentation setup](https://developers.google.com/admob/android/mediation/segmentation.md.txt#test_the_key-value_segmentation_setup)
   to verify you are correctly targeting the new bidding-only mediation group.

## Improve performance on less time-sensitive impressions

To improve performance on less time-sensitive impressions, such as ads that
don't need to show right at app launch, use [ad preloading](https://developers.google.com/admob/android/ad-preloading.md.txt) with an ad request that does not target the bidding-only
mediation group.