mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
622 stars 319 forks source link

History player crash when reading large history files #2833

Open kmadsen opened 4 years ago

kmadsen commented 4 years ago

Mapbox Navigation SDK version: 1.0.0

Steps to trigger behavior

  1. Load the large sensor data history file
  2. Add this file to the examples asset folder
  3. Reference the new json file in the ReplayHistoryActivity
    1. Launch the ReplayHistoryActivity example

Actual behavior

💥 It will run out of memory

Expected behavior

The large files are loaded as a JSON string. When doing this it creates a copy in memory and causes an OutOfMemoryError

 java.lang.OutOfMemoryError: Failed to allocate a 55805472 byte allocation with 25165824 free bytes and 28MB until OOM, target footprint 196105960, growth limit 201326592

Approaches

From these approaches, uploading history files in chunks seems like the quickest solution.

cc: @mskurydin @Guardiola31337 @a-kosak-mbx

kmadsen commented 4 years ago

Here's a smaller more manageable sensor data file. windy road, would be good to test the gravity vector for these cases. device is always mounted on a motorcycle

https://firebasestorage.googleapis.com/v0/b/driver-efb37.appspot.com/o/history%2Fandroid%2F509a527ba87021d4%2F2020-04-25%2022%3A56%3A43_2020-04-25%2023%3A04%3A17_61f00e44-babe-4f0b-a2b3-923cbe71e8d37038961430442486161.json.gzip?alt=media&token=74111308-8998-40e8-b6f5-c2d7478d9cc3

kmadsen commented 4 years ago

Wondering if there is a simple way to convert json into a database so the events can parsed off disk, instead of in memory: https://medium.com/androiddevelopers/packing-the-room-pre-populate-your-database-with-this-one-method-333ae190e680