itinero / routing

The routing core of itinero.
Apache License 2.0
221 stars 69 forks source link

Routes fail on Android, but not iOS #174

Closed JoeCooper closed 6 years ago

JoeCooper commented 6 years ago

I have an issue where with a given routing database, Itinero works on iOS but fails on Android. I have screenshots reproduces in a simulator but the tester has reproduced this behavior and device.

I've reproduced this with Itinero 1.3.1, 1.3.2 and 1.4 pre 38.

The first screenshot here shows the exception, which has the error "Binary search using hilbert distance not possible."

screen shot 2018-03-19 at 11 44 46 am

The second screenshot here shows, on iOS, with the exact same origin and destination, that it has calculated the route just fine (it has the distance):

screen shot 2018-03-19 at 11 58 44 am

Any hint?

xivk commented 6 years ago

Hmm no, assuming you also have the same routerdb on both devices. Have you tried creating a routerdb with 1.4 and using it on android with 1.4?

In any case, what's failing on Android should also fail in iOS.

JoeCooper commented 6 years ago

It’s the same. I checked the MD5 sum to make sure there isn’t sum anomaly downloading it.

If I figure it out I’ll write back here.

On Mar 19, 2018, at 12:30 PM, Ben Abelshausen notifications@github.com wrote:

Hmm no, assuming you also have the same routerdb on both devices. Have you tried creating a routerdb with 1.4 and using it on android with 1.4?

In any case, what's failing on Android should also fail in iOS.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/itinero/routing/issues/174#issuecomment-374181579, or mute the thread https://github.com/notifications/unsubscribe-auth/AE7VAlLwFKyOoTCaxRuv-oULKf5ZC3XUks5tf5a-gaJpZM4Sv9XM.

JoeCooper commented 6 years ago

In order to step through Itinero with the debugger I cloned the repo and replaced the NuGet package with a reference to the project.

When I run it like that, it works fine. No error.

Can you confirm, is Itinero 1.3.2 on NuGet the same as the current 'master' branch of the repo?

xivk commented 6 years ago

Yes, it should match that version (the build server automatically publishes those). Perhaps there is something wrong with how I build the nuget pacakges... is it taking the netstandard to the PCL dll? What are you building? Release/debug?

JoeCooper commented 6 years ago

I can reproduce the issue with local debug builds in a sim and the release builds which are deployed to devices via HockeyApp.

The release builds are done on a different system – Bitrise – so it’s not something particular to my workstation.

When I figure it out I’ll write back here.

On Mar 22, 2018, at 2:18 PM, Ben Abelshausen notifications@github.com wrote:

Yes, it should match that version (the build server automatically publishes those). Perhaps there is something wrong with how I build the nuget pacakges... is it taking the netstandard to the PCL dll? What are you building? Release/debug?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/itinero/routing/issues/174#issuecomment-375302560, or mute the thread https://github.com/notifications/unsubscribe-auth/AE7VAhPTDg_GYgcpHCtUgAhn_LYv7VSHks5tg6TDgaJpZM4Sv9XM.

xivk commented 6 years ago

Thanks for all the detective work, I would help out more but I'm just too busy right now sorry. :+1: :+1:

JoeCooper commented 6 years ago

It seems part of it was that I had accidentally rigged up a version mismatch but with that fixed I'm getting other errors. They're seemingly random.

What do you make of this stack trace? Is it possible that it's not thread safe and I'm accidentally clobbering it somehow?

    [mono-rt] Stacktrace:
    [mono-rt] 
    [mono-rt]   at <unknown> <0xffffffff>
    [mono-rt] at(wrapper managed-to-native) System.Buffer.InternalBlockCopy(System.Array, int, System.Array, int, int) <0x00012>
    [mono-rt] at System.IO.FileStream.ReadSegment(byte[], int, int) [0x00028] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at System.IO.FileStream.ReadInternal(byte[], int, int) [0x00004] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at System.IO.FileStream.Read(byte[], int, int) [0x000a5] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at Reminiscence.IO.Streams.CappedStream.Read(byte[], int, int) [0x00039] in <91d8fc6cabd84f4d9ef32bdc007c11f1>:0
    [mono-rt] at Reminiscence.IO.Streams.CappedStream.Read(byte[], int, int) [0x00039] in <91d8fc6cabd84f4d9ef32bdc007c11f1>:0
    [mono-rt] at Reminiscence.IO.Accessors.MappedAccessorSingle.ReadFrom(System.IO.Stream, long, single&) [0x00020] in <91d8fc6cabd84f4d9ef32bdc007c11f1>:0
    [mono-rt] at Reminiscence.IO.MappedAccessor`1<single>.ReadFrom (long, single&) [0x0001f] in <91d8fc6cabd84f4d9ef32bdc007c11f1>:0
    [mono-rt]
    at Reminiscence.Arrays.Array`1<single>.get_Item (long)[0x0005e] in <91d8fc6cabd84f4d9ef32bdc007c11f1>:0
    [mono-rt]   at Itinero.Graphs.Geometric.GeometricGraph.GetVertex (uint, single&, single&) [0x0001e] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [libc] Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc2cf566c in tid 28586 (Threadpool work)
    [mono - rt] at Itinero.Algorithms.Search.Hilbert.HilbertExtensions.Distance(Itinero.Graphs.Geometric.GeometricGraph, int, uint)[0x00006] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Algorithms.Search.Hilbert.HilbertExtensions.SearchRange(Itinero.Graphs.Geometric.GeometricGraph, long, long, int, uint, uint, uint&, int&) [0x00027] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Algorithms.Search.Hilbert.HilbertExtensions.Search(Itinero.Graphs.Geometric.GeometricGraph, int, single, single, single, single) [0x00106] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Algorithms.Search.Hilbert.HilbertExtensions.Search(Itinero.Graphs.Geometric.GeometricGraph, single, single, single, single) [0x0000b] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Algorithms.Search.Hilbert.HilbertExtensions.SearchClosestEdge(Itinero.Graphs.Geometric.GeometricGraph, single, single, single, single, single, System.Func`2<Itinero.Graphs.Geometric.GeometricEdge, bool>) [0x00018] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Algorithms.Search.ResolveAlgorithm.DoRun() [0x0007c] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Algorithms.AlgorithmBase.Run() [0x00014] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.Router.TryResolve(Itinero.Profiles.IProfileInstance[], single, single, System.Func`2<Itinero.Data.Network.RoutingEdge, bool>, single) [0x000c8] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.RouterBaseExtensions.TryResolve(Itinero.RouterBase, Itinero.Profiles.IProfileInstance[], single, single, single) [0x00007] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.RouterBaseExtensions.Resolve(Itinero.RouterBase, Itinero.Profiles.IProfileInstance[], single, single, single) [0x00006] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at Itinero.RouterBaseExtensions.Resolve(Itinero.RouterBase, Itinero.Profiles.IProfileInstance, single, single, single) [0x0000f] in <8b7ce872a64d4788bed72eb0625e2936>:0
    [mono-rt] at AWTYMobile.Core.Services.MapService.GetRouteToDestination(AWTYMobile.Core.Models.PointOfInterest, int, System.Threading.CancellationToken) [0x00062] in /Users/joecooper/Projects/awty-mobile/AWTYMobile.Core.Standard/Services/MapService.cs:562
    [mono-rt]
    at AWTYMobile.Core.ViewModels.PointOfInterestViewModel/<>c__DisplayClass22_0.<GetRoute>b__0 ()[0x00000] in /Users/joecooper/Projects/awty-mobile/AWTYMobile.Core.Standard/ViewModels/PointOfInterestViewModel.cs:189
    [mono-rt]   at System.Threading.Tasks.Task`1<TResult_REF>.InnerInvoke ()[0x00011] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt]   at System.Threading.Tasks.Task.Execute ()[0x00011] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt]   at System.Threading.Tasks.Task.ExecutionContextCallback (object)[0x00006] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt]   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext, System.Threading.ContextCallback, object, bool)[0x00073] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt]   at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext, System.Threading.ContextCallback, object, bool)[0x00004] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt]   at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task&) [0x00054] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at System.Threading.Tasks.Task.ExecuteEntry(bool) [0x0005e] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() [0x00002] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at System.Threading.ThreadPoolWorkQueue.Dispatch() [0x00075] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] at(wrapper runtime-invoke) <Module>.runtime_invoke_bool(object, intptr, intptr, intptr) [0x0001f] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
    [mono-rt] /proc/self/maps:
    [mono-rt] 12c00000-12d39000 rw-p 00000000 00:04 251810     /dev/ashmem/dalvik-main space(deleted)
    [mono-rt] 12d39000-12e08000 ---p 00139000 00:04 251810     /dev/ashmem/dalvik-main space(deleted)
    [mono-rt] 12e08000-2ac00000 ---p 00208000 00:04 251810     /dev/ashmem/dalvik-main space(deleted)
    [mono-rt] 2ac00000-2ac01000 rw-p 00000000 00:04 251811     /dev/ashmem/dalvik-main space 1 (deleted)
    [mono - rt] 2ac01000-42c00000 ---p 00001000 00:04 251811     /dev/ashmem/dalvik-main space 1 (deleted)
    [mono - rt] 6f401000-6f603000 rw-p 00000000 fc:00 106514     /data/dalvik-cache/x86/system @framework@boot.art
    [mono - rt] 6f603000-6f71e000 rw-p 00000000 fc:00 106515     /data/dalvik-cache/x86/system @framework@boot-core-libart.art
    [mono - rt] 6f71e000-6f748000 rw-p 00000000 fc:00 106516     /data/dalvik-cache/x86/system @framework@boot-conscrypt.art
    [mono - rt] 6f748000-6f772000 rw-p 00000000 fc:00 106517     /data/dalvik-cache/x86/system @framework@boot-okhttp.art
    [mono - rt] 6f772000-6f774000 rw-p 00000000 fc:00 106518     /data/dalvik-cache/x86/system @framework@boot-core-junit.art
    [mono - rt] 6f774000-6f7ac000 rw-p 00000000 fc:00 106519     /data/dalvik-cache/x86/system @framework@boot-bouncycastle.art
    [mono - rt] 6f7ac000-6f7e3000 rw-p 00000000 fc:00 106520     /data/dalvik-cache/x86/system @framework@boot-ext.art
    [mono - rt] 6f7e3000-6fd9b000 rw-p 00000000 fc:00 106521     /data/dalvik-cache/x86/system @framework@boot-framework.art
    [mono - rt] 6fd9b000-6fe19000 rw-p 00000000 fc:00 106522     /data/dalvik-cache/x86/system @framework@boot-telephony-common.art
    [mono - rt] 6fe19000-6fe1f000 rw-p 00000000 fc:00 106523     /data/dalvik-cache/x86/system @framework@boot-voip-common.art
    [mono - rt] 6fe1f000-6fe2a000 rw-p 00000000 fc:00 106524     /data/dalvik-cache/x86/system @framework@boot-ims-common.art
    [mono - rt] 6fe2a000-6fe42000 rw-p 00000000 fc:00 106525     /data/dalvik-cache/x86/system @framework@boot-apache-xml.art
    [mono - rt] 6fe42000-6fe62000 rw-p 00000000 fc:00 106526     /data/dalvik-cache/x86/system @framework@boot-org.apache.http.legacy.boot.art
    [mono - rt] 6fe62000-70382000 r--p 00000000 fd:00 1033       /system/framework/x86/boot.oat
    [mono - rt] 70382000-7073d000 r-xp 00520000 fd:00 1033       /system/framework/x86/boot.oat
    [mono - rt] 7073d000-7073e000 r--p 008db000 fd:00 1033       /system/framework/x86/boot.oat
    [mono - rt] 7073e000-7073f000 rw-p 008dc000 fd:00 1033       /system/framework/x86/boot.oat
    [mono - rt] 7073f000-70bc0000 r--p 00000000 fd:00 1017       /system/framework/x86/boot-core-libart.oat
    [mono - rt] 70bc0000-70ead000 r-xp 00481000 fd:00 1017       /system/framework/x86/boot-core-libart.oat
    [mono - rt] 70ead000-70eae000 r--p 0076e000 fd:00 1017       /system/framework/x86/boot-core-libart.oat
    [mono - rt] 70eae000-70eaf000 rw-p 0076f000 fd:00 1017       /system/framework/x86/boot-core-libart.oat
    [mono - rt] 70eaf000-70f1a000 r--p 00000000 fd:00 1013       /system/framework/x86/boot-conscrypt.oat
    [mono - rt] 70f1a000-70f69000 r-xp 0006b000 fd:00 1013       /system/framework/x86/boot-conscrypt.oat
    [mono - rt] 70f69000-70f6a000 r--p 000ba000 fd:00 1013       /system/framework/x86/boot-conscrypt.oat
    [mono - rt] 70f6a000-70f6b000 rw-p 000bb000 fd:00 1013       /system/framework/x86/boot-conscrypt.oat
    [mono - rt] 70f6b000-70ff1000 r--p 00000000 fd:00 1025       /system/framework/x86/boot-okhttp.oat
    [mono - rt] 70ff1000-7104f000 r-xp 00086000 fd:00 1025       /system/framework/x86/boot-okhttp.oat
    [mono - rt] 7104f000-71050000 r--p 000e4000 fd:00 1025       /system/framework/x86/boot-okhttp.oat
    [mono - rt] 71050000-71051000 rw-p 000e5000 fd:00 1025       /system/framework/x86/boot-okhttp.oat
    [mono - rt] 71051000-7105a000 r--p 00000000 fd:00 1015       /system/framework/x86/boot-core-junit.oat
    [mono - rt] 7105a000-7105d000 r-xp 00009000 fd:00 1015       /system/framework/x86/boot-core-junit.oat
    [mono - rt] 7105d000-7105e000 r--p 0000c000 fd:00 1015       /system/framework/x86/boot-core-junit.oat
JoeCooper commented 6 years ago

Due to reasons outside of the scope of this thread, on Android my software is calling the router on two threads simultaneously, but on iOS it is not.

Outcomes are seemingly random, which is what I would expect if I had two threads clobber a system that isn't thread safe.

Is this intended to be thread safe?

xivk commented 6 years ago

No, when loading from a single stream using memory mapping it's not thread-safe. A could be to use two streams and two routerdb's. There is another issue for this somewhere but I can't seem to find it at the moment, there's more detail there.

JoeCooper commented 6 years ago

Jesus. Duh. I'll go flog myself and fix it in the morning.