-1

enter image description here

I am pretty sure that this is the reason why my completion block is not called here:

    resourceRequest = NSBundleResourceRequest(tags: Set(["preview"]))
    resourceRequest?.beginAccessingResources { [weak self] downloaded in //not called


        // here I do what I need with this and at the end I call      
        // self?.resourceRequest?.endAccessingResources()
        
    }

I have cleaned and restarted Xcode, restarted iPhone and Macbook also. Nothing helped. How can I clear it here?

EDIT

I have printed some info of progress property:

print(resourceRequest?.progress.isCancelled) //false
print(resourceRequest?.progress.isPaused) //false
print(resourceRequest?.progress.isFinished) //false
print(resourceRequest?.progress.isIndeterminate) //false
print(resourceRequest?.progress.localizedDescription) //0% completed
print(resourceRequest?.progress.isCancellable) //true

but when I call cancel() nothing changes...

How can I reject, cancel or resume that request?

When I print progress then I have:

<NSProgress: 0x280cd1720> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 1
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
  • please, try to set resourceRequest?.loadingPriority = NSBundleResourceRequestLoadingPriorityUrgent before resourceRequest?.beginAccessingResources – Mark Aug 23 '20 at 12:17
  • doesnt work...;( Still the same...;( This happens on one particular device... not on every – Bartłomiej Semańczyk Aug 23 '20 at 12:28
  • @BartłomiejSemańczyk Have you found a solution for this? We're suffering from the same. Happens very rarely but when it does... for the love of God I've tried everything to exit that state and request the resources over (cancelling, conditionally and just normally requesting access, playing with the priority) to no avail. Only reinstalling the app, and sometimes even also having to restart the phone does; it is baffling. Also it's not just because of Xcode for we know that users are also suffering from this. – Xtian D. Oct 14 '20 at 13:42
  • @XtianD. you need to just wait. My users also experiencing this, and if they try another day then it works. I dont know how to fix it;( – Bartłomiej Semańczyk Oct 14 '20 at 14:48
  • @XtianD. Have you figured it out? Do you know anything can help? I have this issue now again, and dont know what to do... – Bartłomiej Semańczyk Oct 21 '20 at 13:51
  • @BartłomiejSemańczyk Unfortunately not. I was hoping that the issue for us lied in the use of "prefetched" tags, so I turned them all to be only on-demand. At the same time, stripped down our implementation hoping to find culprits. It was all in vain. My impression is that the functionality is internally broken, and that it isn't in our hands to fix. So, in our team we already agreed to move away from Apple's ODR soon, in favor of self-hosting the files and writing our custom API. I'd be interested to know, however, if you ever come across a solution for this, for my personal interest. Cheers! – Xtian D. Oct 22 '20 at 17:10

2 Answers2

0

Hope you have check this attention

You must call this method or conditionallyBeginAccessingResources(completionHandler:) before accessing any resources marked with the tags managed by the request.

func conditionallyBeginAccessingResources(completionHandler: @escaping (Bool) -> Void)

as Apple suggest to do before some checkmark from below link

Please check this checkpoint

Hardik Bar
  • 86
  • 6
0

Is there any chance the disk on the device is full? The documentation gives a handy little snippet to register for the the notification and check it.

Copying it here:

Listing 4-11 Registering for the NSBundleResourceRequestLowDiskSpaceNotification notification


    // Register to call self.lowDiskSpace when the notification occurs
    [[NSNotificationCenter defaultCenter]
        addObserver:self
           selector:@selector(lowDiskSpace:)
               name:NSBundleResourceRequestLowDiskSpaceNotification
             object:nil
    ];

    // Notification handler for low disk space warning
    -(void)lowDiskSpace:(NSNotification*)theNotification
    {
        // Free the lower priority resource requests
        for (NSBundleResourceRequest *atRequest in self.lowPriorityRequests) {
            // End accessing the resources
            [atRequest endAccessingResources];
        }
     
        // clear lowPriorityRequests preventing multiple calls to endAccesingResource
        [self.lowPriorityRequests removeAllObjects];
    }
  • no, disk space is definitely not full. Have 256GB, and over 150 is free. – Bartłomiej Semańczyk Aug 30 '20 at 07:21
  • ok, cool. I would follow up with Hardik Bar's answer below then and make sure you're using the API as Apple intends. Apple docs state: ```You must call this method or conditionallyBeginAccessingResources(completionHandler:) before accessing any resources marked with the tags managed by the request.``` – Chris Schepman Aug 30 '20 at 19:37