CompanyGateways / mytracks

Automatically exported from code.google.com/p/mytracks
1 stars 0 forks source link

Widget crashes when touching it a second time #515

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add the home screen widget
2. Touch it to start recording
3. Touch it again

What is the expected output? What do you see instead?
It should stop recording. Instead, it crashes.
After the crash, touching it another time just crashes again.

Stack trace:
07-13 21:14:55.280: ERROR/AndroidRuntime(16013): java.lang.RuntimeException: 
Unable to start service 
com.google.android.apps.mytracks.services.TrackRecordingService@405264c0 with 
Intent { act=com.google.android.apps.mytracks.START_NEW_TRACK flg=0x10000000 
cmp=com.google.android.maps.mytracks/com.google.android.apps.mytracks.services.T
rackRecordingService bnds=[24,401][104,493] (has extras) }: 
java.lang.IllegalStateException: A track is already in progress!
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2052)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.app.ActivityThread.access$2800(ActivityThread.java:117)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:994)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.os.Looper.loop(Looper.java:130)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.app.ActivityThread.main(ActivityThread.java:3683)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
java.lang.reflect.Method.invokeNative(Native Method)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
java.lang.reflect.Method.invoke(Method.java:507)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
dalvik.system.NativeStart.main(Native Method)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013): Caused by: 
java.lang.IllegalStateException: A track is already in progress!
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.startNewTrack(Tr
ackRecordingService.java:549)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.handleStartComma
nd(TrackRecordingService.java:291)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.onStartCommand(T
rackRecordingService.java:275)
07-13 21:14:55.280: ERROR/AndroidRuntime(16013):     at 
android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2039)

Original issue reported on code.google.com by rdama...@google.com on 14 Jul 2011 at 12:18

GoogleCodeExporter commented 9 years ago
This is very odd.  I will bring out some older devices to try to repro.  This 
works fine on my nexus s.  I think that the service should throw an exception 
in this state.  It seems like the widget has the wrong pending intent set but I 
don't know how that would happen.  Did the arrow change color for you?

Original comment by sandordo...@google.com on 28 Jul 2011 at 3:49

GoogleCodeExporter commented 9 years ago
I was also able to reproduce this but had to double tab on the widget to do so. 
When I reproduced this issue the arrow does not change colors but the arrow 
icon gets added the status bar but disappears after pressing "Force Close" on 
the error. Any more taps I do on the widget and I get the error again. I have 
to open MyTracks and press stop for the widget to work again.

Also anther path I found to reproduce the issue but a very unlikely use case is:
1. Start recording from MyTracks itself.
2. Added widget to home screen. (After adding the arrow is orange instead of 
red)
3. Press on the arrow on the added widget.

I have added my log as an attachment.

I'll see if I can fix this issue. If anyone as started a fix or has any 
pointers of where a catch should be done for this thrown exception it would be 
helpful.

Thanks.

Original comment by jKas...@gmail.com on 23 Sep 2011 at 5:27

Attachments:

GoogleCodeExporter commented 9 years ago
So it seems like two intents get fired.  The first goes through but the second 
must fail.  The precondition it is failing seems pretty reasonable to me.  IE a 
normal start track should fail if one is already going.  Perhaps we could 
introduce an extra on the start track intent which made the operation 
idempotent. Maybe failOnActive track.  If the value is present and false then 
the service would silently trap the exceptions.

Original comment by sandordo...@google.com on 26 Sep 2011 at 4:14

GoogleCodeExporter commented 9 years ago
Thanks for your help. Saw the multiple intent getting sent but was hoping there 
was a way to catch the exception within the widget. Sent an extra with the 
intent like you suggested.

https://code.google.com/r/jkasten-mytracks2/source/detail?r=eecee1d5ee78181dde64
624f05a79d814d1c8e55

Thanks.

Original comment by jKas...@gmail.com on 28 Sep 2011 at 1:08

GoogleCodeExporter commented 9 years ago
The final revision LGTM.

Jimmy you want to pull this in?

Original comment by sandordo...@google.com on 28 Sep 2011 at 3:59

GoogleCodeExporter commented 9 years ago

Original comment by jshih@google.com on 29 Sep 2011 at 2:53