Unity LocationProvider demo crashes on iPhone
Hi, I have started to incorporate map box into a university project and quite literally all I have done is an an object to the location provider demo. However this crashes everytime when installed onto my iPhone, I have the error 'terminated due to memory issue' shown in the Xcode debugger. I have no idea what is causing the memory loss... I have done nothing to the scene.

Please can I be contacted on [email protected] if somebody has the answer. I have a university project due in just over a week and this is pivotal to it :(
Thanks
@CH196308 Hi--I'm happy to help, but I'll need some more information from you.
What iOS device are you using? What object did you add to the example scene? What are your RangeTileProvider settings? It is possible you are trying to load too many tiles at once and the meshes/textures are consuming too many resources.
What version of the SDK are you using? What version of Unity?
Thanks!
@CH196308 we had an issue with that as well, where we tried placing the start location in another part of the world, and we used the camera slippy thing. It would then proceed to start at that location, and then load tiles all the way to our location on the device, resulting in it crashing because way too many tiles get loaded. This could be the cause, hope it can help narrow down the search.
@Alexphauge Interesting. Are you able to reproduce with the latest SDK? I've never seen this before, and I also have a hard time understanding how this could happen. For example, the CameraBoundsTileProvider will remove tiles outside a certain range. When those tiles are removed, their requests are also cancelled.
@david-rhodes We're still on 1.0.0, and it was a while back. We ended up making a mix between the RangeTileProvider and the CameraBoundsTileProvider, that worked as we wanted it to work.
Though the problem at the time was (As I recall, it was a couple of months back) that we set the initial location of the MapController to e.g. Brazil (We are located in Denmark), the app would then load up everything as if we started in Brazil, and then the device GPS would kick in, and the LocationProvider would hurry back to Denmark, loading tiles along the way.
It worked on Android, though giving some crazy floating point errors (X and Z values in Unity reached crazy amounts). The tiles were also deleted, but if I remember correctly, we actually ended up crashing on iOS because of a too high number of HTTP requests. So I might have been wrong in chipping in on this thread now that I think about it. (The HTTP requests were our own doing and has since been fixed. :) )
I unfortunately do not have time to try and reproduce the error right now, but I could try at some point to create a sample project that did the thing I'm talking about above. Though, as far as I recall, it only requires you to place the MapController start location (I also inputted the LocationProvider/Editor as the same coordinates, just for completeness sakes) to somewhere on the other side of the globe of where you are. And then build the project and throw it on a device near you, so the GPS takes over from there.
Sorry for the wall of text, it's early morning here, hope it can help with something. :)
@Alexphauge Thank you for the clarification. You mentioned MapController and "a few months back," which leads me to believe this was a beta version of the SDK. At that point in time, we were not properly cancelling tile requests (for tiles that are out of view, for example).
@david-rhodes we actually just got the same problem with 1.1.0 and memory loss, it just outright crashes on iPhone for us now. @CH196308 did you ever find a solution?
@Alexphauge How are you loading a map for your location? If you are using the example BuildMapAtLocation, you're technically supposed to have the AbstractMap be disabled to begin with. As soon as you get a location update from your device, it will turn the map on and set it's lat/lon to that location. Please note that this was just a hack and the best approach would be to make a new Map implementation that simply waits for location update before building a map.
We made exactly that, we wait for locationProvider input before initializing the map. Not sure why the iPhone build crashes at all, the error was just thrown my way now by another team member.
The only thing we're certain about right now, is that it's because of something in the 1.1.0 upgrade in our project. I'll be delving into the matter for the next hour or so and again tomorrow. I'll keep you updated when I figure out more.
Well, apparently we had an implementation that did the same you guys did in the upgrade. So we created more maps and tiles on top of each other. This caused our iOS build to crash after a short while because it hugged too much memory.
Probably not the same problem as the one OP had, unfortunately.
@Alexphauge which implementation are you referring to with regards to the upgrade? Any action we need to take to help out?
No, we ended up having a script that spawned more tiles in a Start() method while the upgrade spawned in Update() as well. I've tried interfacing our classes a bit more so this shouldn't be happening again. It was entirely a fault in my code though, so no worries. Unfortunately, it doesn't help OP.
Closing for now. @CH196308 Please let us know if you can provide more details. Thank you!