swift-snapshot-testing icon indicating copy to clipboard operation
swift-snapshot-testing copied to clipboard

"Unbalanced calls to begin/end appearance transitions" when creating initial snapshot

Open dmeehan1968 opened this issue 3 years ago • 3 comments

Xcode console emits the message:

Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x7fa551921b50>

when this line is executed, when there is no existing snapshot on the disk (i.e. first run).

https://github.com/pointfreeco/swift-snapshot-testing/blob/09520c3523ad5e7ccb8507f1b8cc28d74d7a2832/Sources/SnapshotTesting/AssertSnapshot.swift#L52

I'm using the following assertion when this happens:

        assertSnapshot(as: .image(layout: .sizeThatFits, traits: .init(userInterfaceStyle: .light))) {
            NewReminderButton()
                .fixedSize()
        }

dmeehan1968 avatar Nov 15 '21 09:11 dmeehan1968

Definitely happening here: https://github.com/pointfreeco/swift-snapshot-testing/blob/main/Sources/SnapshotTesting/Common/View.swift#L898

Shame that disabling animations doesn't resolve:

UIView.setAnimationsEnabled(false)

markst avatar Jun 08 '22 17:06 markst

oops think View.swift has been modified since my last comment.

anyway it's something to do with the .beginAppearanceTransition & endAppearanceTransition routine which is triggering this Unbalanced calls output... I'd need to spend a bit of time to rewrite the add(traits to clean it up.

markst avatar Oct 20 '22 23:10 markst

Here's an old PR that fixes it: https://github.com/pointfreeco/swift-snapshot-testing/pull/528. May need an update for the current base branch

hello-im-szymon avatar Dec 27 '22 09:12 hello-im-szymon