Skip to content

This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.

License

Notifications You must be signed in to change notification settings

lovoo/LVModalQueue

Repository files navigation

LVModalQueue

This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.

Build Status Carthage compatible

Quick start

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/lovoo/LVModalQueue.git", .upToNextMajor(from: "0.3.0"))
]

Cocoapods

pod 'LVModalQueue', :git => 'https://github.com/Lovoo/LVModalQueue'

Done! You don't have to import anything or change your existing code!

Sample

Sample image

Motivation

If a presentation or dismissal is currently in progress, when starting another one, a NSInternalInconsistencyException is thrown because a transition is already in progress.

Having a big app with a lot of external frameworks comes with a lot of challenges.

One of them is, that most of this frameworks tend to present their UIViewControllers on [UIApplication sharedApplication].keyWindow.rootViewController. Having truly interactive UIViewController transitions could also lead to multiple concurrent presentations as the user can start a transition, while an old one is still running.

Implementation

LVModalQueue hooks into presentations and dismissals by swizzling into UIViewControllers presentViewController:animated:completion: and dismissViewControllerAnimated:completion: methods. If a transition is currently animating, it is queued for later execution when the transition is finished.

Supported iOS Versions

LVModalQueue was tested on iOS 7 and above in the LOVOO App with millions of users and reduced our crashes with concurrent transitions to zero.

About

This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published