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

Must start a session (using -[AVAssetWriter startSessionAtSourceTime:) before appending pixel buffers' #379

Open misos1 opened 11 months ago

misos1 commented 11 months ago

Steps to Reproduce

Just test your code sample from readme on iphone 7 with latest ios (try to test your plugin on older iphones): https://pub.dev/packages/camerawesome#-awesome-built-in-interface

This happened probably after recording was stopped (and is happening like in 5 from 10 cases) so you probably destroyed the session and still got some camera frame samples after that (maybe because there are multiple threads involved) so probably you need to check if the session is actually active in function which receives frames (good to check how others handle this like camera plugin).

Also it throws some errors when trying to use flash with the front camera.

Expected results

No crash.

Actual results

Crash.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] Must start a session (using -[AVAssetWriter startSessionAtSourceTime:) before appending pixel buffers'
*** First throw call stack:
(0x18122bc60 0x198a57ee4 0x18a02f3dc 0x18a02b790 0x18a028f3c 0x18a02e6b8 0x1049f3ec4 0x1049ddd60 0x1a480a558 0x1a47f5b28 0x1a4a27f38 0x1a4bd4fbc 0x180eec094 0x180e8ebb8 0x180ea08dc 0x180e92610 0x180e931f4 0x180e9cec8 0x1dc5a0e00 0x1dc5a092c)
libc++abi: terminating with uncaught exception of type NSException
* thread #40, queue = 'camerawesome.dispatchqueue', stop reason = signal SIGABRT
    frame #0: 0x00000001bbb0bbbc libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1bbb0bbbc <+8>:  b.lo   0x1bbb0bbd8               ; <+36>
    0x1bbb0bbc0 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bbb0bbc4 <+16>: mov    x29, sp
    0x1bbb0bbc8 <+20>: bl     0x1bbb0760c               ; cerror_nocancel

About your device

Brand Model OS
Apple iPhone 7 15.7.8

Your flutter version

Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (2 weeks ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1