wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
197 stars 32 forks source link

[MacOS] AVPixelFormat crash #184

Open JulienDev opened 3 days ago

JulienDev commented 3 days ago

Describe the bug I noticed a few crashes on MacOS related to AVPixelFormat. All MacOS versions are impacted and I'm using fvp 0.28.0 and mdk 0.3.0 with Flutter 3.24.3

Expected behavior The app should not crash

Log I can't reproduce on my Mac so I can share with you the Crashlytics stacktrace:

Crash : mdk.vdec0@0x700004c26000
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
Crashed: mdk.vdec0@0x700004c26000
0  mdk                            0xb3712 mdk::abi::ffmpeg::to(mdk::abi::VideoFormat&, AVPixelFormat) + 1724 (__hash_table:1724)
1  mdk                            0xb65a1 mdk::abi::ffmpeg::to(mdk::abi::VideoFrame&, AVFrame const*, AVRational const&) + 173 (VideoFrameGlue.cpp:173)
2  mdk                            0xc3486 mdk::abi::VideoDecoderFFmpegBase::from(AVFrame*) + 167 (VideoDecoderFFmpegBase.cpp:167)
3  mdk                            0xc3c59 mdk::abi::VideoDecoderAVCodec::from(AVFrame*) + 379 (VideoDecoderAVCodec.cpp:379)
4  mdk                            0xc3549 std::__1::__function::__func<mdk::abi::VideoDecoderFFmpegBase::decode(mdk::abi::Packet const&)::$_3, std::__1::allocator<mdk::abi::VideoDecoderFFmpegBase::decode(mdk::abi::Packet const&)::$_3>, double (AVFrame*)>::operator()(AVFrame*&&) + 60 (VideoFrame.h:60)
5  mdk                            0xbf70c mdk::abi::AVCoderBase::decodePacket(AVCodecContext*, mdk::abi::Packet const&, std::__1::function<double (AVFrame*)>&&) + 139 (AVCoderBase.cpp:139)
6  mdk                            0xc340e mdk::abi::VideoDecoderFFmpegBase::decode(mdk::abi::Packet const&) + 138 (VideoDecoderFFmpegBase.cpp:138)
7  mdk                            0x22cdd bool mdk::abi::FrameReaderImpl::decodeLoop<(mdk::abi::MediaType)0>(int, int) + 2500 (FrameReader.cpp:2500)
8  mdk                            0x1dfd2 void* std::__1::__thread_proxy[abi:nn180100]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, mdk::abi::FrameReaderImpl::startDecodeThread(mdk::abi::FrameReaderImpl::DecLoopState&, mdk::abi::MediaType, int)::$_0>>(void*) + 2732 (FrameReader.cpp:2732)
9  libsystem_pthread.dylib        0x64e1 _pthread_start + 125
10 libsystem_pthread.dylib        0x1f6b thread_start + 15
wang-bin commented 3 days ago

when does it crash? what decoders do you set? a log will be helpful

JulienDev commented 3 days ago

Unfortunately, I have no idea when it's happening as I didn't add enough tracking information. I will add more in the future! I'm not setting any decoder so it's probably using the default ones. Also, I'm using the Backend Player API.

wang-bin commented 3 days ago

if you are using backend api, then software decoder is used, less efficient. you have to set via player videoDecoders, see video_player_mdk.dart

JulienDev commented 3 days ago

Ah ok good to know, I'll make the changes. Actually, the only reason why I'm using the backend API is because in the past it was not possible to control tracks. I'll check if thanks to your latest additions I can move to VideoPlayerPlatform implementation.

wang-bin commented 3 days ago

now you can use videoplayercintroller with extensions, see controller.dart