Closed RobinIsTheBird closed 7 years ago
In addition to the lifecycle fixes above, I intend to add a promise
to join deferreds from the mapView.getMapAsync
and onConnected
together, and call moveToCurrentLocation
only when the joint promise completes.
Here is a gliffy diagram showing dependencies between asynchronously performed procedures.
From a slack with @maurizi on 12/05/16:
mmaurizi [2:44 PM]
it seems like the 3 events we need to wrap into promises are: the callback ofgetMapAsync
, the location services being ready, and the instance having loadedrschaufler [2:45 PM]
yes.[2:46]
Not everything requires all three, but the simplest code structure might be to just have one method that runs when all 3 are done, and not worry about excess synchronization.mmaurizi [2:46 PM]
we can't do that - there are legitimate situations where location will never be readyrschaufler [2:46 PM]
true.mmaurizi [2:47 PM]
but we can combine map ready & instance loadedrschaufler [2:47 PM]
we'd have to have a timeout that would reject location, and a variant of the DONE-DONE-DONE to deal w DONE-DONE-FAIL.[2:48]
So maybe we want 3 methods.mmaurizi [2:48 PM]
to get the best user experience, we likely want DONE-DONE (do reasonable default) - (DONE - move to GPS location / FAIL do nothing)rschaufler [2:49 PM]
async-map && instance-loaded both DONE, async-map && instance-loaded DONE and location DONE, and async-map && instance-loaded DONE and location FAIL.mmaurizi [2:49 PM]
yeah[2:50]
I don't think this planned refactor is a 1-pointer thoughrschaufler [2:50 PM]
agreedmmaurizi [2:50 PM]
Probably should happen next sprint?rschaufler [2:51 PM]
agreed. I feel I've already put in the 1-point of work to figure out what's going on.another piece of refactor - moving it all into onActivityStarted (or whatever it's called)
mmaurizi [2:52 PM]
why would we move everything there?[2:52]
I guess its as good a place as any?rschaufler [2:53 PM]
getting theMapView
requires the activity. It just happens to have worked inonCreateView
, because it just happens to already have its activity, but theonActivityWhatever
is more correct.[2:53]
onActivityConnected
? (edited)mmaurizi [2:54 PM]
onActivityCreate
?onActivityCreated
?rschaufler [2:54 PM]
something like that. Whatever it is, it comes afteronCreateView
.
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.