.NET 9 iOS crashing on device in release mode at System.Threading.Tasks.Task.RunContinuations #28197
Labels
area-controls-listview
ListView and TableView
migration-compatibility
Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert
platform/iOS 🍎
t/bug
Something isn't working
Description
I have a large app that I've converted from Xamarin Forms to MAUI.
It's actually too large to be able to create a reproduction.
It has a lot of ListViews that use DataTemplateSelectors. Each data template is rather complex -- nested grids containing a lot of controls and a lot of bindings.
After about 2 to 3 hours of constant use, the app crashes. I also notice that 15 to 30 minutes before it crashes, performance starts to degrade (scrolling through ListView is less smooth, the UI updates slower, etc.)
It hits the AppDomain.CurrentDomain.UnhandledException event and logs the following to my error log:
EXCEPTION: Arg_InvalidCastException
STACK TRACE: at System.Threading.Tasks.Task.RunContinuations(Object ) at System.Threading.Tasks.Task.FinishStageThree() at System.Threading.Tasks.Task.FinishStageTwo() at System.Threading.Tasks.Task.Finish(Boolean ) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& , Thread ) at System.Threading.Tasks.Task.ExecuteEntryUnsafe(Thread ) at System.Threading.Tasks.Task.ExecuteFromThreadPool(Thread ) at System.Threading.ThreadPoolWorkQueue.DispatchItemWithAutoreleasePool(Object , Thread ) at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
This is all that I get, so I have no idea where this is coming from in my code. It never gets caught in a try/catch block.
This does not happen in the Xamarin.Forms version of the app.
Does anyone have an idea of what this error may be a symptom of? Like a memory issue or too many background tasks running?
Is there something that fundamentally changed from Xamarin to Maui in regard to awaiting tasks?
I do a lot of awaiting "heavy processing" functions that are reading from/writing to a sqlite database and then switching back to the main thread to update the UI.
Any thoughts are greatly appreciated.
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
9.0.10 SR1
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
No response
Affected platforms
iOS
Affected platform versions
iOS 15, iOS 16, iOS 17, iOS 18
Did you find any workaround?
No
Relevant log output
The text was updated successfully, but these errors were encountered: