Skip to content

Fix crash when rootViewController is nil during dismiss#1156

Open
AdrianCurtin wants to merge 1 commit intoSVProgressHUD:masterfrom
AdrianCurtin:fix/dismiss-nil-check
Open

Fix crash when rootViewController is nil during dismiss#1156
AdrianCurtin wants to merge 1 commit intoSVProgressHUD:masterfrom
AdrianCurtin:fix/dismiss-nil-check

Conversation

@AdrianCurtin
Copy link

Summary

Fixes #1155

Adds a nil check before calling setNeedsStatusBarAppearanceUpdate on the rootViewController in the dismiss animation completion block.

Problem

When SVProgressHUD is dismissed, the animation completion block retrieves the rootViewController and calls setNeedsStatusBarAppearanceUpdate on it. If the rootViewController has been deallocated (e.g., during view controller transitions), this causes a crash.

Solution

Simple nil check before the method call:

UIViewController *rootController = [SVProgressHUD mainWindow].rootViewController;
if (rootController) {
    [rootController setNeedsStatusBarAppearanceUpdate];
}

Testing

  • Verified the fix compiles correctly
  • The status bar appearance update is a visual nicety, not critical functionality, so skipping it when rootViewController is nil has no adverse effects

Added a nil check before calling setNeedsStatusBarAppearanceUpdate on rootViewController to prevent potential crashes when rootViewController is not set.
Copilot AI review requested due to automatic review settings December 24, 2025 18:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash that occurs when SVProgressHUD is dismissed and the rootViewController is nil. The fix adds a defensive nil check before calling setNeedsStatusBarAppearanceUpdate on the rootViewController.

  • Adds nil check for rootViewController before calling setNeedsStatusBarAppearanceUpdate

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Crash in dismiss animation completion when rootViewController is nil

1 participant