Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
910 stars 199 forks source link

onImageForAnalysis prevents video recording on iOS #421

Open Parfyonator opened 6 months ago

Parfyonator commented 6 months ago

Steps to Reproduce

Add onImageForAnalysis callback to example app. It can be as simple as

onImageForAnalysis: (image) async {
  print('######################');
  print(image.toInputImage());
  print('######################');
}

Expected results

Video is recorded and available for playback after pressing the "Stop" button.

Actual results

I get the following error in logs

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(VIDEO_ERROR, video is not recording, , null)
#0      CameraInterface.stopRecordingVideo (package:camerawesome/pigeon.dart:983:7)
<asynchronous suspension>
#1      VideoRecordingCameraState.stopRecording (package:camerawesome/src/orchestrator/states/video_camera_recording_state.dart:87:20)
<asynchronous suspension>

I cannot stop video recording due to this error.

About your device

Brand Model OS
Apple iPhone 11 17.1.1

Your flutter version

Flutter 3.13.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision d211f42860 (6 weeks ago) • 2023-10-25 13:42:25 -0700
Engine • revision 0545f8705d
Tools • Dart 3.1.5 • DevTools 2.25.0

g-apparence commented 6 months ago

Could you post your code? Were you actually recording a video while performing analysis?

Parfyonator commented 6 months ago

Hi @g-apparence. I've already posted it. It is literally only that 5 lines of additional code added to CameraAwesomeBuilder.awesome in main file of example. That's it. Nothing more. I don't see any sense in duplicating all of the code for these 5 lines. You can even leave this function empty to reproduce the issue: onImageForAnalysis: (image) async {}.

Parfyonator commented 6 months ago

@g-apparence additional note about video recording: I'm using the built in functionality of CameraAwesomeBuilder.awesome widget. Here is video recording of the screen. When I press stop button, I get the error I've mentioned in the issue description.

https://github.com/Apparence-io/CamerAwesome/assets/27166027/4d8d4cdd-da0b-45e3-84e8-05fe4c0c0b8b

g-apparence commented 6 months ago

Will make a try and tell you. Sorry for delay

Parfyonator commented 6 months ago

Hi @g-apparence. I decided to dig a bit deeper and added some prints to video_camera_state.dart and it throws an error when onImageForAnalysis is present. Since await CamerawesomePlugin.recordVideo(captureRequest); is wrapped in try block it is not visible in logs.

flutter: PlatformException(VIDEO_ERROR, can't record video when image stream is enabled, , null)
flutter: #0      CameraInterface.recordVideo (package:camerawesome/pigeon.dart:899:7)
<asynchronous suspension>
#1      VideoCameraState.startRecording (package:camerawesome/src/orchestrator/states/video_camera_state.dart:48:7)
<asynchronous suspension>

Maybe that will help.

Parfyonator commented 6 months ago

Hi @g-apparence. Don't want to be pushy, just want to know if it is something that can be fixed relatively quickly or I should switch to camera plugin on iOS devices for now. Thanks.

g-apparence commented 6 months ago

Hi sorry, I have a lot of work on the ApparenceKit Supabase support.

I'm not sure that it is a problem with camerawesome or that this should not be possible on all devices. I have to take time and try this on all the devices I have for CamerAwesome.

Also I'm always open for contribution if you wanna help me on this.

Parfyonator commented 6 months ago

I'm not good at native development especially Objective-C. So I'm not sure how to fix it. Also I'm not sure if I'll have time to dig into native iOS part in the nearest future since I have multiple projects.