-
Notifications
You must be signed in to change notification settings - Fork 319
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
Route tile download #1559
Route tile download #1559
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1559 +/- ##
===========================================
- Coverage 22.75% 22.56% -0.2%
- Complexity 689 694 +5
===========================================
Files 182 189 +7
Lines 8102 8230 +128
Branches 599 606 +7
===========================================
+ Hits 1844 1857 +13
- Misses 6075 6190 +115
Partials 183 183 |
During local testing, I run into the following 💥
Nexus 5 - Android 6.0 Also I want to note that we're not requesting the location updates after granting the permissions - there's no location icon in the status bar as shown above. |
@Guardiola31337 can you put that in a separate ticket? That looks unrelated to anything in this PR. |
I brought this up because it's working in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devotaaabel this is looking great! 👍 I left some comments for updates / questions that we can discuss.
One thing I noticed regarding the test app, it seems the app isn't currently aware of changes from settings when resuming. So going from online to offline results in no route found:
I think this is due to the offline router being created as null
during initialization:
@@ -452,6 +454,11 @@ private void generateFeatureCollectionList(List<DirectionsRoute> directionsRoute | |||
// Each route contains traffic information and should be recreated considering this traffic | |||
// information. | |||
for (int i = 0; i < directionsRoutes.size(); i++) { | |||
|
|||
Timber.d("DirectionsRoutes.size " + directionsRoutes.size()); | |||
Timber.d("direction route " + directionsRoutes.get(i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove these logs?
CONFIGURE_ROUTER_RESULT_SUCCESS(true), CONFIGURE_ROUTER_RESULT_FAILURE(false); | ||
|
||
private final boolean success; | ||
Status(boolean success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the success
boolean needed here? It seems you may be able to infer success or failure based on the Status
value itself.
...ain/java/com/mapbox/services/android/navigation/v5/navigation/OfflineRouteRetrievalTask.java
Outdated
Show resolved
Hide resolved
*/ | ||
void routesFound(List<DirectionsRoute> routes); | ||
|
||
void onError(OfflineData offlineData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We renamed this to RouteFoundCallback
but it looks like the the error callback here is specific to offline with OfflineData
. Are we using this callback anywhere that isn't for an offline purpose? (necessitating the change to a more generic name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's being used here https://github.com/mapbox/mapbox-navigation-android/blob/devota-route-tile-download/app/src/main/java/com/mapbox/services/android/navigation/testapp/example/ui/navigation/ExampleRouteFinder.kt#L46 I think for consistency and being able to implement one callback for both online and offline routes it is nice to have one for both, maybe we could also put RouteFoundCallback
here? https://github.com/mapbox/mapbox-navigation-android/blob/devota-route-tile-download/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationRoute.java#L79 But about the OfflineData
, I'd like to talk about that, so we can hopefully come to a consensus about the best way to track errors, that was just my first attempt at an error reporting object.
.../src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxOfflineRouter.java
Outdated
Show resolved
Hide resolved
NavigationLibraryLoader.load(); | ||
} | ||
|
||
TileUnpacker() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to pass the Navigator
created in the MapboxOfflineRouter
to the RouteTileDownloader
and then ultimately here in the TileUnpacker
?
*/ | ||
void unpack(File src, String destPath, UnpackUpdateTask.ProgressUpdateListener updateListener) { | ||
Log.d("source path", "" + src.getAbsolutePath()); | ||
Log.d("dest path", "" + destPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove these logs?
...ion/src/main/java/com/mapbox/services/android/navigation/v5/navigation/UnpackUpdateTask.java
Outdated
Show resolved
Hide resolved
long size = tar.length(); | ||
|
||
while (tar.length() > 0) { | ||
publishProgress((((tar.length() / size)) * 100)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the published progress here is either 0
or 100
- was this expected behavior?
@Guardiola31337 said he had some ideas about a buffer to monitor this? @kevinkreiser any ideas what the issue is with monitoring the tar unpacking? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im going to take a stab at fixing this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devotaaabel this is looking good - some questions and comments to discuss 👍
.../src/main/java/com/mapbox/services/android/navigation/v5/navigation/ConfigureRouterTask.java
Outdated
Show resolved
Hide resolved
* can be called safely. | ||
*/ | ||
public void initializeOfflineData(String tilesDirPath, OnOfflineDataInitialized callback) { | ||
offlineNavigator.configure(tilesDirPath, callback); | ||
public void initializeOfflineData(String version, OnOfflineDataInitialized callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment / question
Have we considered using initializeData
instead of initializeOfflineData
? We're in the context of MapboxOfflineRouter
so adding Offline
sounds redundant to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 I actually think configureRouter
would make the most sense here, because you are configuring it be ready to use the version you specified. Do we know why we went with initializeData
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devotaaabel yeah! In that case I'd name it configure
(initialize
also could work) because we're in the context of MapboxOfflineRouter
, no need to add Router
again IMO.
@@ -33,8 +48,17 @@ public void initializeOfflineData(String tilesDirPath, OnOfflineDataInitialized | |||
* @return the offline {@link DirectionsRoute} | |||
*/ | |||
@Nullable | |||
public void findOfflineRoute(@NonNull OfflineRoute route, | |||
OfflineRouteFoundCallback callback) { | |||
public void findOfflineRoute(@NonNull OfflineRoute route, RouteFoundCallback callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here re: Offline
redundancy
.../src/main/java/com/mapbox/services/android/navigation/v5/navigation/MapboxOfflineRouter.java
Outdated
Show resolved
Hide resolved
...ion/src/main/java/com/mapbox/services/android/navigation/v5/navigation/OfflineNavigator.java
Outdated
Show resolved
Hide resolved
...main/java/com/mapbox/services/android/navigation/v5/navigation/OnOfflineDataInitialized.java
Outdated
Show resolved
Hide resolved
private final Navigator navigator; | ||
|
||
static { | ||
NavigationLibraryLoader.load(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is re-loading NN unnecessarily because it's already done when instantiating OfflineNavigator
which happens when creating a MapboxOfflineRouter
. I guess it's safe to remove it here.
|
||
@Override | ||
protected File doInBackground(String... strings) { | ||
navigator.unpackTiles(strings[0], strings[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't navigator.unpackTiles
be synchronized
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 nope I asked, @kevinkreiser said it can be considered a static method
outputStream.flush(); | ||
return file; | ||
|
||
} catch (IOException exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're currently catching IOException
twice 👇 I believe that's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 the finally
block throws an IOException
public class DownloadTask extends AsyncTask<ResponseBody, Void, File> { | ||
|
||
private static final int END_OF_FILE_DENOTER = -1; | ||
private static int instructionNamingInt = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we considered making instructionNamingInt
non static
?
* fix progressUpdateListener for tile unpacking * lint
…-navigation-android into devota-route-tile-download
…-navigation-android into devota-route-tile-download
…-navigation-android into devota-route-tile-download
Amazing work here @devotaaabel, this was no small effort. Huge milestone for the SDK 🚀 |
I second that. Kudos @devotaaabel |
I am still implementing changes we talked about including the update to navigator
3.4.3
, adding better error reporting, and changing the public API to not includeRoutingTileDownloadManager
and instead add astartDownload
method inMapboxOfflineRouter
. Also going to add some simple unit tests.