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

Limit number of glTF validation issues #291

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
14 changes: 12 additions & 2 deletions src/tileFormats/GltfValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ const validator = require("gltf-validator");
* @internal
*/
export class GltfValidator implements Validator<Buffer> {
/**
* 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.
Expand Down Expand Up @@ -96,6 +105,7 @@ export class GltfValidator implements Validator<Buffer> {
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) => {
Expand Down Expand Up @@ -168,15 +178,15 @@ export class GltfValidator implements Validator<Buffer> {
);

for (const gltfMessage of gltfResult.issues.messages) {
//console.log(gltfMessage);
const cause =
GltfValidator.createValidationIssueFromGltfMessage(gltfMessage);
issue.addCause(cause);
}
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) {
Expand Down
Loading