mapbox / mapbox/mapbox-navigation-android

Main thread lag and skipped frames when mapboxNavigation.startTripSession() called

Open
#4,111 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug jira-sync-complete
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

This issue occurs in our code, Ive provided a stripped down version of this issue on the following github link.

**Android API:** 21
**Mapbox Navigation SDK version:** 1.4.0
**Code:** https://github.com/JustinmClapperton/mapboxAndroidTest
**Example:** https://youtu.be/t0DjKnAMDN8

(You will need to add your own Mapbox API key to gradle.properties and strings.xml)
video:

### Steps to trigger behavior

1. Run the app
2. Try to drag the map around and watch for skips

### Expected behavior
App performs smoothly with no lag on the main thread. LocationEngineRequest Params should be respected

### Actual behavior
App performs incredibly slow with several skipped frames on the main thread. No matter what I set the following code snippet too updates still happen less than every second, this could likely be part of the lag I'm experiencing.
```
LocationEngineRequest request = new LocationEngineRequest.Builder(10000L)
.setFastestInterval(5000L)
.setDisplacement(1)
.setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY)
.build();
```

### Logs
```I/pboxandroidtes: Background concurrent copying GC freed 257365(7031KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 6932KB/12MB, paused 501us total 159.422ms
I/pboxandroidtes: Background concurrent copying GC freed 259824(6913KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7027KB/12MB, paused 301us total 146.792ms
I/Choreographer: Skipped 48 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 256244(6982KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7006KB/12MB, paused 322us total 135.444ms
I/Choreographer: Skipped 45 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 259217(6978KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7196KB/13MB, paused 333us total 160.829ms
I/Choreographer: Skipped 47 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 271095(7222KB) AllocSpace objects, 0(0B) LOS objects, 45% free, 7318KB/13MB, paused 1.486ms total 163.121ms
I/pboxandroidtes: Background concurrent copying GC freed 269248(7251KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7011KB/12MB, paused 237us total 135.379ms
I/Choreographer: Skipped 45 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 259356(6983KB) AllocSpace objects, 0(0B) LOS objects, 47% free, 6891KB/12MB, paused 305us total 151.584ms
I/Choreographer: Skipped 46 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 258053(6855KB) AllocSpace objects, 0(0B) LOS objects, 45% free, 7301KB/13MB, paused 481us total 165.290ms
I/pboxandroidtes: Background concurrent copying GC freed 270151(7256KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7004KB/12MB, paused 398us total 141.638ms
I/Choreographer: Skipped 46 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 259398(6968KB) AllocSpace objects, 0(0B) LOS objects, 47% free, 6900KB/12MB, paused 320us total 156.619ms
I/pboxandroidtes: Background concurrent copying GC freed 257282(6864KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7028KB/12MB, paused 381us total 139.903ms
I/Choreographer: Skipped 47 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 256008(6948KB) AllocSpace objects, 0(0B) LOS objects, 47% free, 6864KB/12MB, paused 2.410ms total 141.356ms
I/Choreographer: Skipped 46 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 252915(6819KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7005KB/12MB, paused 422us total 135.958ms
I/Choreographer: Skipped 45 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 265328(7078KB) AllocSpace objects, 0(0B) LOS objects, 45% free, 7383KB/13MB, paused 526us total 190.145ms
I/pboxandroidtes: Background concurrent copying GC freed 272371(7317KB) AllocSpace objects, 0(0B) LOS objects, 46% free, 7105KB/12MB, paused 332us total 143.023ms
I/Choreographer: Skipped 46 frames! The application may be doing too much work on its main thread.
I/pboxandroidtes: Background concurrent copying GC freed 263058(7078KB) AllocSpace objects, 0(0B) LOS o```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked mapboxAndroidTest reproduction and add the required API key in gradle.properties and strings.xml. Run the app on Android API 21, call startTripSession(), drag the map, and compare the skipped-frame logs with the LocationEngineRequest settings. Done means the map remains responsive and the requested location update parameters are respected.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.