sberrevoets / SDCAlertView

The little alert that could
MIT License
1.86k stars 297 forks source link

Fix iOS 15 crash #326

Closed petrpavlik closed 2 years ago

petrpavlik commented 2 years ago

We've started seeing crashes on iOS 15 when build using Xcode 13. It looks like keyWindow may be nil in certain scenarios (background launch, early in app life cycle?).

sberrevoets commented 2 years ago

Hmm but in that case how do we know what the actual safe area is? Seems like defaulting to 0 would leave users with misaligned alerts?

BarryHaanstra commented 2 years ago

We're seeing this crash as well, but we still have no idea what causes thekeyWindow to become nil. It seems related to iOS 15 indeed.

I'd rather have an occasionally misaligned alert than a crash.

petrpavlik commented 2 years ago

@sberrevoets I'd argue that safe area should be determined from safeArea properties of the view controller that presents the alert, and not the root window. I'd consider this just a hot fix to prevent crashes on iOS 15.

sberrevoets commented 2 years ago

I'd rather have an occasionally misaligned alert than a crash.

That makes sense on an individual level, but by optional chaining it becomes basically impossible to figure out in which situations the behavior changed, whereas if there are useful crash reports with stack traces the underlying problem could potentially be discovered and fixed.

That said, I don't personally feel very strongly one way or another so I'll merge and release this.