---
title: runDeferredStartWhenNeeded()
framework: avfoundation
role: symbol
role_heading: Instance Method
path: avfoundation/avcapturesession/rundeferredstartwhenneeded()
---

# runDeferredStartWhenNeeded()

Tells the session to run deferred start when appropriate.

## Declaration

```swift
func runDeferredStartWhenNeeded()
```

## Discussion

Discussion For best perceived startup performance, call this after displaying the first frame, so that deferred start processing doesn’t interfere with other initialization operations. For example, if using a CAMetalLayer to draw camera frames, add a presentHandler (using doc://com.apple.documentation/metal/mtldrawable/addpresentedhandler) to the first drawable and call runDeferredStartWhenNeeded() from there. If one or more outputs need to start to perform a capture operation, and runDeferredStartWhenNeeded() has not run yet, the session runs the deferred start on your app’s behalf. Only call this method once for each configuration commit - after the first call, subsequent calls to runDeferredStartWhenNeeded() have no effect. The deferred start runs asynchronously, so this method returns immediately. note: You can only call this when automaticallyRunsDeferredStart is false. Otherwise, the session throws an NSInvalidArgumentException. important: To avoid blocking your app’s UI, don’t call this method from the application’s main actor or queue.

## See Also

### Configuring deferred start

- [isManualDeferredStartSupported](avfoundation/avcapturesession/ismanualdeferredstartsupported.md)
- [automaticallyRunsDeferredStart](avfoundation/avcapturesession/automaticallyrunsdeferredstart.md)
- [deferredStartDelegate](avfoundation/avcapturesession/deferredstartdelegate.md)
- [deferredStartDelegateCallbackQueue](avfoundation/avcapturesession/deferredstartdelegatecallbackqueue.md)
- [setDeferredStartDelegate(_:deferredStartDelegateCallbackQueue:)](avfoundation/avcapturesession/setdeferredstartdelegate(_:deferredstartdelegatecallbackqueue:).md)
- [AVCaptureSessionDeferredStartDelegate](avfoundation/avcapturesessiondeferredstartdelegate.md)
