What are the best practices for integrating AI (like LLMs or image generation) into an MIT App Inventor project while keeping performance optimized on low-end Android devices?

Hey everyone! :wave:

I’ve been experimenting with integrating some AI features into an app I’m building with MIT App Inventor—mainly using things like language models (LLMs) for chat or small image generation previews. It’s going well in general, but I noticed the app starts lagging quite a bit on older or low-end Android phones. :sweat:

Just wondering—has anyone else tried adding AI features to their projects and run into performance issues? If so, what are your best practices for keeping things smooth? Do you offload tasks to the cloud, keep data local, compress results somehow…?

Would love to hear how others are balancing AI integration with performance optimization! :pray:

What components are you using to integrate these models, and how are you using them? Text generally shouldn't be an issue since even large amounts of text should fit into memory easily. Images can be another story. Our ImageBot component generates images 256x256 in size, and in memory each pixel will be 4 bytes wide, so one image will be 256 kB, which would be about the same memory needs as a 40-50k word essay. On lower end phones, the app might be limited to anywhere between 8MB to 32MB (my first Android phone, the Nexus One, would typically limit processes to 8 MB). At 256 kB per image and 8 MB tops, assuming the rest of the app needed 0 memory, you'd be limited to 32 images in memory at the same time. If you're generating larger images, you can do the math appropriately (every doubling of the image resolution will reduce the number of images you can fit in memory by 1/4).

If you're using third party extensions to interact with AI models, then you'd have to talk to the extension developer(s) since we cannot speak to how they are managing objects within their extensions.

1 Like

Lagging may be on a FPS/ memory or it oculd be wifi capability. Maybe it takes too long ot load