Skip to content

Commit

Permalink
Merge pull request #6953 from mksquires/modelAnimationCacheMemoryUseBug
Browse files Browse the repository at this point in the history
Altered Model's cacheKey to use a GUID.
  • Loading branch information
Hannah authored Aug 28, 2018
2 parents b9f3689 + 803ad84 commit d6e03a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Change Log
* Fixed crash that happened when calling `scene.pick` after setting a new terrain provider [#6918](https://github.com/AnalyticalGraphicsInc/cesium/pull/6918)
* Fixed an issue that caused the browser to hang when using `drillPick` on a polyline clamped to the ground. [6907](https://github.com/AnalyticalGraphicsInc/cesium/issues/6907)
* Fixed an issue where color wasn't updated propertly for polylines clamped to ground [#6927](https://github.com/AnalyticalGraphicsInc/cesium/pull/6927)
* Fixed an excessive memory use bug that occurred when a data URI was used to specify a glTF model. [#6928](https://github.com/AnalyticalGraphicsInc/cesium/issues/6928)
* Fixed an issue where switching from 2D to 3D could cause a crash. [#6929](https://github.com/AnalyticalGraphicsInc/cesium/issues/6929)
* Fixed an issue where point primitives behind the camera would appear in view. [#6904](https://github.com/AnalyticalGraphicsInc/cesium/issues/6904)
* The `createGroundPolylineGeometry` web worker no longer depends on `GroundPolylinePrimitive`, making the worker smaller and potentially avoiding a hanging build in some webpack configurations.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Josh Lawrence](https://github.com/loshjawrence)
* [Omar Shehata](https://github.com/OmarShehata)
* [Matt Petry](https://github.com/MattPetry)
* [Michael Squires](https://github.com/mksquires)
* [NICTA](http://www.nicta.com.au/)
* [Chris Cooper](https://github.com/chris-cooper)
* [Kevin Ring](https://github.com/kring)
Expand Down
15 changes: 11 additions & 4 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
'../Core/clone',
'../Core/Color',
'../Core/combine',
'../Core/createGuid',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
Expand Down Expand Up @@ -85,6 +86,7 @@ define([
clone,
Color,
combine,
createGuid,
defaultValue,
defined,
defineProperties,
Expand Down Expand Up @@ -221,7 +223,7 @@ define([
};

var gltfCache = {};

var uriToGuid = {};
///////////////////////////////////////////////////////////////////////////

/**
Expand Down Expand Up @@ -1209,9 +1211,14 @@ define([
var basePath = defaultValue(options.basePath, modelResource.clone());
var resource = Resource.createIfNeeded(basePath);

// If no cache key is provided, use the absolute URL, since two URLs with
// different relative paths could point to the same model.
var cacheKey = defaultValue(options.cacheKey, getAbsoluteUri(modelResource.url));
// If no cache key is provided, use a GUID.
// Check using a URI to GUID dictionary that we have not already added this model.
var cacheKey = defaultValue(options.cacheKey, uriToGuid[getAbsoluteUri(modelResource.url)]);
if (!defined(cacheKey)) {
cacheKey = createGuid();
uriToGuid[getAbsoluteUri(modelResource.url)] = cacheKey;
}

if (defined(options.basePath) && !defined(options.cacheKey)) {
cacheKey += resource.url;
}
Expand Down
3 changes: 2 additions & 1 deletion Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ defineSuite([
expect(texturedBoxModel.ready).toEqual(true);
expect(texturedBoxModel.asynchronous).toEqual(true);
expect(texturedBoxModel.releaseGltfJson).toEqual(false);
expect(texturedBoxModel.cacheKey).toEndWith('Data/Models/Box-Textured/CesiumTexturedBoxTest.gltf');
expect(texturedBoxModel.cacheKey).toBeDefined();
expect(texturedBoxModel.cacheKey).not.toContain('Data/Models/Box-Textured/CesiumTexturedBoxTest.gltf');
expect(texturedBoxModel.debugShowBoundingVolume).toEqual(false);
expect(texturedBoxModel.debugWireframe).toEqual(false);
expect(texturedBoxModel.distanceDisplayCondition).toBeUndefined();
Expand Down

0 comments on commit d6e03a2

Please sign in to comment.