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

Fix Terrain Lockups in requestTileGeometry due to Promise Handling Inconsistencies #11630

Merged
Prev Previous commit
Next Next commit
implicit promise handling
Co-authored-by: Gabby Getz <gabby@cesium.com>
  • Loading branch information
marcejohnson and ggetz authored Nov 21, 2023
commit fc60653766eeca7db59de343e0cf8d739facd2ee
17 changes: 3 additions & 14 deletions packages/engine/Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,22 +899,11 @@ CesiumTerrainProvider.prototype.requestTileGeometry = function (
// Try again when availability data is ready– Otherwise the tile will be marked as failed and never re-requested
return availabilityPromise.then(() => {
// handle promise or undefined return
return new Promise((resolve, reject) => {
return new Promise(resolve=> {
// defer execution to the next event loop
setTimeout(() => {
const originalResult = this.requestTileGeometry(x, y, level, request);
if (originalResult && typeof originalResult.then === "function") {
originalResult
.then((result) => {
resolve(result);
})
.catch((err) => {
reject(err);
});
} else {
// undefined means deferred, wait for the promise to resolve
return resolve(this.requestTileGeometry(x, y, level, request));
}
const promise = this.requestTileGeometry(x, y, level, request);
resolve(promise);
}, 0); // next tick
});
});
Expand Down