rectangle-dbmi / Realtime-Port-Authority

Realtime transit tracker of Pittsburgh's Port Authority buses using the realtime PAT API using Google Maps to Display the Maps
GNU General Public License v3.0
60 stars 33 forks source link

Map/Route Display issues #179

Closed ghost closed 9 years ago

ghost commented 9 years ago

Since the last update to PAT Realtime Tracker, it has had trouble displaying maps. It usually displays either a "grid" or a blank map area (save for the word "Google" in the bottom left corner), and only rarely the maps would display. It would, however, be able to display the colored lines for the route correctly as far as I could tell (difficult without the map), and it would be able to locate and display my position.

Since last week, the map has not displayed at all, nor have any of the bus routes, and I have been unable to get it to even show the blue "current location" dot. I have 9 routes selected, only one of them does not run all day (before now, the app would correctly report that it's not available when it's not running), the others should all show during daylight hours.

Since this has started happening, the error reports have been sporadic, from cycling through the routes saying they aren't available, to reporting that either there is no Internet connection or the API call limit was exceeded, to no error messages at all.

I have already tried removing/reinstalling the PAT Realtime Tracker app, and I have even tried clearing the data for (then re-starting) the Google Maps app. I even went as far as to remove PAT Realtime Tracker, clear the data and remove updates for the Google Maps app, clearing the entire cache partition (from my phone's recovery mode), then updating & re-starting Google Maps, then reinstalling PAT Realtime Tracker -- all to no avail.

I am running Android 4.4.4 KitKat on a Motorola Moto G LTE.

In case it matters, the results above are the same regardless of whether I have the runtime set to Dalvik or ART (I did the troubleshooting described above twice -- once for Dalvik, and once for ART, in case the PAT Realtime Tracker app preferred one or the other).

It is also the same regardless of whether I use wifi or my mobile data connection (which, as my phone's name suggests, is 4G LTE, and I never burn out enough of my mobile data allotment to get bumped down to plain-old 4G).

In most of the places I go, I have a good signal (at least 3 out of 4 bars), so this shouldn't be the issue either -- even with an abysmally low signal on a 4G (i.e. non-LTE) connection, the app has worked in the past (albeit slowly with map downloads and route updates -- to be expected in that situation).

ghost commented 9 years ago

Two updates: I have tried force stopping and clearing the data for PAT Realtime tracker and selecting only one route. I got the same result described above.

Today, after leaving PAT Realtime Tracker open for awhile (about 30 minutes), the map and routes suddenly appeared and started updating normally. When I closed PAT Realtime Tracker and re-opened it, the issue reappeared.

RitwikGupta commented 9 years ago

This sounds like a Play Services issue. We have to look into this, or the new GMaps API.

epicstar commented 9 years ago

Since Google Play Services 7.x, Google has suggested a new way to load Google Maps (via another thread!!!!) using asyncmap(this) and onMapReady() from their documentation: https://developers.google.com/maps/documentation/android/ .

I never knew this until 3 weeks ago, so we've been trying to change to the new code. Changing to the new code will guarantee that Google Maps will load and that everything will be added after the maps is loaded. However, we are using an old fashioned way to also load the buses onto the map. I personally plan to move TimerTask/AsyncTask out and perhaps use somethign newer such as RxJava/RxAndroid (maybe RetroFit or even that other AOSP lib) since the previous way doesn't fit the logic of onMapReady() anymore...

However, both of us have very life-changing events going on at this time, so we have no time to do this (wait around 3-4 weeks for us to change it). We have been loading maps the previous way on the main thread, so it seems that this isn't a good idea as we've been getting a new problem of not loading maps (particularly CameraUpdate/CameraUpdateFactory not initializing bc the Google Maps aren't loading).

The app is 100% dependent Google Play Services. Google Maps shouldn't do anything to this app. I suggest to clear the data of Google Play Services 7.x and make sure you're on the most upgraded version. Keep in mind that 7.5 is coming soon for all phones so we'll be on the look out for any Google Play Services API changes relevant to the app. See how that works, but I am not positive if this will help with the app (crossing fingers it does!).

How does loading less than 9 routes react with your phone? If it helps with the situation for now, I suggest doing it, but it's obviously a very suboptimal solution.

Other than that, if you're familiar with exporting logcats, it would be great if you could give yours to us!

ghost commented 9 years ago

Clearing the data for Google Play Services (which is already latest version) causes all Google Services to flat-out stop working, and does absolutely nothing to help with this bug.

As already mentioned in my second comment above, I have already tested with just one route selected (after clearing data for PAT Realtime Tracker).

I have no idea what "logcats" are. I am more familiar with "desktop Linux" where "logcats" don't exist :-)

Have you guys considered using OpenStreetMaps instead of Google Maps/Google Play Services? Their API hasn't changes in ages and is already in use by several desktop and mobile apps (including on Android). Using an API that rarely changes might make things easier for you guys than relying on things provided by corporations that like to frequently changes stuff -- believe me, I've already been there! :-)

epicstar commented 9 years ago

Hmm....

Maybe it's the way we're saving routes that's tripping you up? We're saving the route XMLs via the app's data folder..... Or perhaps I'm missing a case where the polylines try to load before the map even loads.... That will be fixed with the new superior way of loading maps. The biggest issue with this one though is dealing with the TimerTask onResume but I think we'll be ok. Some phones don't activate onResume after leaving the app though and it's been a big issue. I guess that means we should abandon TimerTask soon...

We have no plans to change Google Maps.. The reasoning is that since Android is most exclusively an OS that is maintained by Google, Google Maps should be good, too. Plus, I've been asking random people about switching the maps, and most people would hate it if we move away from Google Maps (especially apple people for apple maps... but OSM is better than that). Plus the APIs in Google Play Services are actually really nice.

ghost commented 9 years ago

Using Google Maps excludes those who are "privacy paranoid" enough to remove/disable all the built-in Google stuff. That's something I've seriously been considering myself since the Snowden revelations: I'm not sure I feel comfortable being tracked by the government (or even just a company like Google), and the only way to avoid that is to either disable mobile data and WiFi (thus rendering apps like this unusable since they require Internet access for obvious reasons), or disable the Google stuff (again, rendering stuff unusable that require it).

Perhaps you can add an option to allow people to choose their map source for those that want to get away from Google?

epicstar commented 9 years ago

I think it would actually be an interesting idea to implement. I think we can put all of the shared tasks into a library module (parsers, bus-stop object, and whatnot) and look to share the modules between the two separate UI activities. It'd be an interesting project but personally I'd focus on the iOS version first then perhaps think about this aspect.

It's a really good suggestion.

epicstar commented 9 years ago

@ItchyDemon I encourage you to join the beta as I'll proibably have a proposed fix on Friday or Saturday....

Invite yourself here and follow the link in the description after.

epicstar commented 9 years ago

@ItchyDemon Despite earlier promises, I actually finally have the time to get the updates rolling. Please let me know (assumign you are still using our app) that the issues are fixed. You can see the changes that hopefully did the fixes here: https://github.com/rectangle-dbmi/Realtime-Port-Authority/pull/182

ghost commented 9 years ago

This seems fixed with the recent update, so I'm marking this closed.

epicstar commented 9 years ago

@ItchyDemon Thank you again for bringing the issue up! You really helped us kill a bug that has possibly affected many users and thus improved the app