I just released a new app and most folks are having no problems with it, but one savvy user contacted me about a consistent crash when selecting an option in a MessageBox. This selection changes to a custom iOSLayout to load new screens in a split view. He’s probably the only person running this app on an M1 iPad, although he’s having no problems with it on his M1 Mac or iPhone. Here’s the crash log he sent me from connecting his iPad to Xcode:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x1b73a6b38 __pthread_kill + 8
1 libsystem_pthread.dylib 0x1f0b6f3bc pthread_kill + 268
2 libsystem_c.dylib 0x18b57a524 abort + 168
3 libsystem_c.dylib 0x18b5d1998 __assert_rtn + 272
4 Classic Citizens 0x102b9a0a8 UnhandledException(RuntimeObject*) + 444
5 Classic Citizens 0x102bd89c8 -[XOJViewController viewWillAppear:] + 1540
6 UIKitCore 0x1829f8290 -[UIViewController _setViewAppearState:isAnimating:] + 664
So it seems that there is an issue in the Xojo framework.
If I watch the Console logs when the app crashes, the last statement reads:
So it seems that is something that only Xojo can fix.
I’m using 2022r2. Could that be the issue?
It would seem you have an unhandled exception in the Opening or Activated events, or there is an internal framework error with the XOJViewController which backs MobileScreen/iOSView
It wouldn’t be called this if it was in XOJViewController. This is a Xojo exception, not an Objective-C exception.
When the user first contacted me, he said:
I assume that you‘ve not set the sourceView and sourceRect property on the popoverPresentationController on the viewController that you want to present. This is not necessary on the iPhone, but not setting these properties will crash on an iPad. I know that kind of crash
I need to do an update to the app, and will use 2022r3 this time and see if it makes a difference for him.
So I guess you actually know what message box the user is referring to.
What code is the message box calling?
If Self.ParentSplitView <> Nil Then 'iPad
Var bdl As New ChargenLayout
App.CurrentLayout.Content = bdl.Content
Var cbd As New BasicDataScreen
App.CurrentLayout.Content = cbd
Chargen Layout is just a split iOSLayout. This works for everyone except this guy with an M1 processor in his iPad Pro.
Now what is in the Activated event of ChargenLayout ?
The master screen Opening event is
// Create a new citizen
Var c As New CitizenClass
CurrentCitizen = Citizens.LastIndex
// Add Stop Button
Var stopbutton As New MobileToolbarButton(MobileToolbarButton.Types.Stop)
The master screen Activated event is
// Get current name for citizen
NameTextField.Text = Citizens(CurrentCitizen).Name
If Citizens(CurrentCitizen).Male = True Then
SexSegmentedButton.SelectedSegmentIndex = 0
SexSegmentedButton.SelectedSegmentIndex = 1
The detail screen Activated event references Citizens(CurrentCitizen) to fill out numerous labels on that screen.
CurrentCitizen should be valid at this point, I presume?
I believe you have tested your app on an iPad Simulator and perhaps a real iPad if you have one.
You definitely have an OutofBounds exception in the Activated event of one of your views.
I see that
CurrentCitizen is changed in your
Masterview.Opening event, it might be possible that the
DetailView.Activated event is happening before the MasterView’s Opening event.
Make sure you check for OutofBounds in both Activated events and eventually move code to a method and use Timer.CallLater 200, AddressOf TheMethod to make sure the execution is delayed a little.
Thanks for all the help. I’ve asked the user to check if a build done with 2022r3 instead of r2 makes a difference. If not, your suggestion is a good one. It’s interesting that this problem happens very rarely.
I’ve confirmed with the user that the detail screen activates before the master screen even opens! So I’ll be adding a delay timer to open the detail screen. Interesting that this only occurs on an M1 iPad Pro.