Skip to content

GLTF: Duplicate extensions at the start of the import and export process#116789

Open
aaronfranke wants to merge 1 commit intogodotengine:masterfrom
aaronfranke:gltf-duplicate-doc-ext
Open

GLTF: Duplicate extensions at the start of the import and export process#116789
aaronfranke wants to merge 1 commit intogodotengine:masterfrom
aaronfranke:gltf-duplicate-doc-ext

Conversation

@aaronfranke
Copy link
Member

This PR was made in response to multi-threading concerns from @lyuma regarding multiple GLTFDocument instances accessing the same GLTFDocumentExtension classes.

@aaronfranke aaronfranke added this to the 4.7 milestone Feb 26, 2026
@aaronfranke aaronfranke requested a review from a team as a code owner February 26, 2026 03:02
@aaronfranke aaronfranke force-pushed the gltf-duplicate-doc-ext branch 2 times, most recently from 7eb38da to 021d58e Compare March 7, 2026 21:24
Copy link
Contributor

@lyuma lyuma 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, just want to move the duplicate a bit earlier to completely avoid any possible of thread safety issues

We should update the line of the documentation in GLTFDocumentExtension.xml to explain that GLTFDocumentExtension instances are duplicated at the beginning of a parse or export.

err = ext->import_preflight(p_state, p_state->json["extensionsUsed"]);
if (err == OK) {
document_extensions.push_back(ext);
document_extensions.push_back(ext->duplicate());
Copy link
Contributor

Choose a reason for hiding this comment

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

do the duplicate before, so import_preflight is also thread safe. They are refcounted, so they will be easily deleted if they are not used.

Error err = ext->export_preflight(state, p_node);
if (err == OK) {
document_extensions.push_back(ext);
document_extensions.push_back(ext->duplicate());
Copy link
Contributor

Choose a reason for hiding this comment

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

do the duplicate before the export_preflight

@aaronfranke aaronfranke force-pushed the gltf-duplicate-doc-ext branch from 021d58e to 89741d5 Compare March 7, 2026 21:26
@aaronfranke aaronfranke requested a review from a team as a code owner March 7, 2026 21:26
Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

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

This looks great. Approved in meeting

@aaronfranke aaronfranke force-pushed the gltf-duplicate-doc-ext branch from 89741d5 to f205173 Compare March 7, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants