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

Add a check for missing mesh in gltf #838

Closed
wants to merge 1 commit into from

Conversation

jmiskovic
Copy link
Contributor

Provide user an error rather than crashing when trying to draw the model

Provide user an error rather than crashing when trying to draw the model
@jmiskovic
Copy link
Contributor Author

Reported here

@@ -530,6 +530,11 @@ bool lovrModelDataInitGltf(ModelData** result, Blob* source, ModelDataIO* io) {
}
}

if (model->blobCount && !model->blobs) {
Copy link
Owner

Choose a reason for hiding this comment

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

This broke all newModel calls for me, since model->blobs is always NULL here. For me, the model is importing fine but there's a crash during rendering. The vertex buffer was NULL during the vertex animation. I pushed 49e90aa to just skip vertex animation when there isn't a vertex buffer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry. I first tried to assert on model->primitiveCount but then the cleanup would crash when releasing blobs, because I did it prematurely. Your method is cleaner.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah I see. I think there is still an issue here with the error/cleanup code. Since blobCount/imageCount are set before blobs/images are assigned, if there is an error then lovrModelDataDestroy is going to try to free non-existent blobs/images. I'll see if I can improve it.

Copy link
Owner

Choose a reason for hiding this comment

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

Fixed up in 949b0ba, just need to ensure arrays exist before releasing their contents

@bjornbytes bjornbytes closed this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants