Skip to content
All guides

Android threading and performance interview questions

By Mike Salari. Staff mobile engineer · 500+ technical interviews from the hiring side.

This page is for senior Android engineers facing a round on coroutines, threads and performance. You get ten questions with what is scored, a follow-up chain that changes one condition at a time, and the weak answer that loses the round. Two sentences run through all of it: every piece of work has one owner, and cancellation is a request.

Who this is for

  • Senior Android engineers who use coroutines daily and want to explain the concurrency model under them.
  • Engineers who have fixed a slow screen and need to describe the investigation as well as the fix.
  • Leads who own startup, memory or ANR numbers for a team.

The questions

Naming flatMapLatest or viewModelScope tells me you know the vocabulary. It does not tell me whether the old result can still win. The same goes for performance: "used Perfetto and improved performance" gives me almost nothing to carry into a hiring discussion. Tell me what the user could not do and which explanation you ruled out.

1. "A coroutine in viewModelScope is still running after the ViewModel is cleared. Why?"

What is scored: cancellation as cooperation.

A strong answer covers:

  • viewModelScope did cancel it. Cancellation only takes effect when the code suspends or checks for it. (Kotlin docs: cancellation)
  • Three causes, in this order: blocking code that never suspends (a CPU loop, Thread.sleep, blocking I/O); a catch (e: Exception) that swallows CancellationException; and work that escaped to another scope, such as GlobalScope or an application scope.
  • Fixes: ensureActive() in loops, runInterruptible around blocking calls you cannot change, rethrow cancellation.
Kotlin
viewModelScope.launch {
    val result = withContext(defaultDispatcher) {
        rows.map { row ->
            ensureActive()
            heavyTransform(row)
        }
    }
    repo.save(result)
}

Follow-ups:

  • The loop calls a blocking library you cannot change. What now?
  • One transform already wrote to the database before cancellation. Is that undone?

Weak answer: "That cannot happen unless you used GlobalScope." Half of one cause out of three.

2. "A teammate launches two network calls into shared variables, then checks both for null. What is wrong?"

What is scored: structured concurrency.

A strong answer covers:

  • Results travel through shared mutable variables, completion is coordinated by hope, and a failure in one call says nothing to the other.
  • Rewrite with coroutineScope and async: values come back as return values, the scope waits for both, and if one fails the other is cancelled and the error reaches the caller. (Kotlin docs: exception handling)
  • When partial results are valid, supervisorScope keeps siblings running, and each branch handles its own failure.
  • Choose by product meaning: checkout needs cart and payment methods together; a dashboard of independent panels can degrade.
Kotlin
suspend fun loadProfile(api: Api): Profile = coroutineScope {
    val user = async { api.user() }
    val orders = async { api.orders() }
    Profile(user.await(), orders.await())
}

Follow-ups:

  • The "optional" call turns out to check authorisation. Should it still be supervised?
  • Where does a CoroutineExceptionHandler help here, and where does it do nothing?

Weak answer: "Use supervisorScope everywhere to be safe." It lets siblings continue after a prerequisite failed.

3. "The user types 'camera', then 'camera bag'. The first request returns last and shows cameras. Fix it."

What is scored: separating stopping work from refusing a stale result.

A strong answer covers:

  • Two jobs: cancel work nobody wants, and make sure an old result can never be published.
  • mapLatest cancels the transform for the previous value when a new one arrives. (kotlinx.coroutines: mapLatest) It is marked experimental, so say so.
  • Cancellation alone proves little. A callback adapter or cache can still deliver late. Give each query an identity and only publish results for the current one.
  • Test the bad interleaving: A checks it is current, B becomes current, A writes.
Kotlin
val results: Flow<List<Item>> = queries
    .debounce(300)
    .mapLatest { query -> repository.search(query) }

Follow-ups:

  • The search SDK ignores cancellation. What stops its late result reaching the screen?
  • The results are written to a database the screen observes. Where does the stale check go now?

Weak answer: "Use the latest operator." Name what it cancels and why no other path can publish old data.

4. "Users see 'Something went wrong' when they leave a screen mid-request. Why?"

What is scored: keeping cancellation out of your error path.

A strong answer covers:

  • A broad catch turns CancellationException into a failure state. Android says to catch specific types like IOException and never consume cancellation. (Android: coroutines best practices)
  • runCatching catches every Throwable, cancellation included, so wrapping a suspend call in it has the same effect.
  • Suspending cleanup after cancellation belongs in withContext(NonCancellable) inside finally, and only there.
  • The product question: cancelling the client does not prove the server rejected the payment.
Kotlin
suspend fun loadProfile(): Result<Profile> =
    try {
        Result.success(api.fetchProfile())
    } catch (e: CancellationException) {
        throw e
    } catch (e: IOException) {
        Result.failure(e)
    }

Follow-ups:

  • The cleanup itself needs a network call. How long do you let it run?
  • The user leaves during a payment submit. What does the next screen show?

Weak answer: catch (e: Exception) { showError() } presented as safe error handling.

5. "Does suspend mean the function runs in the background? Where do IO and Default fit?"

What is scored: who owns main safety.

A strong answer covers:

  • No. suspend allows suspension; a suspend function can still block the thread it runs on.
  • Android's rule: the class doing blocking work moves itself off the main thread with withContext, so callers do not have to know. Inject the dispatcher for tests.
  • Default is for CPU work. IO is for blocking I/O, limited by default to 64 threads or the number of cores, whichever is larger, and it shares threads with Default. (kotlinx.coroutines: Dispatchers.IO)
  • A file import has stages with different needs. "Run the whole feature on IO" is too broad.

Follow-ups:

  • All 64 IO threads are parked in a slow blocking call. What else stalls?
  • How do you test code that calls withContext(ioDispatcher) without real threads?

Weak answer: "suspend runs on a background thread." It runs where it was called until something switches it.

6. "An ANR trace points at a coroutine. The team moved the launch to Dispatchers.IO and it still freezes. Why?"

What is scored: following the wait chain from the trace.

A strong answer covers:

  • Start from the ANR cluster signature in Play Console or Crashlytics. Lock contention is a listed cause, and the lock holder thread can be involved. (Android: diagnose and fix ANRs)
  • The checklist: runBlocking on main; a suspend function doing blocking work on Main; main waiting on a lock held by a background coroutine; the IO pool exhausted.
  • Moving work to a worker does not help if main then waits for it, such as blocking on a future. The wait moved, the dependency stayed.
  • Fix the dependency: keep the critical section short, do slow work outside the lock, or publish an immutable snapshot the UI can read.

Follow-ups:

  • The trace shows main idle in nativePollOnce. When do you ignore that, and when not?
  • You shorten the lock. What correctness test proves the commit still uses valid data?

Weak answer: "Move it to IO." It changes the thread name and leaves the wait in place.

7. "Cold start crept up over two quarters and nobody noticed. Run the investigation."

What is scored: measure, fix, then pin the number.

A strong answer covers:

  • Which clock: TTID is the first frame; TTFD is when the app is usable, and it exists only if you call reportFullyDrawn. (Android: app startup time)
  • Measure a release build on a mid-range device. Debug builds and flagship phones hide the problem.
  • Read a startup trace for the usual lines: SDK setup in Application.onCreate, library auto-init running before your code, a heavy first screen, and a stale profile.
  • Fix in the order the trace ranks them, one change at a time, with a before and after.
  • Pin it: a startup benchmark in CI with a tolerance band, a trend chart, and a field alert.

Follow-ups:

  • Deferring everything made the first tap slow. What did you miss?
  • The app opens from a notification as often as from the launcher. What changes?

Weak answer: "I timed it on my phone." One debug run on a fast device tells you little about users.

8. "How do Baseline Profiles work, and how do you know yours helped?"

What is scored: mechanism and proof.

A strong answer covers:

  • A profile lists critical classes and methods. Play ships it with the APK and ART compiles those paths ahead of time at install, skipping interpretation and JIT for them. (Android: Baseline Profiles)
  • Generated by a test with BaselineProfileRule walking the critical journeys, and regenerated when those journeys change.
  • Startup Profiles are used at build time by R8 to lay out DEX so startup code sits in the primary DEX file.
  • Proof: Macrobenchmark comparing runs with and without the profile, on a release build.

Follow-ups:

  • The navigation rewrite moved the hot paths. What happens to an old profile?
  • The profile is in the APK. Does that prove users start faster?

Weak answer: "It is a Gradle flag for speed." No mechanism, no measurement.

9. "Memory climbs over a session, but the Java heap looks flat. Where do you look?"

What is scored: knowing where memory lives outside the Java heap.

A strong answer covers:

  • Split the bill first with dumpsys meminfo: Java heap, native heap, graphics. A rising native line with a flat Java line redirects the search.
  • Native suspects: bitmap pixels, JNI global references never deleted, native libraries such as decoders or ML runtimes.
  • Tools: native allocation recording in the memory profiler and Perfetto heap profiling, to find the allocation site by stack.
  • For Java leaks, read the retaining chain: the last hop is the field that should have been cleared. callbackFlow without awaitClose is the listener leak in Flow form.
  • Image arithmetic: a 4032 × 3024 bitmap at four bytes per pixel is about 46.5 MiB of pixels, whatever the file size.

Follow-ups:

  • Someone suggests android:largeHeap. What do you say?
  • The crash only happens on low-RAM devices. How do you see kills your crash reporter never records?

Weak answer: "Call System.gc()." It does not free memory something still holds.

10. "You fixed a performance problem. How does the team not regress it?"

What is scored: machinery that outlives the fix.

A strong answer covers:

  • PR gate: Macrobenchmark on stable devices, medians over several runs, thresholds with a tolerance band.
  • Trend tracking on the main branch, because five changes of two percent each pass every single gate.
  • Field signal: Android vitals, where Play may reduce visibility past a bad behaviour threshold. (Android vitals)
  • Percentiles over means, because users live in the tail.
  • A flaky gate is worse than none: teams learn to ignore it.

Follow-ups:

  • The benchmark is noisy on shared emulators. What do you change?
  • A new SDK adds 80 ms to startup. Who decides if that is acceptable?

Weak answer: "QA said it felt faster." Feelings do not survive the next release.

What changed in 2024 to 2026

  • Android 17 adds app memory limits based on total device RAM. If your app is affected, ApplicationExitInfo reports REASON_OTHER with MemoryLimiter:AnonSwap in the description. (Android 17 behavior changes)
  • Compose Runtime 1.13 adds computedStateOf for light derived checks on fast-changing state such as scroll position, next to derivedStateOf. (Compose performance best practices)
  • Android's architecture recommendations, updated 5 October 2026, strongly recommend R8 full mode, Baseline and Startup Profiles, and Macrobenchmark. Performance is part of the architecture conversation now. (Recommendations for Android architecture)
  • Play Console's ANR Insights section can summarize causes such as lock contention and suggest a fix. (Diagnose and fix ANRs)

How the rounds run

Formats vary by company and level. Some loops ask these as discussion, some hand you a trace or a code sample, some fold them into live coding. No official careers page publishes an Android-specific performance round, so none is described here. StaffEng says it is reasonable to ask what each interview evaluates. (StaffEng) Ask that, and ask whether you will read real traces.

For the language features under these answers, see the Kotlin interview guide. For how state flows through layers, see the Android architecture guide.

Sources

These ten questions are a sample. The Senior Signal covers coroutines, performance and memory chapter by chapter, with the follow-ups that decide the round. Interview Runtime Android gives you the practice loop: answer, get the changed constraint, answer again.