Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchImage with ImageBitmap doesn't handle internal redirect #7735

Open
OmarShehata opened this issue Apr 10, 2019 · 1 comment
Open

FetchImage with ImageBitmap doesn't handle internal redirect #7735

OmarShehata opened this issue Apr 10, 2019 · 1 comment

Comments

@OmarShehata
Copy link
Contributor

Forum thread

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?

@StevenPG
Copy link

StevenPG commented Jul 25, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants