Repository navigation
fix: v3 OpenGL 纹理文件缺失或无法解码时段错误 - #149
Merged
Arkueid merged 1 commit intoOct 18, 2026
Merged
Conversation
OpenGL 路径的 CreateTextureFromPngFile 未检查 LoadFileAsBytes / stbi_load_from_memory 的返回值:文件不存在时以 NULL 指针和未初始化的 size 调用 stbi,直接 0xC0000005 退出, 且无任何报错。补上与 Vulkan 路径一致的检查并返回 NULL,SetupTextures 跳过失败的纹理。 Refs EasyLive2D#148
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
live2d.v3(OpenGL 后端)加载模型时,如果model3.json中引用的纹理文件不存在,进程会直接以0xC0000005退出,没有任何 Python 异常或错误日志。由于 stdout 缓冲在崩溃时丢失,最后看到的日志停在load motion: ...,看起来像是动作加载后崩溃,与 #148 描述的现象一致。原因
LAppTextureManager::CreateTextureFromPngFile(OpenGL 版)没有检查返回值:LoadFileAsBytes返回NULL时,size未初始化,随后stbi_load_from_memory(NULL, <垃圾值>)读空指针 → 段错误png == NULL,width/height未初始化,仍会被传给glTexImage2DVulkan 版本已经有这两处检查,OpenGL 版本缺失。
修改
CreateTextureFromPngFile:补上与 Vulkan 版一致的检查,LOGE后返回NULLModel::SetupTextures:纹理创建失败时跳过,不再解引用空指针测试
Windows 11 / Python 3.11 / CsmSDK 5-r.5,本地源码编译:
[E] couldn't load texture file: ...,模型正常加载、绘制[E] couldn't decode texture image: ...,正常继续tests/test_model_json.py:38 passed(另 1 个 error 为既有问题:辅助函数test(fn)被 pytest 当作测试收集,与本 PR 无关)。Refs #148 —— 这能把 #148 的静默崩溃变成明确的报错;是否就是该模型的具体原因,还需要原作者确认纹理路径。