diff --git a/CHANGES.md b/CHANGES.md index 8cb37d09b292..ef0f7d8b8eb9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,11 +10,12 @@ Change Log ##### Fixes :wrench: * Fixed a bug that caused missing segments for ground polylines with coplanar points over large distances and problems with polylines containing duplicate points. [#7885](https://github.com/AnalyticalGraphicsInc/cesium//pull/7885) * Fixed a bug where billboards were not pickable when zoomed out completely in 2D View. [#7908](https://github.com/AnalyticalGraphicsInc/cesium/pull/7908) +* Fixed a bug where image requests that returned HTTP code 204 would prevent any future request from succeeding on browsers that supported ImageBitmap. [#7914](https://github.com/AnalyticalGraphicsInc/cesium/pull/7914/) * Fixed polyline colors when `scene.highDynamicRange` is enabled. [#7924](https://github.com/AnalyticalGraphicsInc/cesium/pull/7924) * Fixed a bug in the inspector where the min/max height values of a picked tile were undefined. [#7904](https://github.com/AnalyticalGraphicsInc/cesium/pull/7904) ### 1.58.1 - 2018-06-03 -_This is an npm-only release to fix a publishing issue_ +_This is an npm-only release to fix a publishing issue_. ### 1.58 - 2019-06-03 diff --git a/Source/Core/Resource.js b/Source/Core/Resource.js index b92959f3caa4..f4c4aa0f8a55 100644 --- a/Source/Core/Resource.js +++ b/Source/Core/Resource.js @@ -981,7 +981,6 @@ define([ } var deferred = when.defer(); - Resource._Implementations.createImage(url, crossOrigin, deferred, flipY, preferImageBitmap); return deferred.promise; @@ -1869,24 +1868,18 @@ define([ return Resource.fetchBlob({ url: url - }); - }) - .then(function(blob) { - if (!defined(blob)) { - return; - } - - return Resource.createImageBitmapFromBlob(blob, { - flipY: flipY, - premultiplyAlpha: false - }); - }) - .then(function(imageBitmap) { - if (!defined(imageBitmap)) { - return; - } + }) + .then(function(blob) { + if (!defined(blob)) { + deferred.reject(new RuntimeError('Successfully retrieved ' + url + ' but it contained no content.')); + return; + } - deferred.resolve(imageBitmap); + return Resource.createImageBitmapFromBlob(blob, { + flipY: flipY, + premultiplyAlpha: false + }); + }).then(deferred.resolve); }) .otherwise(deferred.reject); }; diff --git a/Specs/Core/ResourceSpec.js b/Specs/Core/ResourceSpec.js index 5ecfedf8ca4e..d76b3b595d52 100644 --- a/Specs/Core/ResourceSpec.js +++ b/Specs/Core/ResourceSpec.js @@ -1891,6 +1891,37 @@ defineSuite([ expect(rejectedError).toBeInstanceOf(RequestErrorEvent); }); + it('is an image with status code 204 with preferImageBitmap', function() { + if (!supportsImageBitmapOptions) { + return; + } + + var promise = Resource.fetchImage({ + url: './Data/Images/Green.png', + preferImageBitmap: true + }); + + expect(promise).toBeDefined(); + + var resolved = false; + var resolvedValue; + var rejectedError; + promise.then(function(value) { + resolved = true; + resolvedValue = value; + }).otherwise(function (error) { + rejectedError = error; + }); + + expect(resolvedValue).toBeUndefined(); + expect(rejectedError).toBeUndefined(); + + fakeXHR.simulateHttpResponse(204); + expect(resolved).toBe(false); + expect(resolvedValue).toBeUndefined(); + expect(rejectedError).toBeDefined(); + }); + it('resolves undefined for status code 204', function() { var promise = loadWithXhr({ url : 'http://example.invalid'