#5976 Fix UI getting stuck when transition animation is interrupted #6000
+25
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First time contributor checklist
Contributor checklist
Description
This is a continuation of the issue in #5976. I encountered two scenarios over the week where after tapping done or cancel the buttons animated away, but the view failed to dismiss. I believe #5977 fixed part of this issue, as I haven't had the same error logged, but it's still possible via this route which doesn't generate an error. I think the frequency at which this occurs on my device is much less than pre-#5977 at least.
The theory here is that the animation is interrupted partway through the cycle and returns false even though the buttons have already been dismissed. I think these problems in general are indicative of a larger issue, but we may be able to provide relief by restoring the controls in the event of a cancelled animation.
Now, if iOS interrupts an animation, the controls are restored and the user can retry the operation. I was thinking about taking the business logic outside of the animation, but it degraded the UX of the crop tool by removing the smooth transitions.
Without this fix the user must force close the app to recover due to the controls being hidden, which is not ideal.
Testing and Findings
I added
self.didTapReset()
to the guard statement because depending on where the animation is interrupted eitherself.constrainContent(to: layoutGuide)
orself.updateImageViewTransform()
could have been executed. Not calling reset works, but there's a moment where the user is left with an unrealistic portrayal of their crop which only corrects itself after tapping done again and rerunning the code block. To avoid this confusion I think it's best we just reset the crop tool in the event of the issue and let the user reattempt from scratch.Demos with simulated animation interrupt:
DEMO: Functionality without Reset - YouTube
DEMO: Functionality with Reset - YouTube
Update: I realized, after posting the video, that the image corners were still round after reset since part of the transitionUI function had executed before the simulated error. Added another commit to reset the image corners inside of the guard statement and tested locally.