CurryKitten / CurryKitten-Sim

FPV quad simulator
70 stars 7 forks source link

Reduce memory footprint on iOS/Android for 0.56b mobile release #100

Closed CurryKitten closed 2 years ago

CurryKitten commented 2 years ago

Although the 0.56b version of the sim runs well on my Android tablet, I noticed it was crashing on my iPhone XR when loading the Valley level, despite running fine on the XR simulator.

Running from Xcode with debug, I can see we are hit with a memory usage warning and then -

Failure Reason: Message from debugger: Terminated due to memory issue

Which is interesting given that the simulator runs it fine - and I'm assuming that my Android tablet is fine because it has more RAM than the iPhone. In which case I need to reduce the memory footprint on the levels in order for them to be able to run on a wider range of devices.

Right now I can see from the debugger in the iPhone Sim than the original level runs with around 821MB in use, the City Level takes around 1.15GB and the Valley level around 1.75GB. The iPhone XR has 3GB of memory - so quite why it's hitting the memory warning limit is a bit of a mystery, but if I can bring the usage down to the City level at least it should make things work better. The City has already been optimised through it's texture usage - which I'm assuming is the issue with the Valley level, but I'll investigate via memory profiling to see what's causing the problems.

CurryKitten commented 2 years ago

I managed to get the Valley level down to around 1.3GB RAM usage by resampling the textures (by quite a margin). This means that we do need a platform with 3GB to run either the City or Valley level, the original level will work on phones with 2GB of RAM. Whilst I did consider thinking about doing lighter weight levels, a quick straw poll of friends with Android phones told me that 8GB seems quite standard now with the lowest one we could find having 4GB of RAM. iPones are in a similar situation with my XR being 4 years old and having 3GB of RAM, the more up to date iphone all have 4GB of RAM or more, so I donn't think there's many people on 2GB of RAM out there - and if they are on budget phones then odds are they aren't going to get very good performance here anyway.