glTF 2.0 export fails with NaN float value from specific shape key #104989
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#104989
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: win10
Graphics card: n/a
Blender Version
Broken: 3.6.5
Worked: unknown
Short description of error
__fix_json(obj) fails at line 114 at int(obj) where obj is a float but with a NaN value, but what float exactly is a complete mistery here since there is zero tracking and no exception catching, to log what part this exception occurred in.
More exact trigger was found after hours of brute force narrowing down, eventually finding that at least shape key "じと目" in this .blend mesh will trigger the stack dump as follows;
Exact steps for others to reproduce the error
load the attached .blend and export > glTF 2.0 with the default settings, it should quickly dump the stack in the console
edit; "EyeSquintRight" also seems to be another shape key that will trigger it
There's a similar report from NaN in mesh data over at https://github.com/KhronosGroup/glTF-Blender-IO/issues/1446.
It looks like
Mesh.validate()
doesn't validate shape keys though, so NaN in a shape key can produce the error seen here.Note than NaN values in model data usually indicate a bug in the steps used to create the model. If you can track down exactly which step caused some values to be set to NaN, then please either report that to Blender or the addon responsible.
In this case, both the
じと目
andEyeSquintRight
shape keys of themesh.003
Mesh have a bunch of NaN values on the model's whiskers, backs of the eye balls and the quad inside the chest.This script will go through all meshes in the .blend file and find any NaN values in shape keys. I included a few lines of code that can be uncommented by removing the
#
to either select the vertices or to effectively reset the shape key indices that have NaN values.Hello,
So the question is: Should I/O manage these check on their own, or should consistency of mesh be centralized by mesh module (by extension of validate() to shape keys?
well we can break this down into 4 parts;
1; bug-0, the origin of the NaN values, however I have no clue where this bug exists and this model was not made by me, so for now we just have to ignore this
2; sanity, blender at no point catches that NaN values exist in any of the shape keys, nothing is ever logged and manually editing the shape keys fails to show or change any abnormalies
3; export safety, at no point does exporting check for sanity, this possibly affects more than just glTF as other formats I have exported to also seem to be corrupted in different ways, but I have not fully confirmed this
4; glTF export lacks exception catching to log at what point exactly something has failed and why, this is the big one since the user is completely unable to figure out why this stack dump even occurs, unless they so happen to also be a python coder and can edit the export script directly
extra 5th point; the blender UI does not work well during this, the mouse cursor becomes corrupted, blender itself locks up for a while, and then the python stack dump flashes on screen for only one frame and dissappears, but I expect this is already reported
It seems good to extend mesh validate to include shape keys too. But I would also expect exporters/importers to be robust to NaN values, and either preserve them or set them to zero.
Here is the PR for glTF exporter.
https://github.com/KhronosGroup/glTF-Blender-IO/pull/2045/files
Will apply it to main, as we are close to 4.0 release, and this is not a regression
That's a bit knew to me... so far official position afaik was that NaN values in meshes was data corruption/bug, and we never expected exporters to be resilient to these (iirc we still have these NaN values creeping in UV maps sometimes too, which breaks FBX exporter e.g.)?
Built-in Blender operators don't crash or stop working on NaN values, I would expect operators in add-ons to do the same. The result might not be as expected, but they can still output something.