CartoDB / mobile-sdk

CARTO Mobile SDK core project
https://carto.com/docs/carto-engine/mobile-sdk/
BSD 3-Clause "New" or "Revised" License
187 stars 68 forks source link

Crash while rendering Line over map on 4.2.0RC1 #281

Closed carlos-mg89 closed 5 years ago

carlos-mg89 commented 5 years ago

I've received this crash right after trying to load a Line of 7km on an Android API 28 emulator. I'm not sure if it's related or not with this https://github.com/CartoDB/mobile-sdk/issues/267 issue.

This is the error log:

2019-04-30 16:00:33.421 12888-12888/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-04-30 16:00:33.421 12888-12888/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.1.0/OSM1.180201.007/4586646:user/release-keys'
2019-04-30 16:00:33.421 12888-12888/? A/DEBUG: Revision: '0'
2019-04-30 16:00:33.421 12888-12888/? A/DEBUG: ABI: 'x86'
2019-04-30 16:00:33.421 12888-12888/? A/DEBUG: pid: 12509, tid: 12572, name: Thread-774  >>> com.walkaholic.hikeapp.debug <<<
2019-04-30 16:00:33.422 12888-12888/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
2019-04-30 16:00:33.422 12888-12888/? A/DEBUG: Cause: null pointer dereference
2019-04-30 16:00:33.422 12888-12888/? A/DEBUG:     eax 8bc125a0  ebx 91b66684  ecx 91b66684  edx 8db19000
2019-04-30 16:00:33.422 12888-12888/? A/DEBUG:     esi 00000000  edi 8bc125a0
2019-04-30 16:00:33.422 12888-12888/? A/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
2019-04-30 16:00:33.422 12888-12888/? A/DEBUG:     eip 915bfc53  ebp 8bc125d8  esp 8bc12460  flags 00010286
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG: backtrace:
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #00 pc 00330c53  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #01 pc 0032fdd3  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #02 pc 002ff00b  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #03 pc 004dfe2c  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #04 pc 0039f368  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #05 pc 0039eebe  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #06 pc 002c86d7  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #07 pc 002c826f  /data/app/com.walkaholic.hikeapp.debug-exHfeZ8b_DNe-rZk26JZFA==/lib/x86/libcarto_mobile_sdk.so (offset 0x25a000)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #08 pc 00071445  /system/lib/libc.so (__pthread_start(void*)+53)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #09 pc 000205db  /system/lib/libc.so (__start_thread+75)
2019-04-30 16:00:33.428 12888-12888/? A/DEBUG:     #10 pc 0001ec16  /system/lib/libc.so (__bionic_clone+70)
2019-04-30 16:00:34.203 1530-1530/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_04
mtehver commented 5 years ago

@carlos-mg89 Thanks for reporting this. Any chance you could make a small testcase demonstrating this? So we could reproduce it locally?

carlos-mg89 commented 5 years ago

The code is exactly the same as in https://github.com/CartoDB/mobile-sdk/issues/267

I'm trying to isolate where the issue is.

carlos-mg89 commented 5 years ago

Definitely, there's an issue with drawing a Line over the MapView. I've added only 5 MapPos objects to the MapPosVector and the crash still happens. I've commented the code, to make sure the problem is over there (in the displayTrackSegments() method) and not somewhere in my code and can confirm it.

Drawing a Point or a Marker over the map doesn't cause any issues. But drawing a Line does.

mtehver commented 5 years ago

@carlos-mg89 Thanks for the info. I think I have identified the cause - it is related to geometry simplifier. I will fix this in the next RC. Meanwhile, as a workaround you could remote the DouglasPeuckerGeometrySimplifier from your datasource or use kd-tree index with your datasource (for example, new LocalVectorDataSource(projection, LocalSpatialIndexType.LOCAL_SPATIAL_INDEX_TYPE_KDTREE))

carlos-mg89 commented 5 years ago

That worked perfectly fine :) No issues now, and I believe the results are even better than with the GeometrySimplifier.

carlos-mg89 commented 5 years ago

I'll keep it with the LOCAL_SPATIAL_INDEX_TYPE_KDTREE for the moment, however I'd like to ask, what's supposed to have a better performance, the DouglasPeuckerGeometrySimplifier or the kd-tree?

mtehver commented 5 years ago

You could use both. GeometrySimplifier helps when you have a long linestring and want to visualize it at low zoom level. kd-tree is useful if you have lots of linestrings, but only few of them are visible at once. Note that RC1 should be fine if you use simplifier with kd-tree. It crashes when you use simplifier without spatial index (which is the default behaviour).

carlos-mg89 commented 5 years ago

Thanks for the info, will use both then!

mtehver commented 5 years ago

SDK4.2.0RC2 is now out and fixes the issue, so I am closing it.

carlos-mg89 commented 5 years ago

@mtehver I can confirm it works like super great! Thanks for the quick fix :)

baneyue commented 1 year ago

When I use LineGeometry, I must use Douglas PeuckerGeometrySimplifier to sequentially extract points to improve performance, otherwise as more and more points are added, the rendering will gradually lag.

When I use PolygonGeometry, if I use Douglas PeuckerGeometrySimplifier and dynamically modify PolygonGeometry, the trajectory will flicker, and the aforementioned flicker will also occur.

Does this mean that PolygonGeometry needs to cooperate with LOCAL SPATIAL INDEX TYPE KDTREE to improve performance;

In addition, if using LineGeometry and then using LOCAL SPATIAL INDEX TYPE Can KDTREE also improve performance?

baneyue commented 1 year ago

@mtehver