Task orphaned for request in react-native – what does it mean?

前端 未结 4 1380
傲寒
傲寒 2021-02-04 05:19

I am trying to build a grid system for tiles with buttons and other actions. I forked trying with the react native playground grid images source, that you can find here. It prod

相关标签:
4条回答
  • 2021-02-04 05:22

    according to react native, it better to have the item component a pure component and all the data to be rendered in the component should be in the item object itself for better performance. In case of image I also dont know how they are handling it. loading image from url might be something which is not in the item object itself. However, i am also getting the issue and I am calling a function to load an image icon which are packed with application.

    0 讨论(0)
  • 2021-02-04 05:25

    I think this issue is possibly related to you trying to load http images in ios. I get this same error in my project when using faker images in my seed data on ios (android doesn't care) which only come back with http. Here's a better explanation that I found on this topic React-native loading image over https works while http does not work

    0 讨论(0)
  • 2021-02-04 05:33

    A number of people are encountering the same issue. Seems to be a RN bug.

    https://github.com/facebook/react-native/issues/12152

    https://github.com/facebook/react-native/issues/10731

    0 讨论(0)
  • 2021-02-04 05:43

    It may have something to do with the way you are rendering. Your request seems to get stuck. It looks like this is the code where the error is thrown in RN (from RCTImageLoader.m):

    // Remove completed tasks
    for (RCTNetworkTask *task in _pendingTasks.reverseObjectEnumerator) {
      switch (task.status) {
        case RCTNetworkTaskFinished:
          [_pendingTasks removeObject:task];
          _activeTasks--;
          break;
        case RCTNetworkTaskPending:
          break;
        case RCTNetworkTaskInProgress:
          // Check task isn't "stuck"
          if (task.requestToken == nil) {
            RCTLogWarn(@"Task orphaned for request %@", task.request);
            [_pendingTasks removeObject:task];
            _activeTasks--;
            [task cancel];
          }
          break;
      }
    }
    

    I'm not exactly sure how to solve this, but a couple ideas to help you debug:

    1. The <Image> component has some functions and callbacks that you could utilize to try to further track down the issue (onLoad, onLoadEnd, onLoadStart, onError, onProgress). The last two are iOS only but you could see if any of those are called to see where in the process things get hung up.

    2. Alternatively, the way I would do this would be to use a ListView and place the image urls in the datasource prop for the ListView (utilizing the _.chunk method to group them as you already do). This would be a little cleaner way of rendering them IMO

    0 讨论(0)
提交回复
热议问题