flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
9.29k stars 913 forks source link

Does flame support large size images? #26

Closed wonsuyon closed 5 years ago

wonsuyon commented 5 years ago

I tested 3000px x 4000px 1MB png x 100 files in /assets/images. and

void main() async { .... await Flame.images.loadAll(list); }

40 images loaded but over 50 failed out of memory. (3g ram device) android:largeHeap="true" didn't help.

Do you have any solutions?

(actually i need 1MB x 500 images..)

datayeah commented 5 years ago

That is not an issue with flame, it's more an issue with your architecture. A "loaded" png is always stored uncompressed in your devices memory, so your images will never fit in 3GB of ram. With or without flame.

luanpotter commented 5 years ago

I agree with @datayeah , maybe you should consider splitting your sprite sheet into several bits? Then you can load one bit per level, that is, I'm assuming you don't use the entirety of your enormous sprite sheets at the same time!

Or, you could compress your image, using jpg or some sort of loss-y compression algorithm.

Otherwise, there is simply no solution; you could load all sprites on demand, but your game would be slow as heck, because you'd need to reload files from the disk every render tick. 3 GB ram devices are pretty standard, AFAICT, so I would definitely not recommend this last approach. But the first two seem pretty viable.

wonsuyon commented 5 years ago

Thank you. The tinyPNG helps and the Flame works fine with no delay for the 40MB loading. But at this moment i need Unity instead..

luanpotter commented 5 years ago

I'm glad it worked out! If there is any feature missing from flame that you'd like to use, please feel free to open an issue or even contribute with a PR! It'd be really neat if we provided everything you need. Best regards!