Google map crashes in iOS7

We are developing a hybrid application, and we use the google map APIs in our application. When we try to load 2000 data markers on the map, it crashed. The card does not get into iOS6, iOS5. This only happens on iOS7. Is there any memory related change for ios7 app.

+42
ios7 google-maps
Sep 12 '13 at 8:38 on
source share
11 answers

As already mentioned, iOS7 is more strict with memory usage. This behavior is observed in other browsers, such as Chrome, so when the application reaches the upper limit in memory usage, an accident occurs.

I highlighted two test cases using only the Gmaps javascript and jQuery APIs:

Testing with 100 markers: all right

http://jsfiddle.net/edfFq/6/embedded/result

Testing with 3000 Markers: Crashing

http://jsfiddle.net/edfFq/7/embedded/result/

$(document).ready(function () { var map; var centerPosition = new google.maps.LatLng(40.747688, -74.004142); var options = { zoom: 2, center: centerPosition, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map($('#map')[0], options); for (var i=0;i<2800;i++){ var position = new google.maps.LatLng(40*Math.random(),-74*Math.random()); var marker = new google.maps.Marker({ position: position, map: map }); } }); 

You may crash with fewer markers if your map uses: tags, custom badges, and clusters.

+13
Sep 27 '13 at 13:21
source share

Having experienced similar issues with Google Maps, I tried to isolate a minimal test case. I wanted to see if this was perhaps the more general memory management issue.

This code, which simply stores random data in an array, splits Safari on iOS 7 on iPad mini, 16GB:

 function randomString(length, chars) { var result = ''; for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; return result; } var arr = [] for (var i=0;i<5000;i++) { // one character is two bytes in JavaScript, so 512 chars is 1Kb: o = randomString(512, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); arr.push(o); } 

You can try this test with your own browser by going to http://vici.org/memtest.html . The script on this page will try to request 50 MB of memory in 1 MB increments. The script shows the work counter, so you will see how well your browser works and when it will work (if that happens). The script stores the results for each ip / user agent combination in the database to be able to draw some conclusions.

On average, iOS 6 (n = 12) allows a script to require about 12 MB. IOS 7 (n = 47) allows the script to require about 15 MB. It is not hard. For both sets, the standard deviation was quite high, ~ 12 Mb. The Xcode Safari emulator doesn't even crash at all (requesting a full 50Mb, probably because it has access to more RAM).

So, we can conclude that the problem is not caused by the fact that iOS 7 leaves less memory for Safari. It seems that the problem, as Philip Kuhn suggested, is in some specific cases? - Safari consumes significantly more memory than in iOS 6. One key to this reason can be found at https://discussions.apple.com/message/23837361#23837361 , where there is a page with 200 divs and the following CSS

 div { -webkit-backface-visibility: hidden; } 

resets safari.

Using the Leaflet library seems to work around the map issue (see https://code.google.com/p/gmaps-api-issues/issues/detail?id= and https://github.com/Leaflet/Leaflet/ pull / 2149 ), however Leaflet circumvented low memory losses, not javascript level changes, but not css changes. The flyer now circumvents provisions like

 context = this 

This means that Safari does not clear unused objects. While Apple is not fixing Safari, is it possible that Google can make changes similar to what the guys from Leaflet did?

At the same time, Apple released the IOS7.1 version, which does not fully resolve crashes, but, of course, makes them common.

+8
Sep 18 '13 at 12:03
source share

We have a web application that also contains many tokens on iOS7. Therefore, we carefully examined the memory of the iPad.

iPad mini (and iPad3) with iOS7:

Memory usage is getting higher and higher and between 300-400 MB browsers.

iPad 3 with iOS6

Memory usage is around 200 MB, and everything is in order.

iPad 1 with iOS5

Memory usage is only about 100 MB, and everything is in order.

Conclusion

So, this is NOT just a memory limit - it is definitely a huge bug on iOS safari! And so far (iOS 7.0.3) this has not been fixed.

+7
Oct 23 '13 at 18:09
source share

Good news! we switched our application infrastructure from google to a flyer, and it works beautifully, without failures, we checked the debug version and it works with extremely high memory, but it never crashes. If you’re not already in the Flyer, it works fully on iOS 7,

+4
Nov 20 '13 at 15:29
source share

Our application behaved the same as the users above; everything went well until iOS 7, but then collapsed. The problem is really a memory problem. You can check by checking the crash report logs on your device.

Since our application was important for the client, we could not sit and wait for the fix from Apple. In our case, the fix included three specific strategies:

  • JavaScript code optimization. Our application was developed very quickly and evolved from a prototype to a working system without advanced code planning. In our system, we were able to realize significant memory gains through code optimization. This meant removing unused variables; note if you manage to save all tokens into a pre-array as a response from your database. Delete these old arrays and unused variables when everything is loaded successfully. Also, consider the limitation of included libraries and use common Javascript / jQuery optimization methods.

  • Empty info windows. The next strategy for saving memory came from NOT preloading each window of the data marker information window. We split each info window naked, except for an empty div with a unique identifier, which will then be loaded asynchronously when Ajax is clicked. Saving from many thousands of markers, when you take all this unnecessary information, the window data was quite large. We loaded about 10,000 markers. The user was not much affected either because the preload difference and the Ajax boot time were negligible.

  • The biggest difference, and perhaps a hint about where iOS 7 memory leak is, is simply reducing the number of markers displayed on the screen at the same time. Each application will be different, but we found that lowering the results to 500 markers or less led to the creation of a stable system without failures. Our strategy was to simply load and clear an array of visible markers based on user behavior. For example, if a custom filter selection resulted in more than 500 markers, we simply limited the results from the database. Visually, the result set still seems large, and does not differ much from the prospect of using users, seeing many thousands of markers. In both situations, the user will still need to filter and narrow the results to a manageable result. In our case, the user would not even notice the limit.

This is a trick! Our application is now without failures. Considering the amount of time (not to mention disappointment!), This question has aroused me, I hope these strategies will give you the opportunity to jump from the spot to get your application back and work. Feel free to contact if you want something more specific. Good luck

+3
Dec 16 '13 at 19:58
source share

I believe that IOS7 has 5 MB of memory (longer battery life), it was 50 MB or something like that. Since the cap is limited to the OS, it doesn’t matter if you use Chrome, Safari or other browsers, it will crash if it is exceeded.

i checked my data limit on 20 from SQL and it works in all browsers on my iphone (pad).

0
Sep 22 '13 at 14:08
source share

I had the same problem and tried several things. I turned off the animation when the markers were set (I had about 30 added at the same time), and it looks like it no longer breaks. Hope this helps.

0
Sep 25 '13 at 19:57
source share

We have the same issue with shortcuts on google map. When the map zooming in the application will be broken. This happened after upgrading to iOS 7. I am trying to use various options, such as removing and adding labels in events such as drag and drop and idle. This code works, but it still crashes. but less often. Hope someone can better fix this.

  google.maps.event.addListener(Map.gmap, 'drag', function () { $('.arrowSite_box').remove(); // remove labels }); google.maps.event.addListener(Map.gmap, 'idle', function () { loadMarkers(results); // add labels }); 
0
Sep 30 '13 at 14:27
source share

If you are dealing with a large number of markers, try using MarkerClusterer . This will significantly reduce the number of parallel markers, and in our case it will prevent a crash.

0
Jan 27 '14 at 19:49
source share

Hey ... I also ran into a similar problem. So, I tried this:

I cleared the application caches in the "didReceiveMemoryWarning" method of my controller and user plugins and set the properties and variables to NIL in the "onMemoryWarning" method of the CDVPlugin class. And this approach did the job for me. At the moment, I am not getting a crash. Hope this helps.

0
Mar 03 '14 at 16:30
source share

Seems fixed in iOS 7.1

Yesterday on iOS 7.0.6, my map crashed Mobile Safari with over 3,000 markers. Today, after updating my iPad, I can upload a map to Mobile Safari with over 15,000 markers.

0
Mar 11 '14 at 20:06
source share



All Articles