izivkov/CasioGShockSmartSync

App crashes after disconnecting watch, won't open again

jrvgr opened this issue · 4 comments

jrvgr commented

Describe the bug
App crashes after disconnecting watch for the first time, crashes on open afterwards.

To Reproduce
Steps to reproduce the behavior:

  1. Connect watch.
  2. Change settings.
  3. Press button on watch to disconnect
  4. See app crash.

Expected behavior
App Shouldn't crash.

Watch:

  • G-Shock dw-b5600

Smartphone:

  • Device: Pixel 6a
  • OS: Android 14
  • Version: 10.5

Thanks for the report. I could not find a crash report on Google Play and I don't see this problem on my phone/watch.
It might me related to Android 14, I have not tried it on that. Unfortunately, emulation does not work with this app, so I could not try Android 14.

Do you mind helping narrow down the issue? If you have some time, try the following:

  1. Stop the App. Go to the Android setting, select the app and "clear storage". Restart the app and see if problem persists.
  2. If you have, try on a different phone, preferable running older version of Android.
  3. I am not sure if you are able to generate any stack-traces to see where the problem is. If not, one thing you can try is installing the app from the Google App Store (https://play.google.com/store/apps/details?id=org.avmedia.gshockGoogleSync&hl=en_CA&gl=US) and reproduce the problem. This should create a stack-trace which I can see in the play-store.
    Thanks for your help.
jrvgr commented

In the codeblock below you will find a logcat of android studio, i ran the app via debug mode and used my own steps to reproduce on my pixel 6a with android 14, i don't have another device on hand to test with sadly.

Compat change id reported: 78294732; UID 10368; state: ENABLED
Compat change id reported: 247079863; UID 10368; state: ENABLED
=============== >>>> *** Waiting for connection... ***
FineLocationPermissionGranted
isLeEnabled(): ON
could not find callback wrapper
isLeEnabled(): ON
onScannerRegistered() - status=0 scannerId=4 mScannerId=0
Installing profile for org.avmedia.gshockGoogleSync
Compat change id reported: 265103382; UID 10368; state: ENABLED
isLeEnabled(): ON
connect() - device: XX:XX:XX:XX:98:07, auto: true
registerApp()
registerApp() - UUID=2bfb4c24-850a-4e4a-9b6a-ac93def5e393
onClientRegistered() - status=0 clientIf=6
onClientConnectionState() - status=0 clientIf=6 device=C0:A7:5A:57:98:07
... Do not interrupt...
discoverServices() - device: XX:XX:XX:XX:98:07
onConnectionUpdated() - Device=C0:A7:5A:57:98:07 interval=6 latency=0 timeout=500 status=0
onSearchComplete() = Device=C0:A7:5A:57:98:07 Status=0
Discovered 4 services for C0:A7:5A:57:98:07.
Service 00001801-0000-1000-8000-00805f9b34fb
Characteristics:
|--
Service 00001800-0000-1000-8000-00805f9b34fb
Characteristics:
|--00002a00-0000-1000-8000-00805f9b34fb: READABLE
|--00002a01-0000-1000-8000-00805f9b34fb: READABLE
Service 00001804-0000-1000-8000-00805f9b34fb
Characteristics:
|--00002a07-0000-1000-8000-00805f9b34fb: READABLE
Service 26eb000d-b012-49a8-b1f8-394fb2032b0f
Characteristics:
|--26eb002c-b012-49a8-b1f8-394fb2032b0f: WRITABLE WITHOUT RESPONSE
|--26eb002d-b012-49a8-b1f8-394fb2032b0f: WRITABLE, NOTIFIABLE
|------00002902-0000-1000-8000-00805f9b34fb: EMPTY
|--26eb0023-b012-49a8-b1f8-394fb2032b0f: WRITABLE, NOTIFIABLE
|------00002902-0000-1000-8000-00805f9b34fb: EMPTY
|--26eb0024-b012-49a8-b1f8-394fb2032b0f: WRITABLE WITHOUT RESPONSE, NOTIFIABLE
|------00002902-0000-1000-8000-00805f9b34fb: EMPTY
|--26eb002e-b012-49a8-b1f8-394fb2032b0f: WRITABLE WITHOUT RESPONSE
|--26eb002f-b012-49a8-b1f8-394fb2032b0f: WRITABLE, NOTIFIABLE
|------00002902-0000-1000-8000-00805f9b34fb: EMPTY
configureMTU() - device: XX:XX:XX:XX:98:07 mtu: 517
onConfigureMTU() - Device=C0:A7:5A:57:98:07 mtu=512 status=0
ATT MTU changed to 512, success: true
setCharacteristicNotification() - uuid: 26eb002d-b012-49a8-b1f8-394fb2032b0f enable: true
onConnectionUpdated() - Device=C0:A7:5A:57:98:07 interval=36 latency=0 timeout=500 status=0
Wrote to descriptor 00002902-0000-1000-8000-00805f9b34fb | value: 0x01 00
Notifications or indications ENABLED on 26eb002d-b012-49a8-b1f8-394fb2032b0f
2023-11-01T22:10:54.370283 Wrote to characteristic 26eb002c-b012-49a8-b1f8-394fb2032b0f | value: 0x10
---> Received data 0x10 07 98 57 5A A7 C0 7F 01 03 0F FF FF FF FF 24 00 00 00
PhotoAction: orientation: BACK
PhoneDialAction
2023-11-01T22:10:54.813193 Wrote to characteristic 26eb002c-b012-49a8-b1f8-394fb2032b0f | value: 0x22
---> Received data 0x22 62 E0 77 24 1A EE E0 59 98 B4 02
connectionLayout: hide
... Can be interrupted...
MainLayout: show
OnBackInvokedCallback is not enabled for the application.
Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
2023-11-01T22:10:55.127904 Wrote to characteristic 26eb002c-b012-49a8-b1f8-394fb2032b0f | value: 0x18
---> Received data 0x18 00 0A 00 00 00 00 00 00 00 00 00 00 00 00
>>> setting watch name to CASIO DW-B5600
2023-11-01T22:10:55.326959 Wrote to characteristic 26eb002c-b012-49a8-b1f8-394fb2032b0f | value: 0x1F 00
---> Received data 0x1F 00 41 4D 53 54 45 52 44 41 4D 00 00 00 00 00 00 00 00 00
2023-11-01T22:10:55.551417 Wrote to characteristic 26eb002c-b012-49a8-b1f8-394fb2032b0f | value: 0x28
---> Received data 0x28 13 19 00 00 00 02 00 00
battery level row value: 19
Skipped 47 frames!  The application may be doing too much work on its main thread.
Davey! duration=865ms; Flags=0, FrameTimelineVsyncId=32963464, IntendedVsync=172391193565651, Vsync=172391976812191, InputEventId=0, HandleInputStart=172391982657986, AnimationStart=172391982662258, PerformTraversalsStart=172391983453111, DrawStart=172392040751125, FrameDeadline=172391276828121, FrameInterval=172391982247301, FrameStartTime=16665672, SyncQueued=172392053028591, SyncStart=172392053300360, IssueDrawCommandsStart=172392054897325, SwapBuffers=172392058841010, FrameCompleted=172392059722683, DequeueBufferDuration=12614, QueueBufferDuration=163697, GpuCompleted=172392059722683, SwapBuffersCompleted=172392059057644, DisplayPresentTime=172381859787050, CommandSubmissionCompleted=172392058841010, 
onClientConnectionState() - status=19 clientIf=6 device=C0:A7:5A:57:98:07
onConnectionStateChange: status 19 encountered for C0:A7:5A:57:98:07!
Got error 19
Disconnecting from C0:A7:5A:57:98:07
close()
unregisterApp() - mClientIf=6
connectionLayout: show
... Can be interrupted...
MainLayout: hide
onDisconnect
Not connected to C0:A7:5A:57:98:07, cannot teardown connection!
=============== >>>> *** Waiting for connection... ***
isLeEnabled(): ON
could not find callback wrapper
FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: org.avmedia.gshockGoogleSync, PID: 20671
java.lang.IllegalArgumentException: XX:XX:XX:XX:98:07 is not a valid Bluetooth address
	at android.bluetooth.BluetoothDevice.<init>(BluetoothDevice.java:1370)
	at android.bluetooth.BluetoothDevice.<init>(BluetoothDevice.java:1394)
	at android.bluetooth.BluetoothAdapter.getRemoteDevice(BluetoothAdapter.java:1087)
	at org.avmedia.gshockapi.ble.BleScannerLocal.startConnection(BleScannerLocal.kt:51)
	at org.avmedia.gshockapi.io.WaitForConnectionIO.waitForConnection(WaitForConnectionIO.kt:39)
	at org.avmedia.gshockapi.io.WaitForConnectionIO.request(WaitForConnectionIO.kt:21)
	at org.avmedia.gshockapi.GShockAPI.waitForConnection(GShockAPI.kt:75)
	at org.avmedia.gShockPhoneSync.MainActivity.waitForConnectionCached(MainActivity.kt:295)
	at org.avmedia.gShockPhoneSync.MainActivity.access$waitForConnectionCached(MainActivity.kt:48)
	at org.avmedia.gShockPhoneSync.MainActivity$run$1.invokeSuspend(MainActivity.kt:96)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4228752, Dispatchers.Default]
Sending signal. PID: 20671 SIG: 9

@jrvgr
Well, I'm not 100% sure why the app thinks "C0:A7:5A:57:98:07" is an invalid Bluetooth address. Maybe something in the latest SDK 34, for Android 14.

In any case, I am now handling this error, and the app should no longer crash. If it cannot re-use the existing address from previous connections, it will scan and connect to the watch.

If you are building from source, the latest code is checked in. You can also get the app from the play-store (https://play.google.com/store/apps/details?id=org.avmedia.gshockGoogleSync&hl=en_CA&gl=US). Make sure it is version 10.6. BTW, you can check the version by pressing the (i) in the top-right of the initial screen, and then scrolling to the bottom.

Thanks for your help.

jrvgr commented

Issue seems to be fixed, thanks for the quick support!