There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
Performance. Disk writes when navigating to the details page.
I believe there is potential for improving the performance of navigating to the details page.
Namely, at the end of the method DetailsPage_Loaded in class DetailsPage, the most recent
15 routes are written to disk. This includes, for each route, all the stops in that route (which
may be many, e.g., 82, 102, 108 in my tests) and a list of PolyLine (which has 3,4,6 elements
in my tests).
This looks wasteful, because DetailsPage_Loaded and these writes are on the critical path of
loading the details page. E.g., if I put a Thread.Sleep of 30 seconds near these writes (or in
DetailsPage_Loaded), the DetailsPage stops loading, and the phone screen just shows a
green background, with no data on it.
The applications does not seem to use these writes (i.e., read them back from disk) right
away, since the same data is already in memory. Also, to simplify implementation, this data
supports some imprecision: it may be all right for the most recent routes (saved to disk)
to be slightly imprecise in very rare cases (e.g., tombstoning while writing to disk).
Would it be more efficient to do these writes to disk in parallel, in another thread?
I.e., not on the critical path of loading the details page?
“viewModel.AddRecent(recent);” is called at the end of method DetailsPage_Loaded() in
class DetailsPage. AddRecent() calls AddFavorite() in class AppDataModel. AddFavorite()
in class AppDataModel calls WriteFavoritesToDisk(), which calls serializer.WriteObject(),
which writes the object to disk.
The written objects are a list of FavoriteRouteAndStop. The filed routeStops in class
FavoriteRouteAndStop is a RouteStops object, which has a list List<Stop> stops of all
the stops, which may have many elements (e.g., 82, 102, 108 in my tests).
This behavior (saving all stops in a route) happens when in the Routes pivot I push the
routes in the list. It does not happen when in the Stops pivot I push the stops in the list.
For the stops in the stops list in pivot Stops, the field routeStops is null, and thus there
is no list List<Stop> stops to save.