Handle very large asset manifests
Huh, so apparently the "MiniMME11-S1: Approaching Eventide Skirt" on the Acara has 1000 layer images lol. This caused the manifest string to overflow the MySQL `TEXT` field, and fail to parse as valid JSON when loading it back for the client. I've updated the database to use `MEDIUMTEXT` instead, and added a warning message & skip behavior when the manifest size would exceed the database limit, and added graceful error handling for the invalid JSON scenario. Now, we don't crash, and the data self-repairs, and keeps in a better state in the first place! But I'm also worried about this asset, it doesn't play correctly anyway, and I'm not sure if that's an overload on our end, or just a flat problem in the JS. (There's no error message on the client, it just… loads all the layers, then shows no play button, seemingly self-satisfied.)
This commit is contained in:
parent
020ac572e4
commit
5212375c34
1 changed files with 18 additions and 1 deletions
|
@ -357,7 +357,16 @@ function convertLayerTypeToSwfAssetType(layerType) {
|
||||||
* image for this layer, it could be a supporting sprite for the JS library!)
|
* image for this layer, it could be a supporting sprite for the JS library!)
|
||||||
*/
|
*/
|
||||||
async function loadAndCacheAssetDataFromManifest(db, layer) {
|
async function loadAndCacheAssetDataFromManifest(db, layer) {
|
||||||
let manifest = layer.manifest && JSON.parse(layer.manifest);
|
let manifest;
|
||||||
|
try {
|
||||||
|
manifest = layer.manifest && JSON.parse(layer.manifest);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(
|
||||||
|
`Layer ${layer.id} has invalid manifest JSON: ` +
|
||||||
|
`${JSON.stringify(layer.manifest)}`
|
||||||
|
);
|
||||||
|
manifest = null;
|
||||||
|
}
|
||||||
|
|
||||||
// When the manifest is specifically null, that means we don't know if
|
// When the manifest is specifically null, that means we don't know if
|
||||||
// it exists yet. Load it to find out!
|
// it exists yet. Load it to find out!
|
||||||
|
@ -430,6 +439,14 @@ async function loadAndCacheAssetManifest(db, layer) {
|
||||||
// reload all the missing ones at that time.
|
// reload all the missing ones at that time.
|
||||||
const manifestJson = manifest ? JSON.stringify(manifest) : "";
|
const manifestJson = manifest ? JSON.stringify(manifest) : "";
|
||||||
|
|
||||||
|
if (manifestJson.length > 16777215) {
|
||||||
|
console.warn(
|
||||||
|
`Skipping saving asset manifest for layer ${layer.id}, because its ` +
|
||||||
|
`length is ${manifestJson.length}, which exceeds the database limit.`
|
||||||
|
);
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
const [
|
const [
|
||||||
result,
|
result,
|
||||||
] = await db.execute(
|
] = await db.execute(
|
||||||
|
|
Loading…
Reference in a new issue