Fix iOS 13+ multi-scene window handling and thread safety#1159
Fix iOS 13+ multi-scene window handling and thread safety#1159AdrianCurtin wants to merge 23 commits intoSVProgressHUD:masterfrom
Conversation
Update CHANGELOG.md Fix warning Umbrella header for module
Added a nil check before calling setNeedsStatusBarAppearanceUpdate on rootViewController to prevent potential crashes when rootViewController is not set.
…ore adding to window
…OS 26 Migration)
Adds nil check before calling bundleWithURL: to prevent crash when SVProgressHUD.bundle cannot be found. Fixes SVProgressHUD#1146
Check if containerView.window exists before using containerView. Falls back to frontWindow if containerView was deallocated. Fixes SVProgressHUD#1121
Refactored window retrieval to use protocol conformance and property access for UIWindowSceneDelegate and UIApplicationDelegate. Improved thread safety in popActivity by checking for main thread before executing. Fixed potential nil window access and corrected usage of strongSelf in blocks for grace timer and image tinting.
There was a problem hiding this comment.
Pull request overview
This PR enhances iOS 13+ multi-scene window handling and improves thread safety in SVProgressHUD. The changes address window hierarchy management in multi-scene environments, add proper thread safety checks for UI operations, and remove incorrect symlinks that were causing build warnings.
Key Changes:
- Improved window discovery logic with proper iOS 13+ multi-scene support, including fallback mechanisms for finding the correct window
- Added thread safety checks to ensure UI operations execute on the main thread
- Fixed memory management issues by using strongSelf consistently instead of self in completion blocks
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| SVProgressHUD/SVProgressHUD.m | Core implementation updates including multi-scene window handling, thread safety improvements, and bug fixes for proper window hierarchy validation |
| SVProgressHUD/include/SVRadialGradientLayer.h | Removed incorrect symlink to fix umbrella header warnings |
| SVProgressHUD/include/SVProgressAnimatedView.h | Removed incorrect symlink to fix umbrella header warnings |
| SVProgressHUD/include/SVIndefiniteAnimatedView.h | Removed incorrect symlink to fix umbrella header warnings |
| CHANGELOG.md | Added version 2.3.2 entry documenting the umbrella header fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added tvOS 13.0 availability checks alongside iOS 13.0 for better platform compatibility. Improved logic to ensure mainWindow is only set if sceneDelegate.window exists, and made minor code style adjustments for consistency.
|
This is a sort of bundled PR to close a bunch of open stability issues with the library, please review and comment as you see fit. |
Added detailed entries for version 2.3.2, including fixes for iOS multi-scene window handling, CarPlay crashes, thread safety, and memory management improvements. Also noted tvOS 13.0 availability checks and clarified previous fixes.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@AdrianCurtin could you please explain how issue #1153 was fixed by this pull request? What was the root cause? Thanks |
|
"return windowScene.windows.firstObject;" was returning the wrong window (or nil) on iOS 26. The old code grabbed windowScene.windows.firstObject, which on iOS 26's stricter scene lifecycle is often not the key window It could be a system window or one that's hidden. So the HUD was being added to a non-visible window. Now it checks window.isKeyWindow && !window.isHidden, with multiple fallback layers (inactive scenes, delegate windows) if the first pass doesn't find one. Some other stuff isn't guaranteed to be called from the main thread so its essentilally a race condition. |
Restrict scene handling to application-role UIWindowScenes on iOS/tvOS 13+. When searching for the keyboard window and the active foreground window, the code now checks scene.session.role == UIWindowSceneSessionRoleApplication before iterating windows. This avoids picking up non-application scenes (e.g. system, external, or keyboard-only scenes) and makes window selection more robust on multi-scene environments. No behavioral changes for earlier OS versions.
Summary
This PR consolidates multiple bug fixes to improve iOS 13+ compatibility, thread safety, and defensive nil handling.
iOS 13+ Multi-Scene Support
+mainWindowto properly enumerate connected scenes and find the key windowUIWindowSceneSessionRoleApplicationcheck-frontWindowand-visibleKeyboardHeightfor scene-based window discoveryThread Safety
+popActivitynow checks[NSThread isMainThread]and dispatches to main queue when needed-showProgress:status:optimized to execute synchronously when already on main threadMemory Management
-showProgress:status:,-showImage:status:duration:, and-dismissWithDelay:completion:to consistently usestrongSelfNil Safety
+imageBundlebefore callingbundleWithURL:containerView.windowchecks in-updateViewHierarchyand-moveToPoint:rotateAngle:window && window.rootViewControllercheck before adding HUD to windowrootControllerbefore callingsetNeedsStatusBarAppearanceUpdateOther
performSelector:with proper protocol conformance forUIWindowSceneDelegateCloses
Merges