Main Thread Checker iOS Origin: On your device OSI layer 7 · Application Last updated 12 Oct 2026

Main Thread Checker: UI API called on a background thread: -[UIView setNeedsLayout]

UIKit was used from a background thread; UI must only be touched on the main thread.

Exact message you may see Main Thread Checker: UI API called on a background threadUI API called on a background thread
Seen on: iOS

Meaning

Network/database callbacks run off the main queue. Updating labels, images or layout there causes this checker warning and random UI glitches or crashes.

Common causes

  • UI updates inside URLSession completion handlers
  • Updates from background Tasks/OperationQueues
  • Third-party SDK callbacks on background queues

⚡ Quick fix

  1. Wrap UI updates in DispatchQueue.main.async or MainActor
  2. Mark UI-facing classes @MainActor

Detailed fix by platform

Swift

  1. swift
    URLSession.shared.dataTask(with: url) { data, _, _ in
        DispatchQueue.main.async { self.imageView.image = data.flatMap(UIImage.init) }
    }.resume()

How to diagnose

  1. Stack — Which call path?
  2. Queue — Callback queue

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

40001 — ERROR: could not serialize access due to concurrent update (PostgreSQL)40001412 — HTTP 412 Precondition Failed (HTTP)412428 — HTTP 428 Precondition Required (HTTP)428all goroutines are asleep - deadlock — Go: fatal error: all goroutines are asleep - deadlock! (Go)all goroutines are as…AnotherOperationInProgress — Conflict: AnotherOperationInProgress — Another operation is in progress on the resource (Azure)AnotherOperationInPro…CalledFromWrongThreadException — CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views (Android)CalledFromWrongThread…concurrent_requests_limit — API Error: Too many concurrent requests (concurrency limit reached) (API)concurrent_requests_l…ConditionalCheckFailedException — ConditionalCheckFailedException: The conditional request failed (AWS)ConditionalCheckFaile…Main Thre…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.