armory icon indicating copy to clipboard operation
armory copied to clipboard

Large textures crash with "outofmem" error

Open EliteMasterEric opened this issue 2 years ago • 7 comments

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

  1. Utilize a large texture (4096 pixels by 2048 pixels is the smallest I've reproduced the issue with so far) in a material.
  2. 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

EliteMasterEric avatar Jan 02 '23 04:01 EliteMasterEric

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 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 and compile a new Armorcore binary.

MoritzBrueckner avatar Jan 02 '23 13:01 MoritzBrueckner

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 my Libraries 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.

EliteMasterEric avatar Jan 16 '23 22:01 EliteMasterEric

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).

MoritzBrueckner avatar Jan 18 '23 18:01 MoritzBrueckner

Hm really need to sort this out.. will try to fix asap.

(link https://github.com/Kode/Kinc/issues/407)

luboslenco avatar Feb 03 '23 23:02 luboslenco

@luboslenco Could you please include the workaround for this issue in the upcoming release. A lot of new users face this issue.

QuantumCoderQC avatar Apr 01 '23 10:04 QuantumCoderQC

https://github.com/Kode/Kinc/issues/407#issuecomment-1492944396

luboslenco avatar Apr 01 '23 11:04 luboslenco

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.

Anniepoo avatar Nov 13 '23 11:11 Anniepoo