mapbox / mapbox/mapbox-navigation-android
OOM exception building really long routes
Nessuno ha ancora preso questa issue.
- Lingua principale
- Kotlin
- Stelle
- 651
- Fork
- 321
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**Android API:any
**Mapbox Navigation SDK version:1.4.0
Steps to trigger behavior
- Build long route (thousand of kimoleters)
- App crashes randomly, depending on memory of the device.
Crash happens within DirectionsJsonObject at GSON serialization with the following stacktrace :
E/AndroidRuntime(11384): java.lang.OutOfMemoryError: Failed to allocate a 3690812 byte allocation with 2202366 free bytes and 2MB until OOM
E/AndroidRuntime(11384): at java.lang.String.<init>(String.java:400)
E/AndroidRuntime(11384): at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:633)
E/AndroidRuntime(11384): at java.lang.StringBuffer.toString(StringBuffer.java:723)
E/AndroidRuntime(11384): at java.io.StringWriter.toString(StringWriter.java:100)
E/AndroidRuntime(11384): at com.google.gson.Gson.toJson(Gson.java:639)
E/AndroidRuntime(11384): at com.google.gson.Gson.toJson(Gson.java:618)
E/AndroidRuntime(11384): at com.mapbox.api.directions.v5.models.DirectionsJsonObject.toJson(DirectionsJsonObject.java:30)
E/AndroidRuntime(11384): at com.mapbox.navigation.navigator.internal.MapboxNativeNavigatorImpl$setRoute$2.invokeSuspend(MapboxNativeNavigatorImpl.kt:150)
E/AndroidRuntime(11384): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(11384): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(11384): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(11384): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(11384): at java.lang.Thread.run(Thread.java:818)
From my analysis reason is that nav native implementation accepts route as a single string thus fails if string becomes really large.
While possible solutions are to pass some Json/Route object entity instead of string, temporary workaround returning some error instead of throwing an exception from background thread would also be nice.
cc @mapbox/navigation-android @mskurydin
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/DirectionsJsonObject.java e dalla relativa chiamata a toJson, quindi segui MapboxNativeNavigatorImpl$setRoute$2 alla riga 150. Riproduci il problema con un percorso lungo migliaia di chilometri e controlla come il percorso viene passato come un’unica stringa; la modifica dovrebbe impedire l’OutOfMemoryError nel thread in background oppure restituire un errore.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, kotlin
- Ambito
- mobile-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100