OneBusAway / onebusaway-android

The official Android app for OneBusAway
http://www.onebusaway.org/
Other
483 stars 292 forks source link

Vehicle icons remain on map after closing route mode #439

Open barbeau opened 8 years ago

barbeau commented 8 years ago

When closing out route mode, some vehicle icons still remain on the map:

image

I saw this twice last night when pulling up routes in the Washington, D.C. region, but I can't reproduce it now when browsing D.C. routes. I've also never seen this in Tampa (which I've tested heavily with), so I'm not sure if it's related to regional data or number of stops at a particular zoom level in a region.

Steps I used when I saw the problem:

  1. Tap on a stop
  2. Tap on an arrival
  3. Select "Show route on map"
  4. Tap on "X" in the route header to close out route mode and go back to viewing all stops
    • Expected behavior:

The vehicle icons for the previously selected route should be removed from the map.

The vehicle icons for the previously selected route remained on the map

Stock LG G4 w/ Android 6.0 and Google Play Services 8.7.03 (2645110-440). Using master branch at 2dc9286d96fcc34364baa405b4c64dc8c3b8b0d4, with compile 'com.google.android.gms:play-services-location:8.3.0'.

barbeau commented 8 years ago

Bumping this to milestone v2.1, as I can't currently reproduce it.

barbeau commented 8 years ago

I'm thinking this may have something to do with the number of features being shown on Google Maps, and Google Maps API v2's ability to handle a large number of features.

I did a quick random count of the number of points in route polylines for routes in different regions:

Tampa - Route 5 D/BaseMapFragment: Total points for route polylines = 668

Tampa - Route 6 D/BaseMapFragment: Total points for route polylines = 560

D.C. - Route D6 D/BaseMapFragment: Total points for route polylines = 2911

D.C. - Route R2 D/BaseMapFragment: Total points for route polylines = 2997

Puget Sound - Route 26 D/BaseMapFragment: Total points for route polylines = 870

Puget Sound - Route 424 D/BaseMapFragment: Total points for route polylines = 1350

Atlanta - Route 110 D/BaseMapFragment: Total points for route polylines = 303

Atlanta - Route 27 D/BaseMapFragment: Total points for route polylines = 178

D.C. has a much larger number of points for the route polyline that is being drawn on the map. This definitely has general performance implications, and could potentially result in some strange behavior.

I haven't studied the above route configurations carefully, but I'm guessing that the lines could be simplified to a smaller number of points without losing too much detail. This could be done server-side, or client-side.

For client-side, there is a PolyUtil.simplify() method in the android-maps-util library we can use to simplify route polylines before they are added to the map: https://github.com/googlemaps/android-maps-utils/blob/master/library/src/com/google/maps/android/PolyUtil.java#L288

barbeau commented 8 years ago

I've implemented polyline simplification using the android-maps-util library in this branch: https://github.com/OneBusAway/onebusaway-android/tree/simplifyPolylines

However, I'm seeing strange artifacts that shouldn't exist, such as the line across the middle of the route below:

image

This is with a relatively small tolerance of 2m, which shouldn't result in drastic changes to the line shape, although it does result in substantial savings on points:

D/BaseMapFragment: Polyline simplify time: 17ms
D/BaseMapFragment: Polyline simplify time: 12ms
D/BaseMapFragment: Polyline simplify time: 19ms
D/BaseMapFragment: Polyline simplify time: 23ms
D/BaseMapFragment: Polyline simplify time: 23ms
D/BaseMapFragment: Polyline simplify time: 24ms
D/BaseMapFragment: Total simplified points for route polylines = 951
D/BaseMapFragment: Total points for route polylines = 3324
D/BaseMapFragment: Polyline % savings (with tolerance of 2.0m) =  71.39%
D/BaseMapFragment: Total polyline simplify time: 121ms

There is definitely a time penalty for doing the simplification, 121ms above, as the simplification algorithm is O(n^2).

This needs a little more work before it can be merged to resolve the artifact issues with the line crossing the middle of the map - we simplify several polylines for a given route, so I'm not sure if its smaller lines that are getting messed up by simplification, or what.

I also haven't been able to reproduce this issue again, so I don't yet know if line simplification helps resolve this issue.

barbeau commented 8 years ago

I saw this problem again yesterday in the v2.0.11 beta release when looking at PSTA routes in OBA Tampa - this time, when I cleared the route header view, and selected a new route to view, the old vehicle icon from the other route stayed on the map (IIRC, when viewing a new route on the map last time the extra vehicle icon went away). I also then experienced this crash several times, which is in native code (pulled from the Android Developer Console):

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'lge/p1_spr_us/p1:6.0/MRA58K/160741805a3e8:user/release-keys'
Revision: '11'
ABI: 'arm64'
pid: 21981, tid: 22074, name: VolleyNetworkDi  >>> com.joulespersecond.seattlebusbot <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'FORTIFY: FD_SET: file descriptor >= FD_SETSIZE'
    x0   0000000000000000  x1   000000000000563a  x2   0000000000000006  x3   0000000000000000
    x4   0000000000000000  x5   0000000000000001  x6   0000000000000000  x7   0000000000000000
    x8   0000000000000083  x9   525e43451f3c3d1f  x10  7f7f7f7f7f7f7f7f  x11  0101010101010101
    x12  0000007fb593b890  x13  cbfb6b6660b6f545  x14  cbfb6b6660b6f545  x15  001d1e43c40119c9
    x16  0000007fb5935568  x17  0000007fb58c6b14  x18  0000000000000011  x19  0000007f90629500
    x20  0000007f90629440  x21  000000000000000b  x22  0000000000000006  x23  0000007f863233e0
    x24  0000007f906284c0  x25  0000007f906284d0  x26  0000007fac07dcc0  x27  0000007f90628698
    x28  00000000000009c4  x29  0000007f90628220  x30  0000007fb58c4cb8
    sp   0000007f90628220  pc   0000007fb58c6b1c  pstate 0000000020000000

backtrace:
    #00 pc 0000000000069b1c  /system/lib64/libc.so (tgkill+8)
    #01 pc 0000000000067cb4  /system/lib64/libc.so (pthread_kill+68)
    #02 pc 0000000000023b78  /system/lib64/libc.so (raise+28)
    #03 pc 000000000001e318  /system/lib64/libc.so (abort+60)
    #04 pc 0000000000021760  /system/lib64/libc.so (__libc_fatal+128)
    #05 pc 0000000000021784  /system/lib64/libc.so (__fortify_chk_fail+32)
    #06 pc 0000000000070d44  /system/lib64/libc.so (__FD_SET_chk+32)
    #07 pc 0000000000011268  /system/lib64/libjavacrypto.so
    #08 pc 000000000001a2a0  /system/lib64/libjavacrypto.so
    #09 pc 00000000037ac5c8  /system/framework/arm64/boot.oat (offset 0x2996000)

Right now my LG G4 w/ Android 6.0 has Google Play Services on the device v9.0.83 (440-121911109). OBA Android v2.0.11 has compile 'com.google.android.gms:play-services-location:8.3.0'. I'm wondering if this might be a Google Play Services issue.