Skip to content

About

Fixed the TextureAtlas loading race condition bug that only occurs when start Minecraft client in IDE.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TextureAtlasRaceFix

修复开发环境下加载界面里图集动画与首帧渲染的竞态崩溃。

问题

开发环境(SharedConstants.IS_RUNNING_IN_IDE == true)里,加载界面阶段 TextureManager.tick() 会在第一帧渲染之前就调用 TextureAtlas.tick() 推进图集动画。此时 GlobalSettingsUniform 还没有初始化,RenderSystem.bindDefaultUniforms 不会把 Globals 绑定到渲染通道上,而渲染管线在 GlRenderPass.VALIDATION 下会对缺失的 uniform 抛:

java.lang.IllegalStateException: Missing uniform Globals (should be UNIFORM_BUFFER)
    at com.mojang.blaze3d.opengl.GlCommandEncoder.trySetup(GlCommandEncoder.java:646)
    ...
    at net.minecraft.client.renderer.texture.TextureAtlas.tick(TextureAtlas.java:251)
    at net.minecraft.client.renderer.texture.TextureManager.tick(TextureManager.java:105)

模组越多、启动越慢,动画 tick 越容易抢在首帧之前发生,所以大型整合包在开发环境里更容易踩到。

修复

TextureAtlasMixin(src/client/java/.../mixin/client/TextureAtlasMixin.java,注册在 src/client/resources/textureatlasracefix.client.mixins.json)在 TextureAtlas.tick() 头部判断 RenderSystem.getGlobalSettingsUniform() == null:为空时取消本次 tick(跳过动画推进),不为空时原版逻辑照常执行。 首帧渲染完成后动画恢复,视觉上没有差别。

只在开发环境有意义:正式发行版里 GlRenderPass.VALIDATION 为 false,原版不会抛这个异常;模组在原版环境里也不会产生副作用。

About

Fixed the TextureAtlas loading race condition bug that only occurs when start Minecraft client in IDE.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages