redth-org / BTProgressHUD

Port to Xamarin.iOS of the SVProgressHUD
Other
118 stars 64 forks source link

Fix crash on iOS 15 when showing HUD while app is moving to the foreground #93

Closed marcoburato-ecutek closed 2 years ago

marcoburato-ecutek commented 2 years ago

:sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Bug fix

:arrow_heading_down: What is the current behavior?

When the HUD is shown within UIApplicationDelegate.WillEnterForeground(), sometime an exception is thrown, making the app crash. I could not find a way to reproduce the issue, but I have almost 2,000 crash reports proving it does go wrong.

:boom: Does this PR introduce a breaking change?

No

:bug: Recommendations for testing

Unfortunately, I could not find a way to reproduce, so I can only recommend code review.

:memo: Links to relevant issues/docs

Related to #84

marcoburato-ecutek commented 2 years ago

Turns out this is still not going to fix it in all cases because iOS could add extra windows. I believe this is related to having a keyboard shown.

Example 1:

<UIWindow: 0x104632130; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283446fa0>; layer = <UIWindowLayer: 0x283446e80>>
  IsKeyWindow = True
  Hidden = False
  WindowLevel = 0
<UITextEffectsWindow: 0x10ad10a80; frame = (0 0; 428 926); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x283458750>>
  IsKeyWindow = False
  Hidden = False
  WindowLevel = 10

Example 2:

<UIWindow: 0x10ae25b30; frame = (0 0; 428 926); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x2835219e0>; layer = <UIWindowLayer: 0x283521b60>>
  IsKeyWindow = False
  Hidden = False
  WindowLevel = 0
<UITextEffectsWindow: 0x104b497b0; frame = (0 0; 428 926); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x283451380>>
  IsKeyWindow = False
  Hidden = False
  WindowLevel = 1
<UITextEffectsWindow: 0x104c560e0; frame = (0 0; 428 926); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x2835fff60>>
  IsKeyWindow = False
  Hidden = False
  WindowLevel = 10
<UIRemoteKeyboardWindow: 0x105892000; frame = (0 0; 428 926); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x283452f10>>
  IsKeyWindow = False
  Hidden = False
  WindowLevel = 10000001