|     Blog    |     Wiki    |     Support

My app crashes after updating to newer ThinkGeo libs

I recently updated my mobile app from an older ThinkGeo 9.0 beta version to the newer 10.4 versions and have been seeing some of my customers getting crashes of my app due to exceptions down in the ThinkGeo.MapSuite code. It appears that a cascade of ThinkGeo calls eventually get the map in a bad state that eventually crashes my app (I’ll paste the stack traces below). Also restarting the app after a crash results in more crashes - as if the boundary files have become corrupt. So I initially did have to fix some smaller breaking changes, however we were never able to reproduce these customer errors, so we’re kind of stuck right now.

I was wondering if you can look at the stack traces and possibly explain how these errors might be caused.

Here’s the Nuget packages I currently am using:
MapSuiteMobileForiOS-BareBone 10.4.5
ThinkGeo.MapSuite 10.4.3
ThinkGeo.MapSuite.Layers.BingMaps 10.4.1
ThinkGeo.MapSuite.Layers.ShapeFile 10.4.0
ThinkGeo.MapSuite.Styles.Value 10.4.0

And here are stack traces for the errors my customers are seeing:

  1. First this exception occurs…

System.NullReferenceException: Object reference not set to an instance of an object
at ThinkGeo.MapSuite.Layers.GeoDbf.Flush () <0x10185dd80 + 0x00054> in :0
at ThinkGeo.MapSuite.Layers.GeoDbf.Close () <0x10185dc30 + 0x00067> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureSource.CloseCore () <0x1027f1d80 + 0x0003f> in :0
at ThinkGeo.MapSuite.Layers.FeatureSource.Close () <0x101842470 + 0x0005b> in :0
at ThinkGeo.MapSuite.Layers.FeatureLayer.CloseCore () <0x101887220 + 0x00037> in :0
at ThinkGeo.MapSuite.Layers.Layer.Close () <0x101835b10 + 0x0003b> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureSource.Njc= (System.String shapePathFilename, ThinkGeo.MapSuite.Layers.ShapeFileSortingMode sortingMode, System.Int32 srid) <0x1027ec350 + 0x00c8f> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureSource.Rebuild (System.String shapePathFilename, ThinkGeo.MapSuite.Layers.ShapeFileSortingMode sortingMode, System.Int32 sridForSorting) <0x1027ec300 + 0x0003f> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureSource.Rebuild (System.String shapePathFilename) <0x1027ec2d0 + 0x0001b> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureLayer.Rebuild (System.String shapePathFilename) <0x1027fb3f0 + 0x0002f> in :0
at MapShots.ThinkGeoExtensions.RunEdit (ThinkGeo.MapSuite.Layers.ShapeFileFeatureLayer layer, System.Action editFunc, System.Boolean rebuildShapeFile) <0x100b97570 + 0x00143> in :0
at MapShots.ThinkGeoExtensions.ClearAllFeatures (ThinkGeo.MapSuite.Layers.ShapeFileFeatureLayer featureLayer) <0x100b97ad0 + 0x00113> in :0
at MapShots.MainViewController.BoundaryEditClick () <0x100b465f0 + 0x0009b> in :0
at MapShots.MainViewController.MainToolBarItems_MainToolBarButtonClick (System.Object sender, System.EventArgs e) <0x100b45460 + 0x00247> in :0

  1. And then shortly after this is where the app crashes…

System.DivideByZeroException: Attempted to divide by zero.
at ThinkGeo.MapSuite.Layers.GeoDbf.FSU= (System.Byte[] arrFileHeader, ThinkGeo.MapSuite.Layers.GeoDbf dbfFile) <0x101863400 + 0x000dc> in :0
at ThinkGeo.MapSuite.Layers.GeoDbf.DiU= (System.String fileName, ThinkGeo.MapSuite.Layers.GeoFileReadWriteMode access) <0x101862100 + 0x0031f> in :0
at ThinkGeo.MapSuite.Layers.GeoDbf.Open () <0x10185dbf0 + 0x00027> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureSource.EiU= () <0x1027f18d0 + 0x0021f> in :0
at ThinkGeo.MapSuite.Layers.ShapeFileFeatureSource.OpenCore () <0x1027f16b0 + 0x00047> in :0
at ThinkGeo.MapSuite.Layers.FeatureSource.Open () <0x1018423a0 + 0x0005f> in :0
at ThinkGeo.MapSuite.Layers.FeatureLayer.OpenCore () <0x1018871d0 + 0x00037> in :0
at ThinkGeo.MapSuite.Layers.Layer.Open () <0x101835a80 + 0x00047> in :0
at ThinkGeo.MapSuite.iOS.LayerTileView.DrawCore (ThinkGeo.MapSuite.Drawing.GeoCanvas geoCanvas) <0x101e9a3f0 + 0x003b3> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.TileView.Draw (ThinkGeo.MapSuite.Drawing.GeoCanvas geoCanvas) <0x101e7da10 + 0x00027> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.LayerOverlay.DrawTileCore (ThinkGeo.MapSuite.Drawing.GeoCanvas geoCanvas, ThinkGeo.MapSuite.iOS.TileView tile) <0x101e988c0 + 0x003ff> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.TileOverlay.DrawTile (ThinkGeo.MapSuite.iOS.TileView tile, ThinkGeo.MapSuite.iOS.MapArguments mapArguments) <0x101e78aa0 + 0x0050f> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.TileOverlay.oRY= (ThinkGeo.MapSuite.iOS.MapArguments mapArguments) <0x101e7a860 + 0x0034b> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.TileOverlay.DrawCore (ThinkGeo.MapSuite.iOS.MapArguments mapArguments, ThinkGeo.MapSuite.iOS.OverlayRefreshType refreshType) <0x101e78630 + 0x001ab> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.LayerOverlay.DrawCore (ThinkGeo.MapSuite.iOS.MapArguments mapArguments, ThinkGeo.MapSuite.iOS.OverlayRefreshType refreshType) <0x101e99410 + 0x0004f> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.Overlay.Draw (ThinkGeo.MapSuite.iOS.MapArguments mapArguments, ThinkGeo.MapSuite.iOS.OverlayRefreshType refreshType) <0x101e76450 + 0x0007b> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.MapView.aBY= (ThinkGeo.MapSuite.iOS.MapArguments mapArguments, ThinkGeo.MapSuite.iOS.OverlayRefreshType refreshType, System.Collections.Generic.IEnumerable1[T] overlays) <0x101e6db60 + 0x0027b> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0 at ThinkGeo.MapSuite.iOS.MapView.ZxY= (ThinkGeo.MapSuite.iOS.OverlayRefreshType refreshType) <0x101e6d800 + 0x0031b> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0 at ThinkGeo.MapSuite.iOS.MapView.ZxY= () <0x101e6d7d0 + 0x00017> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0 at ThinkGeo.MapSuite.iOS.MapView.ZoomToCore (ThinkGeo.MapSuite.Shapes.RectangleShape extent) <0x101e6cf50 + 0x0002b> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0 at ThinkGeo.MapSuite.iOS.MapView.ZoomTo (ThinkGeo.MapSuite.Shapes.BaseShape targetShape) <0x101e6c470 + 0x0014b> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0 at ThinkGeo.MapSuite.iOS.MapView.bhY= (UIKit.UIGestureRecognizer e, System.Func3[T1,T2,TResult] action) <0x101e70d30 + 0x00a6f> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at ThinkGeo.MapSuite.iOS.MapView.b__152_2 (UIKit.UIGestureRecognizer recognizer) <0x101e727d0 + 0x00117> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at xEQ=.HBY=.60Q= (UIKit.UIGestureRecognizer recognizer) <0x101e6a9f0 + 0x00153> in <96090b69814b467aa77574140094f241#1a8e0d7664c759d2d61ed14729e75e54>:0
at UIKit.UIPinchGestureRecognizer+Callback.Activated (UIKit.UIPinchGestureRecognizer sender) <0x101038900 + 0x0002b> in :0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x101032f10 + 0x0002b> in :0
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x101032e80 + 0x00043> in :0
at MapShots.Application.Main (System.String[] args) <0x100b7be90 + 0x00093> in :0

Hi Goug,

Our developer will read related logic and see whether we can see where is the possible problem related with your exceptions.

I will reply this post if we have any update.



Thanks Ethan, and if you need any more details and/or code snippets to analyze the error, let me know.

Hi Goug,

Our developer read related logic, and tried to build a sample reproduce it, but it looks we cannot find the correct scenario to reproduce it.

It looks the first exception is because map close shape file incorrect, that’s maybe because the shape file had been closed before you manual close it, we don’t know why the reason of it, but we did some changes in our code to avoid this type exception. And your 2nd exception maybe related with the 1st one, because the only divisor variable which save the record length cannot be zero under normal conditions, so we think it won’t appear if the first exception don’t appear.

So we also have some suggestions here:

  1. If possible avoid to handle same shape file by different layers
  2. If you need to use a shape file many times, you don’t need to close it and open it often, you can just keep it’s open

If you want to test our changes, please upgrade your packages to latest development package( or higher version) which will be uploaded later.



Hi Ethan,

Thanks for the feedback and insight into my errors. So I actually solved the problem last night. It turns out that my app had a scenario where a separate thread was running some map operations on a layer and at the same time the main thread also did map operations on the same layer. And being multithreaded like this made the error only happen intermittently. But when I removed the thread and made everything synchronous (which did not impact my app’s functionality in any way), everything worked as expected. The errors I submitted were a result of the concurrent operations basically corrupting some of the shape files, and eventually bringing the app down. So my issue really isn’t a ThinkGeo problem, but just an issue with my app’s multithreading.

But thanks for your help,

Hi Goug,

Thanks for your update. In fact we are glad to get feedback from our user, so we can improve our product.

Any question please let us know.