-
Notifications
You must be signed in to change notification settings - Fork 19
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
android FSM sometimes gets stuck in the waiting_for_trip_start state #135
Comments
I turned on tracking manually
I left home, got a geofence transition
I launched the app to check the state - it was WAITING_FOR_TRIP_START
So I killed the app.
Both the service and the activity start back up
And I start getting location points
I verified from the UI, and the current state is ONGOING_TRIP It's pretty clear that what's happening is that the code gets to the Could it be that the connection callback is not re-invoked if the client is
|
Let's look to see when the service was created. The log has entries since
|
So maybe this primarily affects transitions from the UI. When the UI is launched, and we try multiple transitions, the same service is reused. And with the current change, we reuse the api client. So if connect() does not invoke the callback when it is already connected, that would explain it. In which case, the fix is also fairly simple - just check the connected state and call |
This does not appear to work. I relaunched a debug version of the app on the phone, with this modified code.
And ran it with the debugger, and the |
Hm, on repro, the service was created every time it worked. That's why the service was created every time. So maybe the fix from #135 (comment) would work after all. Will try to repro and see if I can get service to restart without create. Try 1
Try 2
|
Looking at the prior times when the state change did not happen, I can confirm that the service was not created.
|
Aha! a difference between the two! startId = 1 versus startId = 3.
|
quick grep shows the following restarts
|
from the docs, startId doesn't seem to mean much.
But it is fairly clear that there are restarts with multiple different IDs. Another thing to note is that several of the restarts (specially around 9:19) start with flags = 1, which corresponds to
I wonder if the restart was because I manually killed the app around 9am. But if so, why is the TripDiaryStateMachineService around for so long? And if it was a previous crash, then why did it crash and why aren't there any logs around it. |
For the record, I call
and when the service is stopped, it is destroyed, which didn't happen because we didn't get any logs around
|
So far, I can think of two potential causes - either the client was already connected or the usercache call crashed. if the cause is that the client was already connected, it can be fixed by the connected check. If it's the usercache crash, then we won't have the entry in the cache. Let's see if we do and try to distinguish between them. |
Entries are in the cache.
So it doesn't look like the service randomly crashed. I will attempt to test for a bit to see if I can repro and then just merge the changes anyway and wait to see if I can repro in the real world |
Ok, I can repro. It looks like, when I change the location tracking config, the service is created and
And after that, the service just gets restarted. However, in this case, the action is handled correctly and the service is destroyed.
|
Yup, confirmed that it was the re-config. Switched to the control screen.
Turned off.
Turned on.
Reconfigured.
Tried to stop again.
|
And finally emission crashed. Turning duty cycling back on.
It looks like the service then continuously respawns, trying to connect every time.
|
ok, so I think that it is because of this. In this case, while we are running the service, we broadcast something else, so while the receiver is handling it, it restarts the service without creating it.
|
Also, although I am able to reproduce the start without create, I am not able to reproduce the lack of connected callback. Even in the case where it crashed, we got
setting the state to start and then initializing is bad in many ways (see #115). It was basically a somewhat lazy implementation that we can fix by factoring the code and calling the same action from two places. |
If the state is tracking_stopped, don't automatically restart tracking: - if you receive an initialize (e.g. on upgrade) - if you receive a reconfigure This fixes e-mission#115. Also made some fixes to try and avoid e-mission#135, although I am not sure if they are completely fixed. In particular, - added a check for the isConnected() state and some additional logging. This is in case the reason that the transition was not handled was because the connection handler was never called. - also changed the structure so that we no longer send a broadcast from the service. This should ensure that the TripDiaryStateMachineService (duty cycled and ongoing) is never restarted. Fixed some logging as well.
While mucking with turning tracking on and off for the power measurement paper, I found that the android FSM sometimes gets stuck in the
waiting_for_trip_start
state and does not respond to any inputs. Initially, only one of the phones was in that state, but today morning, both of them were. I manually killed the process and restarted it and that fixed it for one of the phones.Need to investigate and figure out what the underlying issue is.
The text was updated successfully, but these errors were encountered: