Ribs: Unbalanced calls to begin/end appearance transitions

Created on 24 Nov 2017  路  5Comments  路  Source: uber/RIBs

The warning "The unbalanced calls to begin/end appearance transitions" seems to occur on my RootViewController RIB when the RootRouter tries to present another controller. The warning occurs when a view controller tries to present the another view controller even though the presenting view controller has not finished displaying. Any idea on preventing this warning to occur?

question

Most helpful comment

Making the listing as the root does makes sense as the root VC does nothing except for presenting the listing vc.

This makes sense to me now. Thank you and cheers! 馃嵒馃嵒

All 5 comments

That warning is usually because the parent view controller has not been fully presented yet, before the child view controller is presented. RIBs doesn't deal with any UIKit specific logic. Perhaps you can show some more code of how the root view controller is attached to window and how you present the second view controller? It's difficult to debug without seeing any code.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    private var launchRouter: LaunchRouting?

    func application(_: UIApplication,
                     didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let window = UIWindow(frame: UIScreen.main.bounds)
        self.window = window

        let launchRouter = RootBuilder(dependency: AppComponent()).build()
        self.launchRouter = launchRouter

        launchRouter.launchFromWindow(window)

        return true
    }
}


final class RootRouter: LaunchRouter<RootInteractable, RootViewControllable>, RootRouting {
    // MARK: - Private
    private let listingBuilder: ListingBuildable

    init(interactor: RootInteractable,
         viewController: RootViewControllable,
         listingBuilder: ListingBuildable) {
        self.listingBuilder = listingBuilder
        super.init(interactor: interactor, viewController: viewController)
        interactor.router = self
    }

    override func didLoad() {
        super.didLoad()

        routeToListing(withSubreddit: "all")
    }

    func routeToListing(withSubreddit subreddit: String) {
        let listing = listingBuilder.build(withListener: interactor, subreddit: subreddit)
        attachChild(listing)

        viewController.present(viewController: listing.viewControllable)
    }
}

Above is my sample root router and how it is presented

AFAIK the warning also occurs in the sample tutorials.

The listing VC is being presented in the same runloop cycle as the root VC is assigned to the window, while making the window visible. This will indeed cause a warning.

I think we should consider why the listing VC is separated from root to begin with? If we want listing to be attached to root at all times, as it's indicated by using the didLoad method for attachment, then there really isn't a lifecycle difference between root and listing. Perhaps we can collapse listing RIB entirely into root. If we think there are significant dependency differences between the two scopes, then perhaps a separate listing scope is warranted. In that case, we may want to only collapse the VC hierarchy, by combining the listing VC with the root VC.

Making the listing as the root does makes sense as the root VC does nothing except for presenting the listing vc.

This makes sense to me now. Thank you and cheers! 馃嵒馃嵒

Happy to help!

Was this page helpful?
0 / 5 - 0 ratings