Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS dropping Tasks in the middle of execution

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.

like image 673
Kdog Avatar asked Nov 09 '22 12:11

Kdog


1 Answers

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).

like image 69
hvaughan3 Avatar answered Nov 15 '22 11:11

hvaughan3