Something is dropping my running tasks beyond a certain point in the code(see where below). It just stops executing. It only happens on iOS devices. On iOS simulators and android devices it runs perfectly. Anyone seen anything like this before? I don't think it's deadlocks or race conditons, because then it wouldn't complete successfully on other devices right?
Here's some code;
private async Task ExecuteFreshAndPopulateUI(IFetchVehicleCommand command)
{
List<Models.Vehicle.Vehicle> vehicles = await command.ReturnAndExecute<Models.Vehicle.Vehicle>();
var z = 9;
ListPopulateObservableCollection(vehicles, view.Vehicles);
}
public virtual async Task<dynamic> ReturnAndExecute<T>() where T : new()
{
await FlushCache<T>();
await Execute();
await CheckIfCached<T>();
return (dynamic) cachedResult.cachedObject;
}
public override async Task Execute()
{
try
{
dynamic x = await fetchableService.Fetch(userId);
if (x != null)
{
await cacheProvider.Cache(x); // THIS is the last line to be called from this method, it never returns
SetCached(true);
}
}
catch (Exception ex)
{
AddValidationError(ex.Message);
}
}
public async Task Cache(dynamic obj)
{
await database.InsertAllAsync((IEnumerable)obj); // this runs
} // this is the last breakpoint to be hit
Edit: reduced the code to make the issue clearer.
This could be an issue with iOS devices' known limitation in terms of dynamic support. Xamarin's info on this here and a thread here (but as you can see from the last post in the thread, some dynamic support may be available).
The tricky thing about this is that the dynamic code would work fine on an iOS simulator (since Macs support JIT) but would fail on an iOS device (since the iOS device hardware has it specifically disabled).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With