istornz / iPokeGo

A native iOS client to map the Pokemon around you!
https://github.com/RocketMap/RocketMap
MIT License
642 stars 168 forks source link

Crashing #205

Closed blackhattristar closed 8 years ago

blackhattristar commented 8 years ago

The app seems to be crashing every so often on initial launch and sometimes a minute after being open. Unfortunately I can't debug the crash on initial launch because it only happens once the app is installed. Has any one else noticed this?

markvl91 commented 8 years ago

If you have pokestops enabled this is very possible. A fix in the meantime is not enabling pokestops.

blackhattristar commented 8 years ago

@markvl91 I have noticed that as well. What about if PokéStops are not activated? Have you had this issue?

markvl91 commented 8 years ago

I honestly haven't, and I'm scanning a ridiculous amount of pokemon. Then again, I'm using an iPhone 6s, it might be hardware related?

blackhattristar commented 8 years ago

@markvl91 I'm using an iPhone 6 Plus. I've had some other people mention they had the same issue but I didn't ask what device they were running on.

blackhattristar commented 8 years ago

I just noticed that if I turn the Gyms feature off, the app does not crash. Gym feature and PokéStops feature are off and the app does not crash. It actually isn't "crashing" per say. When you double tap the home button the app is still open. It just opens and then hides itself.

AcidicSkittles commented 8 years ago

I found the root of the problem. Was crashing for me with certain gyms nearby.

* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 9 beyond bounds [0 .. 8]'***

GymAnnotation.m:

NSArray *gymLvl     = @[@2000, @4000, @8000, @12000, @16000, @20000, @30000, @40000, @50000];
int gym_level = 1;
while (gym.points >= [gymLvl[gym_level - 1] integerValue]) {
     gym_level++;
}

specifically, in the [gymLvl[gym_level - 1] integerValue] part of the while loop. The gym object printed out a points (gym.points) value of 52,000 which was causing the index out of bounds crash. 52000 >= 50000 causing the loop to go past the last index of gymLvl.

Not sure what the fix is, but maybe we just need more @60000, @70000, @80000, etc. values in the gymLvl array? I added more values like that and the crash went away.

vasilywang commented 8 years ago

Not sure how many levels gym has, the following code fixed this issue while (gym_level <= gymLvl.count && gym.points >= [gymLvl[gym_level - 1] integerValue]) { gym_level++; }