Anuken/Mindustry · error · RuntimeException
Calling getPixmap outside of createIcons is not supported!
Error message
Calling getPixmap outside of createIcons is not supported!
What it means
After createIcons finishes, Mods flushes the packer into a new atlas whose getPixmap override throws if the underlying pixmap is disposed. A disposed pixmap means the call happened outside the createIcons window where pixmaps are guaranteed live — pixel access is unsupported at runtime.
Source
Thrown at core/src/mindustry/mod/Mods.java:338
if(u.generateIcons && !c.minfo.mod.meta.pregenerated){
u.createIcons(packer);
}
}
});
}
waitForMain(() -> {
whitePixmap[0].dispose();
whiteTex[0].dispose();
//replace old atlas data
Core.atlas = packer.flush(filter, new TextureAtlas(){
@Override
public PixmapRegion getPixmap(AtlasRegion region){
var other = super.getPixmap(region);
if(other.pixmap.isDisposed()){
throw new RuntimeException("Calling getPixmap outside of createIcons is not supported!");
}
return other;
}
});
textureResize.each(e -> Core.atlas.find(e.key).scale = e.value);
Core.atlas.setErrorRegion("error");
Log.debug("Total pages: @", Core.atlas.getTextures().size);
packer.printStats();
Events.fire(new AtlasPackEvent(packer));
packer.dispose();
Log.debug("Total time to pack and generate sprites: @ms", Time.timeSinceMillis(startTime));View on GitHub (pinned to f695ad7e60)
Solutions
- Read all pixel data you need inside createIcons() and cache the result.
- Never call getPixmap in render/update/init-after-load paths.
- If you need runtime pixels, ship a separate texture you control.
Example fix
// before (runtime, throws)
PixmapRegion px = Core.atlas.getPixmap(Core.atlas.find("my-block"));
// after (during createIcons)
@Override
public void createIcons(MultiPacker packer) {
cached = packer.get("my-block").pixmap.copy(); // cache for later
} Defensive patterns
Strategy: validation
Validate before calling
// Only touch pixmaps during createIcons; cache what you need.
if(pixmapRegion.pixmap.isDisposed()) {
throw new IllegalStateException("Pixmap accessed after disposal; read during createIcons only.");
} Type guard
boolean pixmapLive(PixmapRegion r){ return r != null && !r.pixmap.isDisposed(); } Prevention
- Read and cache pixel data inside createIcons().
- Avoid Core.atlas.getPixmap() in runtime/render paths.
- Ship separate runtime textures if you need pixels later.
When it happens
Trigger: Code calls Core.atlas.getPixmap(region) after the atlas flush, when pixmaps have been disposed to save memory.
Common situations: Mod reads pixel data at runtime (e.g. for collision/procedural effects) instead of during createIcons; calling getPixmap in update/render loops.
Related errors
- Max image size exceeded
- No constructor set up for unit '{name}', add this argument t
- Mod is not loaded yet (or missing)!
- Failed to load image {file} for mod {mod.name}
- Error loading mod {mod.meta.name}
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/9ecf2816cba3550c.
Report an issue: GitHub.