Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix replay index out of bound crash #2987

Merged
merged 1 commit into from May 18, 2020
Merged

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented May 18, 2020

Description

Noticed a crash https://console.firebase.google.com/u/0/project/driver-efb37/crashlytics/app/android:com.mapbox.logistics_example/issues/e862d092872024aedf13e4613f895304?time=last-seven-days&sessionId=5EBEE08602820001515BC0625CF3D016_DNE_0_v2

Fatal Exception: java.lang.IndexOutOfBoundsException
Index: 2, Size: 2
java.util.ArrayList.get (ArrayList.java:437)
com.mapbox.navigation.core.replay.route2.ReplayRouteSmoother.smoothRoute (ReplayRouteSmoother.kt:28)
com.mapbox.navigation.core.replay.route2.ReplayRouteInterpolator.createSpeedProfile (ReplayRouteInterpolator.kt:18)
com.mapbox.navigation.core.replay.route2.ReplayRouteDriver.drivePointList (ReplayRouteDriver.kt:40)
com.mapbox.navigation.core.replay.route2.ReplayRouteMapper.mapRouteLegGeometry (ReplayRouteMapper.kt:57)
com.mapbox.navigation.core.replay.route2.ReplayProgressObserver.onRouteLegChanged (ReplayProgressObserver.kt:49)
com.mapbox.navigation.core.replay.route2.ReplayProgressObserver.onRouteProgressChanged (ReplayProgressObserver.kt:43)
  • I have added any issue links
  • I have added all related labels (bug, feature, new API(s), SEMVER, etc.)
  • I have added the appropriate milestone and project boards

Testing

I reproduced it locally and am adding a test to cover it.

  • I have tested locally (including SNAPSHOT upstream dependencies if needed) through testapp/demo app and run all activities to avoid regressions
  • I have tested via a test drive, or a simulation/mock location app
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have updated the CHANGELOG including this PR

@kmadsen kmadsen added the bug Defect to be fixed. label May 18, 2020
@kmadsen kmadsen added this to the v1.0.0 milestone May 18, 2020
@kmadsen kmadsen force-pushed the km-fix-replay-index-crash branch from e36008a to 6b669a4 Compare May 18, 2020 16:22
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -65,7 +65,7 @@ internal class ReplayRouteSmoother {
*/
private fun smoothRouteIndices(points: List<Point>, thresholdMeters: Double): List<Int> {
val smoothedRouteIndices = mutableListOf<Int>()
if (points.size <= 3) return List(3) { it }
if (points.size <= 3) return List(points.size) { it }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

@codecov-io
Copy link

Codecov Report

Merging #2987 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #2987      +/-   ##
============================================
+ Coverage     36.60%   36.62%   +0.02%     
  Complexity     2210     2210              
============================================
  Files           554      554              
  Lines         19923    19923              
  Branches       1885     1885              
============================================
+ Hits           7293     7297       +4     
+ Misses        11793    11791       -2     
+ Partials        837      835       -2     

@kmadsen kmadsen merged commit 13b2936 into master May 18, 2020
@kmadsen kmadsen deleted the km-fix-replay-index-crash branch May 18, 2020 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants