-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Race condition in toKtx.ts #1366
Comments
Thanks @mramato! Within the tmp directory, gltf-transform will generate a UUID (unique to the I wasn't aware that Asides – In the longer term, I'd like to avoid having a CLI dependency involved in KTX compression at all. Long discussion and open questions: You may also find it's faster to do batch processing using a glTF Transform based script rather than the glTF Transform CLI – initializing the CLI session many times has significant overhead. The |
Thanks for the quick reply, @donmccurdy.
That's good to know and makes me way less worried about my current hacked together POC actually working. I can just create the gltf-transform top-level folder at startup.
I was not aware of this, and that is awesome. I will definitely look at going this route. I was doing a quick and dirty POC for KTX in this case, but we actually already use |
Thanks again, @donmccurdy! |
Describe the bug
toKtx.ts checks if a directory exists before creating it, resulting in a crash/race condition when multiple instances of gltf-transform are run simultaneously. The offending line is:
glTF-Transform/packages/cli/src/transforms/toktx.ts
Line 152 in 46a7405
I'm also skeptical of gltf-transform always using the same tmp folder across all processes, since it seems like file name collision could be a real problem.
To Reproduce
Steps to reproduce the behavior:
$tmp/gltf-transform
does not exist.gltf-transform etc1s in.glb out.glb
many times concurrentlyerror: EEXIST: file already exists, mkdir '/tmp/gltf-transform'
(since this is a race condition it's not 100%).Expected behavior
Versions:
Additional context
In general, it's bad practice to check for an existence of an external resource before using it, specifically because of race conditions like the above. While I'm not intimately familiar with the source, the simple fix should be to remove the if check and use
recursive: true
, which will handle the "create if not exist" logic correctly for us.As I mentioned above, I'm also concerned a well known tmp dir name is always used (gltf-transform) because this means that multiple processes could stomp on each other. Should it create a random name each time (using randomUUID perhaps?)
The text was updated successfully, but these errors were encountered: