NSBundle PathsForResources returning null after downloading On Demand Resource Bundle

148 views Asked by At

My team is experiencing a very odd issue with Apple's On Demand Resources framework. It's a randomly occurring problem where a user will successfully download one of our resources yet when we try to access the path of this resource via NSBundle.PathsForResources() it does not show up. When a user gets into this state with a specific resource tag we have not found a way to fix the issue. Our code does attempt to refetch the affected resource tag every time this part of the app is accessed so it's not a matter of not refetching, we are definitely fetching and succeeding in the download. The odd part is that uninstalling the app and reinstalling does not even fix this broken state. One would assume that nothing is carried over between app deletion and reinstall on iOS but that does not seem to be the case here. Additionally this is occurring on seemingly random assets, there is no pattern of certain On Demand Resource Bundles being affected, it's different in all cases. Once the resource tag is "bricked" it remains this way. Any ideas what could be causing this/what we can try to fix this?

Download code:

        // create and initialize new resource request
    public async Task CreateODRResourceRequest(string tag)
    {
        if (string.IsNullOrWhiteSpace(tag))
        {
            throw new ArgumentNullException(nameof(tag));
        }

        // Create resource request
        var request = new NSBundleResourceRequest(new[] { tag });

        // Set highest loading priority
        request.LoadingPriority = NSBundleResourceRequest.LoadingPriorityUrgent;

        _currentResourceRequest = request;

        var resourcesAlreadyAvailable = await request.ConditionallyBeginAccessingResourcesAsync();

        // ensure we only download resource if it's not already on the device
        if (!resourcesAlreadyAvailable)
        {
            await request.BeginAccessingResourcesAsync();
        }
    }
0

There are 0 answers