Warning Attempt to present on which is already presenting null
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
This UIKit warning appears when code tries to present a new view controller while the current presenter is already presenting another controller or is not in a valid presentation state. It is common in async flows, repeated button taps, and lifecycle timing mistakes. The fix is usually to serialize presentation attempts and present from the correct top controller.
Core Sections
What the Warning Means in Practice
A typical warning message says the app attempted to present controller B from controller A while A is already presenting something else. UIKit blocks the second presentation to avoid inconsistent view hierarchy state.
Frequent causes:
- triggering
presenttwice before first animation finishes - calling
presentfrom a controller not currently in window hierarchy - presenting during
viewDidLoadbefore appearance lifecycle completes - competing async callbacks that both attempt navigation
Treat this warning as a state management issue, not as a random UIKit bug.
Present From the Top Most Visible Controller
In complex apps with tabs, navigation stacks, and modals, the safest presenter is the top visible controller. Build a helper and centralize modal presentation calls.
Using one helper avoids scattered presenter assumptions across view models and coordinators.
Guard Against Duplicate Presentation Calls
Before presenting, verify no modal is already active and optionally debounce repeated taps.
This pattern prevents duplicated alerts caused by rapid retries or parallel network callbacks.
Coordinate Async Flows and Lifecycle Timing
Presentation triggered from async work should be routed to main thread and checked against current lifecycle state. Presenting during transition phases is fragile.
Checking window attachment prevents presentation from off screen controllers after navigation changes.
Use a Navigation Coordinator for Large Apps
When several modules can trigger modals, coordinator based presentation avoids race conditions. The coordinator owns a serial queue of navigation intents and decides what to show next.
Simple coordinator idea:
- one presentation entry point
- one active modal at a time
- queue or drop duplicate intents by key
This architecture removes modal logic from random callbacks and makes warnings significantly less frequent.
Debugging Checklist
When warning appears in logs:
- Add temporary logging before every
presentcall. - Log current controller, presented controller, and thread.
- Reproduce with UI test that taps rapidly.
- Confirm transitions finish before next presentation.
You can also set symbolic breakpoints on UIViewController presentation methods to capture the second conflicting call site immediately.
Common Pitfalls
- Presenting from controllers that are no longer visible.
- Triggering multiple
presentcalls from concurrent async callbacks. - Showing modals in early lifecycle methods before appearance.
- Ignoring
presentedViewControllerstate checks. - Spreading modal logic across many classes without coordination.
Summary
- The warning indicates overlapping or invalid modal presentation attempts.
- Present from the top visible controller and centralize logic.
- Guard duplicate calls with state checks and debouncing.
- Synchronize async callbacks with main thread and lifecycle checks.
- Use coordinator style navigation for complex modal flows.

