I have the following code for download map regions. This function is called on multiple regions asynchronously. In debug/development mode I rarely get this error. But in production release app I get this issue sometimes and the whole offline user experience is ruined. Notice that for users and fields same function is being used to download regions but it fails mostly for fields and not for users.
const downloadPack = async (packName, bounds) => {
console.log("bounds", packName, bounds);
// Delete old pack
await MapboxGL.offlineManager.deletePack(packName);
const progressListener = (offlineRegion, status) => {
if (status.state === "complete") {
console.log(
`Pack: ${packName}`,
formatBytes(status.completedResourceSize),
status.percentage,
status.state,
);
}
};
const errorListener = (offlineRegion, err) => {
console.log("pack error", offlineRegion, err);
};
const packConfig = {
name: packName,
styleURL: styleURL,
minZoom: MAP_CONFIG.MIN_ZOOM_ALLOWED,
maxZoom: MAP_CONFIG.MAX_ZOOM_ALLOWED,
bounds,
};
await MapboxGL.offlineManager.createPack(
packConfig,
progressListener,
errorListener,
);
// console.log("packConfig", packConfig);
};
I am getting the following errors for following regions:
Regions:
LOG bounds field-region-74 [[67.05473691050432, 24.859774187835313], [67.05879400202377, 24.864996599470516]]
LOG bounds field-region-73 [[67.05603555964123, 24.863974062407152], [67.06011966003771, 24.86902696726922]]
LOG bounds field-region-72 [[67.05860259878298, 24.868365914318616], [67.06177770104551, 24.871585472853567]]
LOG bounds field-region-71 [[67.0527601437771, 24.865385527088804], [67.06248793623786, 24.878936670953124]]
LOG bounds field-region-70 [[67.0575708775574, 24.859917106865936], [67.06827409941002, 24.868984873055723]]
Errors:
LOG pack error {"pack":{"metadata":"{\n \"name\" : \"field-region-74\"\n}","bounds":"{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.05473691050432,24.859774187835313]}},{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.05879400202377,24.864996599470516]}}]}"},"_metadata":null} {"message":"Failed to resolve tileset descriptors: Loading request canceled","name":"field-region-74"}
LOG pack error {"pack":{"metadata":"{\n \"name\" : \"field-region-73\"\n}","bounds":"{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.05603555964123,24.863974062407152]}},{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.06011966003771,24.86902696726922]}}]}"},"_metadata":null} {"name":"field-region-73","message":"Failed to resolve tileset descriptors: Loading request canceled"}
LOG pack error {"pack":{"metadata":"{\n \"name\" : \"field-region-72\"\n}","bounds":"{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.05860259878298,24.868365914318616]}},{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.06177770104551,24.871585472853567]}}]}"},"_metadata":null} {"name":"field-region-72","message":"Failed to resolve tileset descriptors: Loading request canceled"}
LOG pack error {"pack":{"metadata":"{\n \"name\" : \"field-region-71\"\n}","bounds":"{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.0527601437771,24.865385527088804]}},{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[67.06248793623786,24.878936670953124]}}]}"},"_metadata":null} {"name":"field-region-71","message":"Failed to resolve tileset descriptors: Loading request canceled"}
LOG Pack: field-region-70 2.18 MB 100 complete
Notice that last pack is downloaded successfully. I even tried to await the function to make them synchronous but still I get the error.