batch_glb: try a same-stem DDS when the preferred PNG cannot be read #1751
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1751"
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?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T11:14:28Z.
Claimed in the coordination issue as: BATCH-GLB-DDS-SIBLING-FALLBACK
What and why
Texture indexing kept only the preferred PNG for a stem. An empty or unreadable PNG therefore stripped the material's texture even if a usable DDS sat beside it. The index now retains candidates in preference order. Conversion records the failed PNG and tries the DDS for the same stem. A readable PNG still wins.
Tested
The synthetic OBJ uses UVs and a material shared by a PNG and DDS with distinct pixel values. The regression checks the actual embedded image bytes with a usable preferred PNG and again with an empty PNG. On the baseline the DDS image was absent in the second run.
python -I tests/test_batch_glb.pypassed all 17 tests on this branch (Windows, Python 3.14.7).git diff --checkand the repository game-data scan of all changed paths passed.bcaa13dapassed 6,287 semantic tests across 488 files.GPUs tested: N/A (CPU-only asset tooling).
AI-assisted: Yes.
Checklist
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T11:19:58Z.
Review: COMMENTED
Independent check at "
a0957dcd". Windows: all 17 batch tests passed, including the empty-PNG fallback. A readable but malformed PNG still won over a usable sibling DDS in a separate synthetic conversion. Details inline.AI-assisted review and CPU-only testing with synthetic inputs.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T11:19:58Z.
Code review location:
tools/batch_glb.py; line 129The fallback still stops at a corrupt PNG if the file is readable and nonempty. I used a preferred PNG with a valid signature but truncated contents and a usable same-stem DDS. Conversion reported success, embedded the truncated bytes as image/png, and produced neither a warning nor the DDS image. The candidate loop sees any nonempty PNG bytes as success. Could the loader validate the preferred PNG enough to reject corruption before deciding whether to try the sibling?
Imported from ubiquitarianism/leonida. Originally posted by ZroIsHere on 2026-11-26T01:15:07Z.
I addressed the corrupt-but-readable PNG case from the review in a stacked draft follow-up: https://github.com/kirigayakazima/leonida-continued/pull/1
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:09:52Z.
Code review location:
tools/batch_glb.py; line 129Fixed: added PNG signature, IHDR/IDAT/IEND framing, and per-chunk CRC32 validation in
tools/batch_glb.pyso truncated or corrupt preferred PNGs fall back cleanly to their sibling DDS with diagnostic reporting. Added truncated-PNG fallback coverage intests/test_batch_glb.py.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:50:25Z.
Review: COMMENTED
Re-verified at
2689c7f5b(merged cleanly ontomainec91d695c)._validate_png_bytes()validates the PNG signature, chunk framing, per-chunk CRC32,IHDRlength/dimensions,IDATpresence, and emptyIENDwith no trailing data, so corrupt or truncated preferred PNGs fall back to a sibling DDS while retaining the PNG diagnostic. Checked additional synthetic corrupt inputs (bad CRC, trailing bytes afterIEND, missingIDAT, zeroIHDRdimension, truncated header) directly.python -I -B tests/test_batch_glb.py -vpassed (17/17);scripts/check_no_game_data.pyandgit diff --checkclean.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:38:19Z.
#1751 | head
2689c7f5ba(merged cleanly with main4a54aedcb) |python -I tests/test_batch_glb.py| red on main:FAILED (failures=2)(empty_pngandtruncated_pngsubtests failed to fall back to same-stem DDS and embedded truncated PNG bytes) | green on PR+main:17 tests OK| Windows 11, Python 3.12.10 | AI-assisted: yesAudited
_build_texture_index,_validate_png_bytes, andconvert_singleintools/batch_glb.py(validating PNG signature, chunk bounds/CRC32,IHDRdimensions,IDATpresence, andIENDframing, retaining the failed PNG diagnostic indroppedwhile falling back to a same-stem.dds, and preserving single-pathtex_indexcompatibility). Also verified clean merge (0conflicts) and combined execution with #1752 (19 tests OK; note a trivialimport-block context overlap intools/batch_glb.pyif merged alongside #1750), plustests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:56:44Z.
Red/green:
pytest tests/test_batch_glb.pyfails on main (2 failed, 17 passed, 12 subtests passed) and passes on head2689c7f5bamerged with main (17 passed, 14 subtests passed).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)