'React-Native, iOS, XHR - XHR progress event not firing on iOS while downloading Blob/Arraybuffer response type

as title says I've noticed a strange behaviour while trying to subscribe to the "progress" event that should be fired by an XHR call.

NB: Links used below are just for testing purpose, I need to download a big file (about 100MB) and read how many bytes I've already downloaded from "progress" event. Sefram had some heavy file hosted online where I could test

export default function dlTest(dlCalled, nextTest, settings) {

  if (dlCalled) return;

  dlCalled = true;

  let xhr = new XMLHttpRequest();

  xhr.addEventListener("progress", (e) => console.log("progress", e.loaded));
  xhr.addEventListener("load", (e) => console.log("loaded", e.loaded));
  xhr.addEventListener("error", () => console.log("error"));

  let zipAddress = "https://www.sefram.com/images/products/photos/hi_res/BK1760A.zip";
  let jpgAddress = "https://www.sefram.com/images/products/photos/hi_res/207030301.jpg";
  let documentAddress = "https://www.sefram.com/en/download/high-resolution-images.html";

  xhr.open("GET", zipAddress, true); 
  xhr.responseType = "blob";

  xhr.send();
}

Basically I need to read how much bytes I've downloaded since the call started. To sum up my tests:

  • iOS:
    • Call documentAddress && Response-Type: document: It does fire progress event but doesn't update event.loaded (it remains 0). You can try this yourself with documentAddress.

    • Call documentAddress && Response-Type: blob/arraybuffer: It doesn't fire progress event at all

    • Call zipAddress && Response-Type: document It doesn't fire progress event at all

    • Call zipAddress && Response-Type: blob/arraybuffer It doesn't fire progress event at all

I can't really understand why this is happening. I couldn't find any other discussion about this kind of problems. Thanks in advance for your help.

React-Native version: 0.64.3

Slack Example Download Test



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source