-
Notifications
You must be signed in to change notification settings - Fork 22
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
NPE in moveCamera #294
Comments
In addition to the lifecycle fixes above, I intend to add a |
From a slack with @maurizi on 12/05/16:
|
Changes: - Move most initialization from onCreateView to onActivityCreated - Move getMapAsync to onResume, since it has to be there anyway, and shouldn't be done twice during initialization - Complete initialization using jDeferred promises Feats: - On first run, shows nearby locations, and goes there when you pick one - On subsequent runs, goes to most recently chosen treeMap - On entering a treeMap that covers current location, with gps on, zooms correctly to current location - Scales and pans - Selecting a plot or tree works - Getting more details for that plot or tree works TODO: - Sometimes after you select a plot/tree, you can then select another one, and sometimes it just ignores your attempts - It always ignores attempts to select a third one - Need to test filters, changing maps, logging in and out, and turning off the gps -- Connects to OpenTreeMap#294
Rollbar registered the following error: ``` java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.moveCamera( com.google.android.gms.maps.CameraUpdate)' on a null object reference at org.azavea.otm.ui.MainMapFragment.lambda$null$3 (MainMapFragment.java:488) ``` It's probably a race condition. Tame the asynchronous control flow to eliminate race conditions. AFAIK, this fixes all race conditions except open question OpenTreeMap#1 below. Unknown how many rollbar errors it will eliminate, but should eliminate the original npe. Refer to * [MapView](https://developers.google.com/android/reference/com/google/android/gms/maps/MapView) * [GoogleMap](https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap) * [MapsInitializer](https://developers.google.com/android/reference/com/google/android/gms/maps/MapsInitializer) * [GoogleApiAvailability](https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability) * [Fragment Life Cycle](https://developer.android.com/guide/components/fragments.html) Changes: - Use jDeferred to synchronize between asynchronous flows - Move most initialization from onCreateView to `onActivityCreated` - Move google api connect, map fetch, and add mode cancel to `onStart` - Update `MapHelper` to use current google availability api Open questions: 1. Need a way to manage the `MapHelper` google api dialog to determine whether the play store services problem gets resolved, and fail catastrophically if it doesn't. 2. Need a way to test missing play store services without wrecking my phone. 3. Fails to fix OpenTreeMap#297, clearing the filter repositions the camera 4. Probably shouldn't create new `Deferred` objects if they already exist, but haven't noticed any negative effects of doing so 5. I don't know enough about the tile cache to be sure when it needs to be cleared. -- Connects to OpenTreeMap#294
The motivation for this commit is when Rollbar registered the following error: ``` java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.moveCamera( com.google.android.gms.maps.CameraUpdate)' on a null object reference at org.azavea.otm.ui.MainMapFragment.lambda$null$3 (MainMapFragment.java:488) ``` It's undoubtedly a race condition, one of several. Tame the asynchronous control flow to eliminate race conditions. AFAIK, this fixes all race conditions except open question OpenTreeMap#1 below. Unknown how many rollbar errors it will eliminate, but should eliminate the original npe. Refer to * [MapView](https://developers.google.com/android/reference/com/google/android/gms/maps/MapView) * [GoogleMap](https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap) * [MapsInitializer](https://developers.google.com/android/reference/com/google/android/gms/maps/MapsInitializer) * [GoogleApiAvailability](https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability) * [Fragment Life Cycle](https://developer.android.com/guide/components/fragments.html) Changes: - Follow instructions on the Android Fragment life cycle - Follow instructions on the Google API state machine - Consolidate most initialization in `onActivityCreated` from `onCreateView` and `onResume` - Use jDeferred to synchronize between asynchronous flows - Eliminate mMap member variable in favor of the deferred. - Thanks to all of the above, eliminate checks for whether the map, the instance, and the location have been initialized - Replace `clearTileCache`, which no longer worked (OpenTreeMap#291), with `reloadTiles` - Eliminate `MainMapFragment.onHiddenChanged` - Fix pre-existing bug on Back Stack pop out of step 3 of add tree - Move some string literals used in toasts into `strings.xml` - Remove unnecessary `public` declarations - Better `Logger` messages - Use `lambda`s more extensively - Fix pre-existing bug in `TreeEditDisplay` to update the rev on the correct plot variable - Update `MapHelper` to use current google availability api -- Connects to OpenTreeMap#294
This issue relates to Rollbar #1880,
The Rollbar traceback isn't entirely clear whether the null was the
mMap
or the return value ofCameraUpdateFactory
, but it looks to me like it's probably the former.mMap
would benull
here as a result of a race condition betweenonCreateView
, where themapView
that creates themMap
is setup, and the fragmentonConnected
, where the fragment attempts to zoom to the current location. Being a race condition would explain why I am unable to reproduce it.The text was updated successfully, but these errors were encountered: