Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large textures crash with "outofmem" error #2746

Open
EliteMasterEric opened this issue Jan 2, 2023 · 7 comments
Open

Large textures crash with "outofmem" error #2746

EliteMasterEric opened this issue Jan 2, 2023 · 7 comments
Labels
bug This issue describes a bug has workaround This issue has a known workaround

Comments

@EliteMasterEric
Copy link

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 EliteMasterEric added the bug This issue describes a bug label Jan 2, 2023
@MoritzBrueckner
Copy link
Collaborator

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.

@EliteMasterEric
Copy link
Author

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.

@MoritzBrueckner
Copy link
Collaborator

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 #2762 has been merged).

@luboslenco
Copy link
Member

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

(link Kode/Kinc#407)

@QuantumCoderQC
Copy link
Contributor

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

@luboslenco
Copy link
Member

Kode/Kinc#407 (comment)

@Anniepoo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a bug has workaround This issue has a known workaround
Projects
None yet
Development

No branches or pull requests

5 participants