cph-cachet / carp_studies_app

The CARP Study App
MIT License
6 stars 1 forks source link

Video / Image task fails #340

Open bardram opened 1 week ago

bardram commented 1 week ago

When using the image task it fails with an assertion error when clicking on the "green" save button.

image

The picture is taken but not uploaded to the database / saved in any way.

Testing on the Samsung S10e Android 12 / SDK 33 phone.

The log is:

D/InsetsSourceConsumer(26202): ensureControlAlpha: for ITYPE_STATUS_BAR on dk.cachet.carp_study_app/dk.carp.studies_app.MainActivity
I/ViewRootImpl@4526430[MainActivity](26202): ViewPostIme pointer 0
I/ViewRootImpl@4526430[MainActivity](26202): ViewPostIme pointer 1
D/ImageCapture(26202): takePictureInternal
D/CameraOrientationUtil(26202): getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=90, isOppositeFacing=true, result=90
D/TakePictureManager(26202): Issue the next TakePictureRequest.
D/Camera2CameraImpl(26202): {Camera@660f297[id=0]} Issue capture request
D/CaptureSession(26202): Issuing capture request.
D/Camera2CaptureRequestBuilder(26202): createCaptureRequest
W/AndroidMediaUtils(26202): Image_getBlobSize: No JPEG/HEIC header detected, defaulting to size=width=18289152
D/TakePictureManager(26202): Issue the next TakePictureRequest.
D/TakePictureManager(26202): No new request.
I/BpBinder(26202): onLastStrongRef automatically unlinking death recipients: <uncached descriptor>
[log] [CAMS INFO] Starting BackgroundTaskExecutor [511368468] (initialized)
[log] [CAMS INFO] Starting VideoProbe [490871400] (initialized)
[log] [CAMS DEBUG] VideoProbe - Checking permission for: [Permission.camera]
[log] [CAMS DEBUG] VideoUserTask - onPictureCapture(), media: /data/user/0/dk.cachet.carp_study_app/cache/CAP8480050397187952853.jpg
I/ExoPlayerImpl(26202): Init 709836 [AndroidXMedia3/1.4.1] [beyond0, SM-G970F, samsung, 31]
I/ViewRootImpl@4526430[MainActivity](26202): ViewPostIme pointer 0
I/ViewRootImpl@4526430[MainActivity](26202): ViewPostIme pointer 1
[log] [CAMS INFO] Stopping VideoProbe [490871400] (started)
[log] [CAMS DEBUG] VideoProbe [490871400] (stopped) - stopped
[log] [CAMS DEBUG] BackgroundTaskExecutor - all probes have stopped - stopping this BackgroundTaskExecutor too.
[log] [CAMS INFO] Stopping BackgroundTaskExecutor [511368468] (started)
[log] [CAMS INFO] Stopping VideoProbe [490871400] (stopped)
[log] [CAMS WARNING] Trying to stop a VideoProbe in a state where this cannot be done - state: 'stopped'. Ignoring this.
[log] [CAMS DEBUG] BackgroundTaskExecutor [511368468] (stopped) - stopped
I/flutter (26202): {
I/flutter (26202):  "sensorStartTime": 1729712839573329,
I/flutter (26202):  "data": {
I/flutter (26202):   "__type": "dk.cachet.carp.batterystate",
I/flutter (26202):   "batteryLevel": 37,
I/flutter (26202):   "batteryStatus": "charging"
I/flutter (26202):  }
I/flutter (26202): }
I/ViewRootImpl@4526430[MainActivity](26202): ViewPostIme pointer 0
[log] [CAMS DEBUG] SQLiteDataManager - wrote measurement to SQLite - id: 125, type: dk.cachet.carp.batterystate, device role name: Primary Phone.
I/ViewRootImpl@4526430[MainActivity](26202): ViewPostIme pointer 1
[log] [CAMS DEBUG] VideoUserTask - onSave(), file: /data/user/0/dk.cachet.carp_study_app/cache/CAP8480050397187952853.jpg
[log] [CAMS INFO] Stopping BackgroundTaskExecutor [511368468] (stopped)
[log] [CAMS WARNING] Trying to stop a BackgroundTaskExecutor in a state where this cannot be done - state: 'stopped'. Ignoring this.
[log] [CAMS INFO] AppTaskController - Marked VideoUserTask - id: f376d902-7739-4958-81bf-4b82bcd2fb0d, type: image, title: Wound Healing, state: UserTaskState.done, triggerTime: 2024-10-23 21:45:00.919767 as done

and

E/flutter (26202): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4894 pos 12: '!_debugLocked': is not true.
E/flutter (26202): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:50:61)
E/flutter (26202): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter (26202): #2      NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4894:12)
E/flutter (26202): #3      NavigatorState.push (package:flutter/src/widgets/navigator.dart:4851:5)
E/flutter (26202): #4      showDialog (package:flutter/src/material/dialog.dart:1431:65)
E/flutter (26202): #5      CameraTaskPageState._showCancelConfirmationDialog (package:carp_study_app/ui/pages/camera_task_page.dart:128:12)
E/flutter (26202): #6      CameraTaskPageState.build.<anonymous closure> (package:carp_study_app/ui/pages/camera_task_page.dart:20:13)
E/flutter (26202): #7      PopScope._callPopInvoked (package:flutter/src/widgets/pop_scope.dart:140:19)
E/flutter (26202): #8      _PopScopeState.onPopInvokedWithResult (package:flutter/src/widgets/pop_scope.dart:172:12)
E/flutter (26202): #9      ModalRoute.onPopInvokedWithResult (package:flutter/src/widgets/routes.dart:1780:16)
E/flutter (26202): #10     NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5362:19)
E/flutter (26202): #11     DisplayPicturePageState.build.<anonymous closure> (package:carp_study_app/ui/pages/display_picture_page.dart:119:59)
E/flutter (26202): #12     _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1170:21)
E/flutter (26202): #13     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:351:24)
E/flutter (26202): #14     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:656:11)
E/flutter (26202): #15     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:313:5)
E/flutter (26202): #16     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:283:7)
E/flutter (26202): #17     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:169:27)
E/flutter (26202): #18     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:505:20)
E/flutter (26202): #19     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:481:22)
E/flutter (26202): #20     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:11)
E/flutter (26202): #21     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:426:7)
E/flutter (26202): #22     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:389:5)
E/flutter (26202): #23     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:336:7)
E/flutter (26202): #24     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:305:9)
E/flutter (26202): #25     _invoke1 (dart:ui/hooks.dart:328:13)
E/flutter (26202): #26     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7)
E/flutter (26202): #27     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
bardram commented 1 week ago

There is no media file in CAWS when I download the data.

This can be caused by several things:

  1. Data is not uploaded @bardram
  2. Data is not stored @yuanchen233
  3. Data is not extracted in the export file @yuanchen233
bardram commented 1 week ago

The video task now works with the UI w/o the exception above.

However, the media is still not uploaded to CAWS. Here is the log:

[log] [CAMS DEBUG] DataStreamBuffer - getting data stream batch for device 'Primary Phone' and data type 'dk.cachet.carp.audio'.
[log] [CAMS DEBUG] DataStreamBuffer - getting data stream batch for device 'Primary Phone' and data type 'dk.cachet.carp.image'.

But neither the json or the files are in the download from CAWS.

bardram commented 1 week ago

Now the JSON and files are uploaded to CAWS. But when downloading, the filenames of the downloaded files does not match the names of the files uploaded.

Here are two audio recordings:

      "measurements": [
        {
          "data": {
            "id": "f2307b9b-e401-4014-b2c7-68e05e2ca17c",
            "__type": "dk.cachet.carp.audio",
            "upload": true,
            "filename": "f2307b9b-e401-4014-b2c7-68e05e2ca17c.mp4",
            "metadata": {},
            "mediaType": "audio",
            "endRecordingTime": "2024-10-29T19:30:46.677579Z",
            "startRecordingTime": "2024-10-29T19:30:34.778037Z"
          },
          "sensorEndTime": 1730230246677579,
          "sensorStartTime": 1730230234778037
        },
        {
          "data": {
            "id": "f2307b9b-e401-4014-b2c7-68e05e2ca17c",
            "__type": "dk.cachet.carp.audio",
            "upload": true,
            "filename": "f2307b9b-e401-4014-b2c7-68e05e2ca17c.mp4",
            "metadata": {},
            "mediaType": "audio",
            "endRecordingTime": "2024-10-29T19:30:46.677579Z",
            "startRecordingTime": "2024-10-29T19:30:34.778037Z"
          },
          "sensorEndTime": 1730230246677579,
          "sensorStartTime": 1730230234778037
        }
      ]

But the files downloaded with it looks like this

image

bardram commented 1 week ago

The file upload task seems to work fine with audio files but not image files - here is the log, where only one file upload tasks ends....?

[log] [CAMS INFO] CarpDataManager - File attachment upload to CAWS started - path : '/data/user/0/dk.cachet.carp_study_app/app_flutter/carp/deployments/b8b4bf38-5026-417f-bd2f-218fa704b4f7/data/media/073f1797-7ba0-48d7-9e9f-c9fe98250126.mp4'
[log] [CAMS INFO] CarpDataManager - File attachment upload to CAWS started - path : '/data/user/0/dk.cachet.carp_study_app/cache/CAP4387157332099287494.jpg'
[log] [CAMS DEBUG] DataStreamBuffer - cleaned up. N=11 records deleted.
[log] [CAMS INFO] CarpDataManager - File upload to CAWS finished - server id : 60

Subsequently getting TimeoutException on the upload task:

I/flutter (13522): TimeoutException - Retrying to SEND https://dev.carp.dk/api/studies/d4ed449f-eb15-443e-b768-416e50d92a80/files
bardram commented 6 days ago

Sometimes it return an HTTP error 413:

[log] [CAMS WARNING] CarpDataManager - Error uploading file attachment - 413 null

which is defined as;

A 413 HTTP error code occurs when the size of a client's request exceeds the server's file size limit. This typically happens when a client attempts to upload a large file to a web server, and the server responds with a 413 error to alert the client.