-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Description
When calling SVProgressHUD show methods, the HUD attempts to add its control view to the front window. If the window exists but its rootViewController is nil or in an invalid state, UIKit throws an NSInternalInconsistencyException during trait collection resolution.
Crash Details
The crash occurs in updateViewHierarchy at line 519:
[self.frontWindow addSubview:self.controlView];Stack Trace
Fatal Exception: NSInternalInconsistencyException
UIKitCore _UIThemeKeyValueFromTraitCollection
UIKitCore -[UIDynamicCatalogSystemColor _resolvedColorWithTraitCollection:]
UIKitCore -[UIDynamicColor resolvedColorWithTraitCollection:]
...
UIKitCore -[UIView(Internal) _didMoveFromWindow:toWindow:]
...
SVProgressHUD.m:534 -[SVProgressHUD updateViewHierarchy]
Reproduction
This crash is difficult to reproduce but can occur when:
- SVProgressHUD is shown during app state transitions
- The key window exists but its rootViewController has been deallocated or is nil
- UIKit attempts to resolve trait collection for the new subview
Proposed Fix
Add a nil check for rootViewController before adding the subview:
UIWindow *window = self.frontWindow;
if (window.rootViewController) {
[window addSubview:self.controlView];
}Environment
- iOS 17.x/18.x
- SVProgressHUD master branch
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels