-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Request Scheduler Prioritization #3397
Changes from 9 commits
825689e
40082fe
546f19d
71f6c50
712881e
e15dfae
7fef79b
a7286e6
7805c29
c3f0326
5b4bb9a
0d94b53
afdebab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ define([ | |
'./HeightmapTerrainData', | ||
'./loadImage', | ||
'./Math', | ||
'./Request', | ||
'./RequestScheduler', | ||
'./RequestType', | ||
'./TerrainProvider' | ||
], function( | ||
when, | ||
|
@@ -29,7 +31,9 @@ define([ | |
HeightmapTerrainData, | ||
loadImage, | ||
CesiumMath, | ||
Request, | ||
RequestScheduler, | ||
RequestType, | ||
TerrainProvider) { | ||
"use strict"; | ||
|
||
|
@@ -200,11 +204,13 @@ define([ | |
* @param {Number} x The X coordinate of the tile for which to request geometry. | ||
* @param {Number} y The Y coordinate of the tile for which to request geometry. | ||
* @param {Number} level The level of the tile for which to request geometry. | ||
* @param {Request} [request] The request object. | ||
* | ||
* @returns {Promise.<TerrainData>|undefined} A promise for the requested geometry. If this method | ||
* returns undefined instead of a promise, it is an indication that too many requests are already | ||
* pending and the request will be retried later. | ||
*/ | ||
ArcGisImageServerTerrainProvider.prototype.requestTileGeometry = function(x, y, level) { | ||
ArcGisImageServerTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) { | ||
var rectangle = this._tilingScheme.tileXYToRectangle(x, y, level); | ||
|
||
// Each pixel in the heightmap represents the height at the center of that | ||
|
@@ -231,7 +237,19 @@ define([ | |
url = proxy.getURL(url); | ||
} | ||
|
||
var promise = RequestScheduler.throttleRequest(url, loadImage); | ||
// TODO : request used to be a boolean called throttleRequest. Continue to handle that case until it is deprecated. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this |
||
if (!defined(request) || (request === false)) { | ||
// If a request object isn't provided, perform an immediate request | ||
request = new Request({ | ||
defer : true | ||
}); | ||
} | ||
|
||
request.url = url; | ||
request.requestFunction = loadImage; | ||
request.type = RequestType.TERRAIN; | ||
|
||
var promise = RequestScheduler.schedule(request); | ||
if (!defined(promise)) { | ||
return undefined; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ define([ | |
'./Matrix3', | ||
'./OrientedBoundingBox', | ||
'./QuantizedMeshTerrainData', | ||
'./Request', | ||
'./RequestScheduler', | ||
'./RequestType', | ||
'./RuntimeError', | ||
'./TerrainProvider', | ||
'./TileProviderError' | ||
|
@@ -45,7 +47,9 @@ define([ | |
Matrix3, | ||
OrientedBoundingBox, | ||
QuantizedMeshTerrainData, | ||
Request, | ||
RequestScheduler, | ||
RequestType, | ||
RuntimeError, | ||
TerrainProvider, | ||
TileProviderError) { | ||
|
@@ -246,7 +250,7 @@ define([ | |
} | ||
|
||
function requestMetadata() { | ||
var metadata = loadJson(metadataUrl); | ||
var metadata = RequestScheduler.request(metadataUrl, loadJson); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at this now, I suspect this is a better approach than doing this implicitly/explicitly in the utility functions. It's explicit to the user, should extend well to new request functions, and I imagine is what a typical game engine's "resource manager" looks like. |
||
when(metadata, metadataSuccess, metadataFailure); | ||
} | ||
|
||
|
@@ -474,17 +478,16 @@ define([ | |
* @param {Number} x The X coordinate of the tile for which to request geometry. | ||
* @param {Number} y The Y coordinate of the tile for which to request geometry. | ||
* @param {Number} level The level of the tile for which to request geometry. | ||
* @param {Boolean} [throttleRequests=true] True if the number of simultaneous requests should be limited, | ||
* or false if the request should be initiated regardless of the number of requests | ||
* already in progress. | ||
* @param {Request} [request] The request object. | ||
* | ||
* @returns {Promise.<TerrainData>|undefined} A promise for the requested geometry. If this method | ||
* returns undefined instead of a promise, it is an indication that too many requests are already | ||
* pending and the request will be retried later. | ||
* | ||
* @exception {DeveloperError} This function must not be called before {@link CesiumTerrainProvider#ready} | ||
* returns true. | ||
*/ | ||
CesiumTerrainProvider.prototype.requestTileGeometry = function(x, y, level, throttleRequests) { | ||
CesiumTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs some backwards compatibility code for when " |
||
//>>includeStart('debug', pragmas.debug) | ||
if (!this._ready) { | ||
throw new DeveloperError('requestTileGeometry must not be called before the terrain provider is ready.'); | ||
|
@@ -507,8 +510,6 @@ define([ | |
url = proxy.getURL(url); | ||
} | ||
|
||
var promise; | ||
|
||
var extensionList = []; | ||
if (this._requestVertexNormals && this._hasVertexNormals) { | ||
extensionList.push(this._littleEndianExtensionSize ? "octvertexnormals" : "vertexnormals"); | ||
|
@@ -520,14 +521,22 @@ define([ | |
function tileLoader(tileUrl) { | ||
return loadArrayBuffer(tileUrl, getRequestHeader(extensionList)); | ||
} | ||
throttleRequests = defaultValue(throttleRequests, true); | ||
if (throttleRequests) { | ||
promise = RequestScheduler.throttleRequest(url, tileLoader); | ||
if (!defined(promise)) { | ||
return undefined; | ||
} | ||
} else { | ||
promise = tileLoader(url); | ||
|
||
// TODO : request used to be a boolean called throttleRequest. Continue to handle that case until it is deprecated. | ||
if (!defined(request) || (request === false)) { | ||
// If a request object isn't provided, perform an immediate request | ||
request = new Request({ | ||
defer : true | ||
}); | ||
} | ||
|
||
request.url = url; | ||
request.requestFunction = tileLoader; | ||
request.type = RequestType.TERRAIN; | ||
|
||
var promise = RequestScheduler.schedule(request); | ||
if (!defined(promise)) { | ||
return undefined; | ||
} | ||
|
||
var that = this; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,14 +160,13 @@ define([ | |
* @param {Number} x The X coordinate of the tile for which to request geometry. | ||
* @param {Number} y The Y coordinate of the tile for which to request geometry. | ||
* @param {Number} level The level of the tile for which to request geometry. | ||
* @param {Boolean} [throttleRequests=true] True if the number of simultaneous requests should be limited, | ||
* or false if the request should be initiated regardless of the number of requests | ||
* already in progress. | ||
* @param {Request} [request] The request object. | ||
* | ||
* @returns {Promise.<TerrainData>|undefined} A promise for the requested geometry. If this method | ||
* returns undefined instead of a promise, it is an indication that too many requests are already | ||
* pending and the request will be retried later. | ||
*/ | ||
EllipsoidTerrainProvider.prototype.requestTileGeometry = function(x, y, level, throttleRequests) { | ||
EllipsoidTerrainProvider.prototype.requestTileGeometry = function(x, y, level, request) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deprecation comment throughout. |
||
return this._terrainData; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*global define*/ | ||
define([ | ||
'./defaultValue' | ||
], function( | ||
defaultValue) { | ||
"use strict"; | ||
|
||
/** | ||
* Stores information for making a request using {@link RequestScheduler}. | ||
* | ||
* @exports Request | ||
* | ||
* @private | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we plan to keep Although their most important use for most apps will be deep inside of Cesium for things that stream, I think they will be useful as a public API for any app that wants to play nice with requests. Perhaps the best approach is to keep them private when this is first merged into master, and then make them public when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with keeping it private for now. |
||
*/ | ||
function Request(options) { | ||
options = defaultValue(options, defaultValue.EMPTY_OBJECT); | ||
|
||
/** | ||
* The URL to request. | ||
* | ||
* @private | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the class is private, each member does not need to be |
||
*/ | ||
this.url = options.url; | ||
|
||
/** | ||
* Extra parameters to send with the request. For example, HTTP headers or jsonp parameters. | ||
* | ||
* @private | ||
*/ | ||
this.parameters = options.parameters; | ||
|
||
/** | ||
* The actual function that makes the request. | ||
* | ||
* @private | ||
*/ | ||
this.requestFunction = options.requestFunction; | ||
|
||
/** | ||
* Type of request. Used for more fine-grained priority sorting. | ||
* | ||
* @private | ||
*/ | ||
this.type = options.type; | ||
|
||
/** | ||
* Specifies that the request should be deferred until an open slot is available. | ||
* A deferred request will always return a promise, which is suitable for data | ||
* sources and utility functions. | ||
* | ||
* @private | ||
*/ | ||
this.defer = defaultValue(options.defer, false); | ||
|
||
/** | ||
* The distance from the camera, used to prioritize requests. | ||
* | ||
* @private | ||
*/ | ||
this.distance = defaultValue(options.distance, 0.0); | ||
|
||
// Helper members for RequestScheduler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mark these as |
||
|
||
/** | ||
* A promise for when a deferred request can start. | ||
* | ||
* @private | ||
*/ | ||
this.startPromise = undefined; | ||
|
||
/** | ||
* Reference to a {@link RequestScheduler~RequestServer}. | ||
* | ||
* @private | ||
*/ | ||
this.server = options.server; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would have more precise semantics if it was named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe not. Up to you. |
||
} | ||
|
||
return Request; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version will it be removed in? 1.19 is find IMO.