Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Error/Crash when Stop Capture from CaptureFromCamera after PrepareCapture but without StartCapture #455

Open
shirborer-shine opened this issue Feb 9, 2025 · 1 comment
Assignees
Labels

Comments

@shirborer-shine
Copy link

Unity version

2022.3.20f1

Unity editor platform

macOS

AVPro Movie Capture edition

Full

AVPro Movie Capture Version

5.3.3

Which Android OS version(s) are you using?

14

Which graphics API(s) are you using?

OpenGLES 3

Hardware

Samsung S24

Which capture component are you using?

Capture From Camera

Capture mode

Realtime

Which output mode are you using?

Video file

Video codecs

H264

Audio source

Unity

Any other component configuration required to reproduce the issue.

No response

The issue

In my game, I do PrepareCapture as part of the loading. Then user have an option to start the game, which also calls StartCapture, or to abort, which unloads the scene in which the CaptureFromCamera exists (Then StopCapture called form CaptureBase's OnDestroy).
When StopCapture is called, I get the following errors (attached in the Log output section below), which also sometimes lead to a crash.
I tried calling UnprepareCapture, and/or CancelCapture, but still get the same errors.
Adding to UnprepareCapture
_handle = -1;
seem to fix the issue. But i'm not sure which side effects this may have, and if there is something else wrong I'm doing which leads to this issue.

Log output

2025/02/09 19:08:14.228 14597 16877 Info CCodec [c2.exynos.h264.encoder] state->set(RELEASING)
2025/02/09 19:08:14.228 14597 16877 Debug CCodecBufferChannel [c2.exynos.h264.encoder#745] MediaCodec discarded an unknown buffer
2025/02/09 19:08:14.228 14597 16877 Debug CCodecBufferChannel [c2.exynos.h264.encoder#745] MediaCodec discarded an unknown buffer
2025/02/09 19:08:14.228 14597 16877 Debug CCodecBufferChannel [c2.exynos.h264.encoder#745] MediaCodec discarded an unknown buffer
2025/02/09 19:08:14.228 14597 16877 Debug CCodecBufferChannel [c2.exynos.h264.encoder#745] MediaCodec discarded an unknown buffer
**2025/02/09 19:08:14.229 14597 16895 Error MediaCodec Invalid to call during release(); only valid in Executing states**
2025/02/09 19:08:14.229 14597 16895 Info AVProMovieCapture ??????? (VideoRecorder.cpp:866) VideoRecorder::videoCaptureThread - got input buffer of size: 0
2025/02/09 19:08:14.229 14597 16877 Error MediaCodec queueInputBuffer() is valid only at Executing states; currently during release()
**2025/02/09 19:08:14.229 14597 16895 Info AVProMovieCapture ??? (VideoRecorder.cpp:909) VideoRecorder::videoCaptureThread - failed to queue input buffer, error: -10000 - AMEDIA_ERROR_UNKNOWN**
2025/02/09 19:08:14.229 14597 16924 Warn CCodec release order: surface --> comp
2025/02/09 19:08:14.229 14597 16901 Verbose MediaWriter Track event err/info msg:101, trackId:2, type:1000,val:0
2025/02/09 19:08:14.229 14597 16901 Info MPEG4Writer Received total/0-length (0/0) buffers and encoded 0 frames. - Audio
2025/02/09 19:08:14.229 14597 16901 Info MPEG4Writer Audio track drift time: 0 us
2025/02/09 19:08:14.229 14597 16900 Verbose MediaWriter Track event err/info msg:101, trackId:1, type:1000,val:0
2025/02/09 19:08:14.229 14597 16900 Info MPEG4Writer Received total/0-length (0/0) buffers and encoded 0 frames. - Video
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer reset()
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Video track stopping. Stop source
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Video track source stopping
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Video track source stopped
2025/02/09 19:08:14.229 14597 16900 Info MPEG4Writer TrackDuration is 0 us
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Video track stopped. Status:0. Stop source
2025/02/09 19:08:14.229 14597 16897 Info MPEG4Writer Duration for 1:Video track is 0 us
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Audio track stopping. Stop source
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Audio track source stopping
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Audio track source stopped
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer Audio track stopped. Status:0. Stop source
2025/02/09 19:08:14.229 14597 16897 Info MPEG4Writer Duration for 2:Audio track is 0 us
2025/02/09 19:08:14.229 14597 16897 Info MPEG4Writer Duration from tracks range is [0, 0] us
2025/02/09 19:08:14.229 14597 16898 Debug MPEG4Writer 0 chunks are written in the last batch
2025/02/09 19:08:14.229 14597 16897 Debug MPEG4Writer WriterThread stopped. Status:0
2025/02/09 19:08:14.230 14597 16897 Info MPEG4Writer Adjust the moov start time from -1 us -> -1 us
2025/02/09 19:08:14.230 14597 16897 Info MPEG4Writer The mp4 file will not be streamable.
2025/02/09 19:08:14.230 14597 16897 Info MPEG4Writer MOOV atom was written to the file
2025/02/09 19:08:14.230 14597 16897 Debug MPEG4Writer release()
2025/02/09 19:08:14.230 14597 16897 Debug MPEG4Writer ftruncate mPreAllocateFileEndOffset:0 mOffset:850 mMdatEndOffset:40 diff:-850
2025/02/09 19:08:14.230 14597 16897 Debug MPEG4Writer MP4WtrCtrlHlpLooper stopped
2025/02/09 19:08:14.230 14597 16897 Info MPEG4Writer Top 5 write durations(microseconds): #1:8 #2:33 #3:37 #4:38 #5:110
2025/02/09 19:08:14.230 14597 16897 Debug MPEG4Writer reset()
2025/02/09 19:08:14.230 14597 16897 Debug MPEG4Writer Video track stopping. Stop source
**2025/02/09 19:08:14.230 14597 16897 Error MPEG4Writer Stop() called but track is not started or stopped**
2025/02/09 19:08:14.230 14597 16897 Debug MPEG4Writer Audio track stopping. Stop source
2025/02/09 19:08:14.230 14597 16897 Error MPEG4Writer Stop() called but track is not started or stopped
2025/02/09 19:08:14.239 14597 16924 Info CCodec [c2.exynos.h264.encoder] state->set(RELEASED)
2025/02/09 19:08:14.239 14597 16877 Info MediaCodec Codec shutdown complete
2025/02/09 19:08:14.239 14597 16879 Info hw-BpHwBinder onLastStrongRef automatically unlinking death recipients
2025/02/09 19:08:14.239 14597 16879 Debug BufferPoolAccessor2.0 Destruction - bufferpool2 0xb400006ee1dcce18 cached: 0/0M, 0/0% in use; allocs: 5, 0% recycled; transfers: 0, 0% unfetched
2025/02/09 19:08:14.241 14597 14613 Debug MediaCodec flushMediametrics
2025/02/09 19:08:14.241 14597 16890 Info CCodec [c2.android.aac.encoder] state->set(RELEASING)
2025/02/09 19:08:14.242 14597 16890 Debug CCodecBufferChannel [c2.android.aac.encoder#368] MediaCodec discarded an unknown buffer
2025/02/09 19:08:14.242 14597 16890 Debug CCodecBufferChannel [c2.android.aac.encoder#368] MediaCodec discarded an unknown buffer
2025/02/09 19:08:14.242 14597 16890 Debug CCodecBufferChannel [c2.android.aac.encoder#368] MediaCodec discarded an unknown buffer
2025/02/09 19:08:14.242 14597 16925 Warn CCodec release order: surface --> comp
2025/02/09 19:08:14.242 14597 16925 Info CCodec [c2.android.aac.encoder] state->set(RELEASED)
@MorrisRH
Copy link
Contributor

Setting the handle to -1 is going to prevent the native part of the plugin from being able to clean up and free off resources so I would advise against that.

Could you provide details of the crashes you're experiencing (crash logs, tombstones, etc.)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants