polarofficial / polar-ble-sdk

Repository includes SDK and code examples. More info https://polar.com/en/developers
Other
488 stars 155 forks source link

`listOfflineRecordings` doesn't list all recordings #491

Open metuuu opened 1 month ago

metuuu commented 1 month ago

Platform on which you observed the bug:

Device on which you observed the bug:

Describe the bug Listing sensor measurements might return only single item even though there are multiple recordings. After the first recording is removed from the sensor, then polar ble sdk returns the other item. I have not find a reason for this or a way to reproduce this consistently.

I had this issue happening 2/3 of the time but in the next day it stopped and never happened for me again. After I released our app to testing, our tester had the same issue where he described that approximately every 1/3 recording is missing ACC. And after the recording is removed from sensor then the ACC appears. The recordings were approx 10min - 1h long. (When I had the issue, the recording time didn't affect the outcome. I tested 10sec - 10min recordings)

How to Reproduce

  1. Start PPI+ACC or PPG+ACC recordings with Verity Sense.
  2. Wait a moment and stop both recordings
  3. List recordings -> only one of the two or both recordings are returned
  4. If only one of the two recording was returned, delete the returned recording (If both were returned, repeat until only single one is returned)
  5. List recordings -> now the missing recording should appear

Expected behavior All recordings should be returned when listing offline recordings

The code used in our app for listing the offline recordings

    @SuppressLint("CheckResult")
    @ReactMethod
    fun listOfflineRecordings(callback: Callback) {
        if (deviceId == null) return callback.invoke("No device connected")
        api!!.listOfflineRecordings(deviceId!!)
            .observeOn(AndroidSchedulers.mainThread())
            .doOnSubscribe { offlineRecordingEntries = mutableListOf() }
            .subscribe(
                { offlineRecordingEntries!!.add(it) },
                { error ->
                    if (error is PolarOperationNotSupported) {
                        callback.invoke(ERROR_FEATURE_NOT_SUPPORTED, deviceId)
                    } else {
                        Log.d(TAG, "list offline recording failed: " + throwableToString(error))
                        callback.invoke(throwableToString(error), deviceId)
                    }
                },
                {
                    val result = Arguments.createMap()
                    val entriesArray = Arguments.createArray()
                    offlineRecordingEntries!!.forEach { entry ->
                        val entryMap = Arguments.createMap()
                        entryMap.putString("type", entry!!.type.name.lowercase())
                        entryMap.putDouble("size", entry.size.toDouble())
                        entriesArray.pushMap(entryMap)
                    }
                    result.putArray("entries", entriesArray)
                    callback.invoke(null, result)
                }
            )
    }
samulimaa commented 3 weeks ago

Hi, thanks for reporting this, we have created internal ticket to fix this on upcoming releases.

metuuu commented 3 weeks ago

Thank you! Were you able to reproduce the issue?

samulimaa commented 3 weeks ago

We are working on it.