I’m getting lots of crash reports on my latest app (https://apps.apple.com/us/app/national-hero/id1500338790) and it’s always the same report. The problem is I don’t know what could be wrong. I don’t have any crashs in the simulator, not on my device, not on my test device and not on my wife’s device.
The app has this line of code in almost all views’ Activate handler: Xojo.Core.Timer.CallLater(10, AddressOf m001_DelayedLayout)
In that method I’m doing this: If Xojo.System.Version.MajorVersion >= 13 Then recMenuBackground.SetEffect(BlurStyle_MenuBackground, VibrancyStyle_MenuBackground, Nil)
Not sure if that’s the problem because I have these crash reports for iOS 12 too. But I would assume there is something happening in this method because the crash reports indicate it’s right after the timer fires. It would be extremely helpful to somehow find out if it’s always the same view that’s crashing.
This is the crash report and I would appreciate any help. Thank you!
Thanks for your feedback! If I cancel the call, the code inside that method will not be executed, right? Could I potentially add it to the if-clause where I first cancel and then run it?
What could be a reason why the m001_DelayedLayout wouldn’t exist anymore? It’s a local method in each view as shown on the picture.
Thank you again, I will try setting the delay to 0 and see what happens.
If LoadingView closes, the address of the method will be gone. Since the timer runs of a (dictionary?) that is coming from the main loop it will still try to call the method while the address is gone. That causes a crash.
Say you open the loading view then the timer is called in .Activate. Now the LoadingView closes (for whatever reason) before the timer fired,… The call is still pending, now the timer elapsed and bam, crash since it calls an address that’s non existing.
It’s better to have single shot timer on the view that’s started when the view activates, or opens then in the Run or Action event, call your function. Since that timer would be on the view, it will close with it if it’s destructed.
Usually there are no declares. Most of the time, the method consists of a single line: If Xojo.System.Version.MajorVersion >= 13 Then recMenuBackground.SetEffect(BlurStyle_MenuBackground, VibrancyStyle_MenuBackground, Nil)
BlurStyle_MenuBackground is = iOSRectangle.BlurStyles.ExtraLight
VibrancyStyle_MenuBackground is = iOSRectangle.VibrancyStyles.Fill
I actually believe it’s what you just said, the user is closing the view before the DelayedLayout method is being run. Cause as I said, I haven’t been able to reproduce it on any device. Just tested setting the delay to 0 but that doesn’t work. Delay = 1 works fine. I’ll keep you posted.
To try to re-produce try closing the view asap or set de delay longer and then reproduce to see if you get the same crash. 90% of the crashlog methods should remain the same.
You see the timer is calling CallUserCode and it calls XojoExceptions.h (thus creating an exception there)
The next call after it is UnhandledException.
you can cas it back to the name of the exception (if it was a subclass):
Var exceptionType As Text = Xojo.Core.Introspection.GetType(e).FullName
/// Write to log... exceptionType ...
I use this technique very often in my apps with one major difference. I use WeakAddressOf
In one of my apps I get an exception thrown due to the timer trying to run code in a view that isn’t available anymore. I tried to track from which View this comes from but haven’t fixed it yet.
Fortunately the user never experiences a crash because I have Return True in App.UnhandledException
The experience of an app crashing is so bad for a mobile app that I prefer the user to not know that something went wrong and just let the app continue running and not closing.