Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing fatal error in method transitionDuration #642

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

LevinIvan
Copy link
Contributor

Summary

This PR modifies the transitionDuration(using:) method in FloatingPanelController to return 0.0 instead of calling fatalError when the FloatingPanelController instance is not found. This change is crucial for several reasons:

  1. Avoiding Crashes in Production: Using fatalError in production can lead to unexpected crashes, which are detrimental to user experience. It's safer to return a default value like 0.0 and handle the scenario gracefully.

  2. Improved Stability: By returning 0.0, the application can continue running, allowing for better stability and user satisfaction. This approach also aligns with the principle of fail-safety, where the system continues operating under error conditions.

  3. Real-World Case: In our large-scale project, we encountered a crash at this specific point due to the fatalError. Given the size and complexity of our application, it has been challenging to pinpoint the exact cause. Switching to a return value of 0.0 would significantly help us mitigate the issue and maintain app stability while we investigate further.

  4. Maintainability: Returning a default value makes the codebase more maintainable and easier to debug, as it avoids abrupt termination and allows for logging or other error handling mechanisms.

Code Changes

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
    guard
        let fpc = transitionContext?.viewController(forKey: .to) as? FloatingPanelController
    else { return 0.0 }
    // Existing logic
}

We believe this change will benefit not only our project but also others who might face similar issues. Your consideration and review are greatly appreciated.

@LevinIvan
Copy link
Contributor Author

@scenee

@scenee
Copy link
Owner

scenee commented Aug 5, 2024

I totally agree with your suggestion and thanks for the PR. I will release 2.8.5 later.

@scenee scenee merged commit 0e27410 into scenee:master Aug 5, 2024
21 checks passed
@LevinIvan
Copy link
Contributor Author

@scenee, could you please tell me when the new release will be? As I mentioned before, it's really important for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants