Describe the bug
Running snapshot generates Unbalanced calls to begin/end transition for view controller message. View controller in question is the one created here
Expected behaviour
Calls to begin/end transition are balanced.
Environment
swift-snapshot-testing version 1.9, 1.11
Xcode 14.2
Swift 5.7
OS: iOS 16
Additional context
Why is this an issue?
In our project we have almost 400 snapshots. When running them all message is not printed to console immediately, but it seems they are left unprocessed by runloop until in one test when waiting for snapshot all (or most?) of them are processed at once causing timeout in that test (when run on our CI, but sometimes it did happen also on local machine). Yes, we can increase timeout for that test, but it's just workaround and won't change fact that after adding additional snapshots this issue will cause other test to fail.
From my investigation it looks like additional beginAppearanceTransition is called by UIWindow.rootViewController setter (not directly), used in add private method in View.swift which creates unbalanced view controller. I tried removing manual calls to beginAppearanceTransition seen in add method, but then additional beginAppearanceTransition call occurred as effect of layoutIfNeeded.
Some stackoverflow answers suggest this message is generated when view controller is beginning it's appearance transition before appearance of its parent has ended.
Issue #538 seems to be related (or even the same).
Describe the bug Running snapshot generates
Unbalanced calls to begin/end transition for view controller
message. View controller in question is the one created hereTo Reproduce Launch
UnbalancedCallsTests
UnbalancedCalls.zip
Expected behaviour Calls to begin/end transition are balanced.
Environment
Additional context Why is this an issue? In our project we have almost 400 snapshots. When running them all message is not printed to console immediately, but it seems they are left unprocessed by runloop until in one test when waiting for snapshot all (or most?) of them are processed at once causing timeout in that test (when run on our CI, but sometimes it did happen also on local machine). Yes, we can increase timeout for that test, but it's just workaround and won't change fact that after adding additional snapshots this issue will cause other test to fail.
From my investigation it looks like additional
beginAppearanceTransition
is called byUIWindow.rootViewController
setter (not directly), used inadd
private method inView.swift
which creates unbalanced view controller. I tried removing manual calls tobeginAppearanceTransition
seen inadd
method, but then additionalbeginAppearanceTransition
call occurred as effect oflayoutIfNeeded
.Some stackoverflow answers suggest this message is generated when view controller is beginning it's appearance transition before appearance of its parent has ended.
Issue #538 seems to be related (or even the same).