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

Cache ion endpoints #442

Merged
merged 11 commits into from
Mar 10, 2022
Merged

Cache ion endpoints #442

merged 11 commits into from
Mar 10, 2022

Conversation

joseph-kaile
Copy link
Collaborator

Fixes #382

@@ -60,6 +60,9 @@ struct Tileset::LoadIonAssetEndpoint::Private {
assert(false);
});
}

static std::unordered_map<std::string, std::shared_ptr<IAssetRequest>>
endpointCache;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't hold onto the IAssetRequest instance like this. The problem is that IAssetRequest is implemented by cesium-native's client (e.g. Cesium for Unreal or O3DE or whatever) and may (probably does) hold some of the client's resources hostage. For example, maybe there's a limit on the number of requests that can exist at once, and these requests will count against that limit. Or maybe it's really important that request resources be released before, say, the HTTP module shuts down, but we can't do that if a static field is keeping them alive.

So it may be possible to just cache the parts of the request/response that are needed. Or, if necessary, you can even create another class that implements IAssetRequest and store instances of that class in the cache instead. We do something similar in CachingAssetAccessor.cpp.

@joseph-kaile
Copy link
Collaborator Author

Getting errors with the last commit. I will investigate.

LogCesium: Error: [2022-02-17 17:24:52.660] [error] [Tile.cpp:427] Received status code 401 for tile content https://assets.cesium.com/1/18/108845/188938.terrain?v=1.2.0&extensions=octvertexnormals-metadata
LogCesium: Error: [2022-02-17 17:24:52.660] [error] [Tile.cpp:427] Received status code 401 for tile content https://assets.cesium.com/1/18/108844/188938.terrain?v=1.2.0&extensions=octvertexnormals-metadata
Copy link
Member

@kring kring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @joseph-kaile! Very minor comments below.

We should also extend this mechanism IonRasterOverlay, which has a nearly identical situation. But it can be a separate PR.

tileset.getExternals().pCreditSystem->createCredit(
html->value.GetString()));
endpointAttribution.html = html->value.GetString();
endpoint.attributions.push_back(endpointAttribution);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly cleaner / more performant to do:

AssetEndpointAttribution& endpointAttribution = endpoint.attributions.emplace_back();
endpointAttribution.html = html->value.GetString();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip.

*/
bool updateContextWithNewToken(
TileContext* pContext,
std::optional<std::string> GetNewAccessToken(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use camelCase for function names.

Suggested change
std::optional<std::string> GetNewAccessToken(
std::optional<std::string> getNewAccessToken(
@kring
Copy link
Member

kring commented Mar 10, 2022

Thanks @joseph-kaile!

@kring kring merged commit a91987a into main Mar 10, 2022
@kring kring deleted the cache-ion-endpoints branch March 10, 2022 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants