Coder Social home page Coder Social logo

Crash on iOS 15 about btprogresshud HOT 17 CLOSED

redth-org avatar redth-org commented on July 30, 2024 2
Crash on iOS 15

from btprogresshud.

Comments (17)

marcoburato avatar marcoburato commented on July 30, 2024 3

@Cheesebaron This is still not quite fixed, unfortunately. I've been adding some logging to my app to figure out why GetActiveWindow() would return null.

Here's the output from a crash report.

This is the normal condition immediately before calling BTProgressHUD.Show(), which works fine:

KeyWindow = <UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>
Windows =
  <UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>
    IsKeyWindow = True
    Hidden = False
    WindowLevel = 0
Scenes:
  <UIWindowScene: 0x104e12fb0; scene = <FBSScene: 0x281868600; identifier: sceneID:REDACTED>; persistentIdentifier = DEAEB509-D8BF-462C-9B07-15688ADF1DA8; activationState = UISceneActivationStateForegroundActive; settingsScene = <UIWindowScene: 0x104e12fb0>; windows = (
    "<UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>"
  )>
    Windows =
      <UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>
        IsKeyWindow = True
        Hidden = False
        WindowLevel = 0
ApplicationState = Active

This is the condition that causes the crash instead:

KeyWindow = 
Windows =
  <UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>
    IsKeyWindow = False
    Hidden = False
    WindowLevel = 0
Scenes:
  <UIWindowScene: 0x104d18db0; scene = <FBSScene: 0x281855380; identifier: sceneID:REDACTED>; persistentIdentifier = DEAEB509-D8BF-462C-9B07-15688ADF1DA8; activationState = UISceneActivationStateForegroundInactive; settingsScene = <UIWindowScene: 0x104d18db0>; windows = (
    "<UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>"
  )>
    Windows =
      <UIWindow: 0x10b510b10; frame = (0 0; 428 926); tintColor = UIExtendedSRGBColorSpace 0 0.588235 0.203922 1; gestureRecognizers = <NSArray: 0x283841380>; layer = <UIWindowLayer: 0x2838414d0>>
        IsKeyWindow = False
        Hidden = False
        WindowLevel = 0
ApplicationState = Inactive

Apparently, sometimes there is no KeyWindow and UIApplication.SharedApplication.ApplicationState == Inactive.

I'm not sure what the proper fix would be.
My app, like most others, only uses a single window. So, it's easy to just pick the only existing one.
In case of multiple windows, things are not so obvious. Perhaps in that use case it would make more sense to not use the convenience static methods and instead manually creating the ProgressHud with a new constructor that allows to specify the target window.

from btprogresshud.

Cheesebaron avatar Cheesebaron commented on July 30, 2024 1

Can someone in this thread grab the artifact from this build and test my fix? https://github.com/redth-org/BTProgressHUD/pull/85/checks?check_run_id=3788006258

from btprogresshud.

mjo151 avatar mjo151 commented on July 30, 2024 1

We display a loading message at startup by calling BTProgressHUD.Show("Loading..."). The NRE occurs at that point and the stack trace indicates it is occurring on line 872 of ProgressHUD.cs. Looking at the code, I can see that UIApplication.SharedApplication.KeyWindow is still referenced.

Note that the problem doesn't happen every time the app is run, so it's not consistently reproducible.

from btprogresshud.

BramFP avatar BramFP commented on July 30, 2024

Adding to this for additional information, we've also experienced some crashes on iOS 15 but haven't tracked down the root cause yet.

Ours originates from Acr.UserDialogs which incorporates BTProgressHUD and we've got a different stack trace though, but just dropping it in here in case it might help.

ProgressHUD.PositionHUD (Foundation.NSNotification notification)
ProgressHUD.ShowProgressWorker (System.Single progress, System.String status, BigTed.ProgressHUD+MaskType maskType, System.Boolean textOnly, BigTed.ProgressHUD+ToastPosition toastPosition, System.String cancelCaption, System.Action cancelCallback, System.Double timeoutMs, System.Boolean showContinuousProgress, UIKit.UIImage displayContinuousImage)
ProgressHUD+<>c__DisplayClass18_0.<Show>b__0 ()
NSActionDispatcher.Apply ()
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr,intptr,intptr,bool)
NSObject.InvokeOnMainThread (System.Action action)
ProgressHUD.Show (System.String status, System.Single progress, BigTed.ProgressHUD+MaskType maskType, System.Double timeoutMs)
BTProgressHUD.Show (System.String status, System.Single progress, BigTed.ProgressHUD+MaskType maskType)
ProgressDialog+<>c__DisplayClass17_0.<Refresh>b__0 ()
NSActionDispatcher.Apply ()
(wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr,intptr,intptr,bool)
NSObject.InvokeOnMainThread (System.Action action)
ProgressDialog.Refresh ()
ProgressDialog.Show ()
AbstractUserDialogs.Progress (Acr.UserDialogs.ProgressDialogConfig config)
AbstractUserDialogs.Loading (System.String title, System.Action onCancel, System.String cancelText, System.Boolean show, System.Nullable`1[T] maskType)
AbstractUserDialogs.ShowLoading (System.String title, System.Nullable`1[T] maskType)

from btprogresshud.

mjo151 avatar mjo151 commented on July 30, 2024

I am also seeing a crash on iOS 15 when building against Xcode 13. I believe the problem is the use of UIApplication.SharedApplication.KeyWindow in the BTProgressHUB library. This property is deprecated and appears to be null in some cases, even after calling Window.MakeKeyAndVisible.

from btprogresshud.

Cheesebaron avatar Cheesebaron commented on July 30, 2024

Hmm, interesting. I think we have to use UIApplication.SharedApplication.ConnectedScenes to get the foreground and active scene.

from btprogresshud.

nicobarengo avatar nicobarengo commented on July 30, 2024

Downloaded and installed... it's very unpredictable the crash, so I will get back with the results 🤞🏻

If someone need the NuGet for Acr.UserDialogs using the updated BTProgressHud (1.3.4) I made one for testing purposes
Acr.UserDialogs NuGet

from btprogresshud.

nicobarengo avatar nicobarengo commented on July 30, 2024

@Cheesebaron I can confirm that the issue is resolved with the the latest build.

from btprogresshud.

Cheesebaron avatar Cheesebaron commented on July 30, 2024

OK, that is cool. Thanks for testing.

from btprogresshud.

Cheesebaron avatar Cheesebaron commented on July 30, 2024

1.3.4 has been released on NuGet

from btprogresshud.

mjo151 avatar mjo151 commented on July 30, 2024

This doesn't appear to be completely resolved. Line 872 of ProgressHUD.cs is still accessing UIApplication.SharedApplication.KeyWindow. This resulted in an NRE when running my app.

from btprogresshud.

Cheesebaron avatar Cheesebaron commented on July 30, 2024

@mjo151 can you please describe the scenario this happens in, so I can better test this?

from btprogresshud.

mjo151 avatar mjo151 commented on July 30, 2024

@Cheesebaron please let me know if you need any additional information to track down this issue.

from btprogresshud.

marcoburato avatar marcoburato commented on July 30, 2024

@Cheesebaron Can you reopen this issue based on my last comment? Or should I create a new one?

from btprogresshud.

RobbiewOnline avatar RobbiewOnline commented on July 30, 2024

Hi, I'm also experiencing this crash on iOS 15 intermittently. I'm using BTProgressHud 1.3.5 and the Xamarin crash is...

MyProject 2022-05-04T22:10:59Z  UI  1 - IosPlatformDifferences - Display Message 'The pin does not match'

2022-05-04 23:11:06.324 MyProject.iOS[16396:1424514] [AppCenterCrashes] ERROR: +[MSACWrapperLogger MSACWrapperLog:tag:level:]/10 Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at BigTed.ProgressHUD.PositionHUD (Foundation.NSNotification notification) [0x000cf] in /_/BTProgressHUD/ProgressHUD.cs:872 
  at Foundation.InternalNSNotificationHandler.Post (Foundation.NSNotification s) [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSNotificationCenter.cs:48 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/UIKit/UIApplication.cs:75 
  at MyProject.iOS.Application.Main (System.String[] args) [0x00001] in /Users/rob/GitHub/hillingar-MyProject-appv2/app/MyProject/MyProject.iOS/Main.cs:16 

2022-05-04 23:11:06.341 MyProject.iOS[16396:1424514] Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
  at BigTed.ProgressHUD.PositionHUD (Foundation.NSNotification notification) [0x000cf] in /_/BTProgressHUD/ProgressHUD.cs:872 
  at Foundation.InternalNSNotificationHandler.Post (Foundation.NSNotification s) [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSNotificationCenter.cs:48 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/UIKit/UIApplication.cs:75 
  at MyProject.iOS.Application.Main (System.String[] args) [0x00001] in /Users/rob/GitHub/hillingar-MyProject-appv2/app/MyProject/MyProject.iOS/Main.cs:16 

from btprogresshud.

brunck avatar brunck commented on July 30, 2024

@devology-rob you should open a new issue for this since this one is closed.

from btprogresshud.

RobbiewOnline avatar RobbiewOnline commented on July 30, 2024

@devology-rob you should open a new issue for this since this one is closed.

Thanks, I noticed afterwards and created #95 and it already looks like you may have fixed it 👏

from btprogresshud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.