FetchImage with ImageBitmap doesn't handle internal redirect
This Sandcastle tries to load imagery via http.
The browser will block the mixed content requests, so imagery does not load. However, turning off imagebitmap support by adding:
Cesium.Resource.supportsImageBitmapOptions = function(){
return Cesium.when.resolve(false);
};
Shows that the imagery first receives a 307 Internal Redirect, and then redirects to the https URL, which works fine.
I think this is because when we fetchImage with preferImageBitmap, we will always try to fetch the image as a blob, since that allows the decode to happen off the main thread. So this fetchBlob code-path doesn't handle the redirect?
This is now an issue again, I believe because there was a switch to Promises. The code included the issue no longer works.
To recreate, use the sandcastle link and add the code included in the issue description. It now results in an error
TypeError: Cannot read properties of undefined (reading 'resolve') TypeError: Cannot read properties of undefined (reading 'resolve')
I attempted to use
Cesium.Resource.supportsImageBitmapOptions = function(){
const imageDataUri =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAAE4g3rEiDgAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADElEQVQI12Ng6GAAAAEUAIngE3ZiAAAAAElFTkSuQmCC";
let supportsImageBitmapOptionsPromise = Cesium.Resource.fetchBlob({
url: imageDataUri,
})
.then(function (blob) {
return false;
});
return supportsImageBitmapOptionsPromise;
};
To force it, to no avail.