Comments (17)
@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.
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.
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.
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.
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.
Hmm, interesting. I think we have to use UIApplication.SharedApplication.ConnectedScenes
to get the foreground and active scene.
from btprogresshud.
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.
@Cheesebaron I can confirm that the issue is resolved with the the latest build.
from btprogresshud.
OK, that is cool. Thanks for testing.
from btprogresshud.
1.3.4 has been released on NuGet
from btprogresshud.
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.
@mjo151 can you please describe the scenario this happens in, so I can better test this?
from btprogresshud.
@Cheesebaron please let me know if you need any additional information to track down this issue.
from btprogresshud.
@Cheesebaron Can you reopen this issue based on my last comment? Or should I create a new one?
from btprogresshud.
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.
@devology-rob you should open a new issue for this since this one is closed.
from btprogresshud.
@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)
- Can't resolve the reference 'UIKit.UIColor UIKit.UIColor::get_SystemBackground()' HOT 6
- Add NuGet to Maui Project HOT 8
- .NET MAUI Support? HOT 1
- ForDefaultWindow() can return `null`
- Nu get package HOT 2
- Crash: Window.Level not normal HOT 1
- iOS 11 - Appearance Changes HOT 6
- Using a lot of Memory on App HOT 2
- Doesn't supports .net standard 2.0 HOT 1
- Xamarin Forms : Acr userdialog loading indicator not showing in Center HOT 8
- Crashes on iOS 12 or older devices HOT 6
- v 1.3.1 Crash - Xamarin - Targeting 13.2 IOS HOT 8
- reviving old xmaring project; type BTProgressHUD exists in Acr.UserDialogs HOT 2
- Release 1.3.4 seems to break Acr.UserDialogs HOT 5
- Namespace change makes it inconvenient to use methods in BTProgressHUD static class HOT 3
- How to disable accessibility focus for indicator and label?
- Object reference not set to an instance of an object HOT 1
- iOS 15 still crashes intermittently HOT 3
- MacCatalyst Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btprogresshud.