armory
armory copied to clipboard
Large textures crash with "outofmem" error
Description Attempting to load large textures will reliably crash the Armory Player with the following message:
Not enough memory on image.c Buffer.
outofmem
To Reproduce
- Utilize a large texture (4096 pixels by 2048 pixels is the smallest I've reproduced the issue with so far) in a material.
- Attempt to start the game.
Expected behavior The expectation is that the large texture would load and be displayed by the game.
Large textures may be necessary in some cases, for example when using tilesheets. The largest I would expect tilesheets to be required to support is 8192x8192.
System
Blender:
Armory: 2022.12.0 (tested on release and git main
)
OS: Windows 10
Graphics card: NVidia GTX 3080
Test File BasicTexture.zip
Hi, thanks for the report! This is a known issue which I think is currently being investigated by @ luboslenco. Luckily there is a workaround:
- On static targets (HL):
Add the
#ifndef KINC_IMAGE_STANDARD_MALLOC
block to image.h like described in the linked issue, and addproject.addCDefine("KINC_IMAGE_STANDARD_MALLOC");
(don't forget theC
!) to your project's khafile.js (like described here for example). Then build the project again. - On Krom:
You need to add the
#ifndef
block described above as well, but instead of modifying the project's khafile you need to addproject.addDefine("KINC_IMAGE_STANDARD_MALLOC");
(noC
) to Armorcore's kfile.js and compile a new Armorcore binary.
Hi, thanks for the report! This is a known issue which I think is currently being investigated by @ luboslenco. Luckily there is a workaround:
* On **static targets (HL)**: Add the `#ifndef KINC_IMAGE_STANDARD_MALLOC` block to image.h like described in the linked issue, and add `project.addCDefine("KINC_IMAGE_STANDARD_MALLOC");` (don't forget the `C`!) to your project's khafile.js (like described [here](https://forums.armory3d.org/t/understanding-khafile/5118/2) for example). Then build the project again. * On **Krom**: You need to add the `#ifndef` block described above as well, but instead of modifying the project's khafile you need to add `project.addDefine("KINC_IMAGE_STANDARD_MALLOC");` (no `C`) to [Armorcore's kfile.js](https://github.com/armory3d/armorcore/blob/main/kfile.js) and compile a new Armorcore binary.
Hey, just tried this out, I wasn't able to reproduce the fix (probably due to inexperience with the engine):
- I have been using Krom for previews in the Armory Player but I don't have ArmorCore installed, I cloned the
armsdk
to myLibraries
folder and that is what I have been using. - When I add the
addCDefine
line to the project's khafile.js, then try to run the Armory Player, I see that the khafile.js gets reset, undoing my changes.
I'm afraid for Armorcore you really need a recompiled Armorcore binary until this is properly fixed. Armorcore is a Javascript engine (V8) bundled with Kinc ("Kha in C") and unlike your own source code or Armory's Haxe sources, every change in Kinc needs to be compiled before it takes effect.
But luckily, @ Naxela compiled a version of Armorcore for Windows with above workaround included: https://github.com/Naxela/custom_armorycore_bin. You should be able to use that instead, just replace <sdk-path>/Krom/Krom.exe
with the Krom.exe
from the repository :)
When I add the
addCDefine
line to the project's khafile.js, then try to run the Armory Player, I see that the khafile.js gets reset, undoing my changes.
The khafile.js is automatically generated by Armory each time you build the game, but you can append to it by creating a new text document in Blender in the text editor and selecting that text document in Armory Project > Modules > Khafile
(or Append Khafile
if you read this after https://github.com/armory3d/armory/pull/2762 has been merged).
Hm really need to sort this out.. will try to fix asap.
(link https://github.com/Kode/Kinc/issues/407)
@luboslenco Could you please include the workaround for this issue in the upcoming release. A lot of new users face this issue.
https://github.com/Kode/Kinc/issues/407#issuecomment-1492944396
As a note for users affected by this issue - I suspect a large subset of those affected are using imported Mixamo characters. These often have 4096 x 4096 textures. Reducing the size of these can cure the problem with less pain than compiling Krom.