diff --git a/CHANGES.md b/CHANGES.md index 805ca7ce..03e361d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,8 @@ +Version ?.?.? - yyyy-mm-dd + +- The maximum number of issues that are reported for a single glTF asset is now limited (via [#291](https://github.com/CesiumGS/3d-tiles-validator/pull/291)). + Version 0.5.0 - 2023-10-24 - Added validation of glTF extensions via [#280](https://github.com/CesiumGS/3d-tiles-validator/pull/280) and [#284](https://github.com/CesiumGS/3d-tiles-validator/pull/284). In addition to the basic validation of glTF tile content that is performed with the glTF validator, the 3D Tiles Validator now checks the validity of certain glTF extensions: diff --git a/src/tileFormats/GltfValidator.ts b/src/tileFormats/GltfValidator.ts index c2502138..93a6c8af 100644 --- a/src/tileFormats/GltfValidator.ts +++ b/src/tileFormats/GltfValidator.ts @@ -18,6 +18,15 @@ const validator = require("gltf-validator"); * @internal */ export class GltfValidator implements Validator { + /** + * The maximum number of issues that should be reported by + * the glTF validator. For large glTF assets that contain + * "completely invalid" data, a large number of issues + * can cause out-of-memory errors. + * See https://github.com/CesiumGS/3d-tiles-validator/issues/290 + */ + private static readonly MAX_ISSUES = 1000; + /** * Creates a `ValidationIssue` object for the given 'message' object * that appears in the output of the glTF validator. @@ -96,6 +105,7 @@ export class GltfValidator implements Validator { try { gltfResult = await validator.validateBytes(inputWithoutPadding, { uri: uri, + maxIssues: GltfValidator.MAX_ISSUES, externalResourceFunction: (gltfUri: string) => { const resolvedDataPromise = resourceResolver.resolveData(gltfUri); return resolvedDataPromise.then((resolvedData: any) => { @@ -168,7 +178,6 @@ export class GltfValidator implements Validator { ); for (const gltfMessage of gltfResult.issues.messages) { - //console.log(gltfMessage); const cause = GltfValidator.createValidationIssueFromGltfMessage(gltfMessage); issue.addCause(cause); @@ -176,7 +185,8 @@ export class GltfValidator implements Validator { context.addIssue(issue); } - // XXX TODO Find a sensible place to hook in glTF extension validators + // When the glTF itself is considered to be valid, then perform + // the validation of the Cesium glTF metadata extensions const extensionsValid = await GltfExtensionValidators.validateGltfExtensions(uri, input, context); if (!extensionsValid) {