Interrupting a custom view controller presentation transition results in sudden disappearance

I’ve implemented a basic custom view controller presentation: the presented view controller slides up from the bottom in a manner similar to UISheetPresentationController, and can be dismissed by tapping the dimming view added on top of the presenting view controller.

I want my custom presentation to be interruptible, so the user should be able to tap the dimming view while the presentation transition is in progress to smoothly convert the presentation transition into a dismissal transition. I’m using additive spring animations (by virtue of UIViewPropertyAnimator) here to make the change in direction less jarring.

Unfortunately, it seems that the interruption-triggered dismissal transition is abruptly terminated by the system based on some kind of timer. The later in the presentation transition I tap the dimming view, the earlier the dismissal transition is terminated.

Steps to reproduce

After launching the test project:

  1. Tap the “Present” button.
  2. Tap the dimming view just before the transition completes.

The test project includes a screen recording of the broken behavior.

Interrupting a custom view controller presentation transition results in sudden disappearance
 
 
Q