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 31 forks source link

Flutter app crashes after a while with bad_function_call #146

Closed mruettgers closed 2 weeks ago

mruettgers commented 2 months ago

Describe the bug I've encountered an issue with my Flutter app where it crashes after a while. This occurs after several videos from a playlist, which consists of both images and videos, have been played without issues. The app then terminates with the following error message:

default FrameReader0x7fffd4385750 update state: 2=>0
0x7fffb80dbcc0 player.onStateChanged(0)
terminate called after throwing an instance of 'std::bad_function_call'
  what():  bad_function_call

Thread 2348 "mdk.read@140735" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff935f6dc0 (LWP 34408)]

I assume this is somehow related to the disposal of the video player controller, but I'm not really sure if this is an issue with my app or with the mdk-sdk.

Is there a way to further debug this issue? For example, is there an mdk-sdk build available with debug symbols, if that helps to track this issue down further?

Expected behavior The bad_function_call exception should be avoided or at least handled somehow.

Log

flutter: [D] TIME: 2024-08-29T11:38:41.662587 Starting timer. Duration: 5000 ms
flutter: [D] TIME: 2024-08-29T11:38:41.664576 Initializing video player (item ID 4a)
flutter: [D] TIME: 2024-08-29T11:38:41.664647 Initializing video player (item ID 4a), file: /home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4
default 0x7fffd4385750 new FrameReader...
Registered audio backends: ALSA OpenAL null
[New Thread 0x7fff853eedc0 (LWP 34406)]
ALSA device name: default
ALSA device id: default
ALSA subdevice name: default
default 0x7fffd410fc10 new FrameReader...
Registered audio backends: ALSA OpenAL null
[New Thread 0x7fff85bfedc0 (LWP 34407)]
ALSA device name: default
ALSA device id: default
ALSA subdevice name: default
0x7fffb80dbcc0 player.Player()
0x7fffb80dbcc0 player.onEvent(1, 0x7fffe2fdc790)
0x7fffb80dbcc0 player.onStateChanged(1)
0x7fffb80dbcc0 player.onMediaStatus(1)
0x7fffb80dbcc0 player property: video.decoder = shader_resource=0
0x7fffb80dbcc0 player property: avformat.strict = experimental
0x7fffb80dbcc0 player property: avio.reconnect = 1
0x7fffb80dbcc0 player property: avio.reconnect_delay_max = 7
0x7fffb80dbcc0 player property: avio.protocol_whitelist = file,rtmp,http,https,tls,rtp,tcp,udp,crypto,httpproxy,data,concatf,concat,subfile
0x7fffb80dbcc0 player property: avformat.rtsp_transport = tcp
0x7fffb80dbcc0 player.setDecoders(video, [FFmpeg])
video decoders: "FFmpeg"
video decoders: "FFmpeg"
0x7fffb80dbcc0 player.setMedia(file:///home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4)
default FrameReader0x7fffd4385750 state: 0=>0=>0, 0
default0x7fffd4385750 stop, current state: %, drequested: 0
ALSA ERROR@284 snd_pcm_pause(pcm_, value) (0XFFFFFFFB): Input/output error
no video renderer
default FrameReader0x7fffd4385750 state: 0=>0=>0, 0
default0x7fffd4385750 stop, current state: %, drequested: 0
0x7fffb80dbcc0 player.prepare(0, ..., 1282)
ALSA ERROR@284 snd_pcm_pause(pcm_, value) (0XFFFFFFFB): Input/output error
0x7fffd4141890 MediaControl.prepare(0, ...) file:///home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4
default 0x7fffd4385750 FrameReader.start(0, ...)
default 0x7fffd4385750 FrameReader::update MediaStatus 0=>0X2
default FrameReader0x7fffd4385750 state: 0=>0=>1, 0
default FrameReader0x7fffd4385750 state: 0=>1=>1, 0
[New Thread 0x7fff935f6dc0 (LWP 34408)]
default FrameReader0x7fffd4385750 request to pause 1, loaded: 0.
default FrameReader0x7fffd4385750 state: 0=>1=>2, 0
default FrameReader0x7fffd4385750 state requested: 2, current: 0
ALSA ERROR@284 snd_pcm_pause(pcm_, value) (0XFFFFFFFB): Input/output error
0x7fffd4385750start frame reader thread: 140735665892800
Trying MediaIO FFmpeg
0x7fffa0000b80 open url: file:///home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4
unsupported avio options:  reconnect_delay_max=7 reconnect=1
0x7fffa0000b80 url opened
default 0x7fffd4385750 FrameReader::update MediaStatus 0X2=>0X2
0x7fffa061c210 avio set class
before avformat_open_input. io: 0x7fffa0000b80(FFmpeg)/pb: 0x7fffa061c210, url: file:///home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4
after avformat_open_input. pb: 0x7fffa061c210, iformat: 0x7fff927a0830, context flags: 2097280, input format flags: 67141640
unsupported avformat options:  rtsp_transport=tcp reconnect_delay_max=7 reconnect=1
Format: mov,mp4,m4a,3gp,3g2,mj2, range: 0 +30155ms, bitrate: 10904434, size: 0
Metadata:
  creation_time: 2023-10-16T16:06:29.000000Z
  minor_version: 1
  compatible_brands: isommp41mp42
  major_brand: mp42
Streams: 2
 Video:
  stream#1, range: 0 +30155ms, frames: 723
  codec: h264 tag: 'avc1' profile: 100 level: 40, yuv420p, bpc:8, bpp:12(8,8,8), channels:(1,1,1), map: 0 1 2 0, bitrate: 10750038, 1920x1080, fps: 23.976, bframes: 0, primaries: BT709, trc: BT709, matrix: BT709, range: Limited
  extra data(35): 01 64 00 28 FF E1 00 10 27 64 00 28 AC 56 80 78 02 27 E5 9A 80 80 80 81 01 00 04 28 EE 3C B0 FD F8 F8 00
  Metadata:
   handler_name: Core Media Video
   vendor_id: [0][0][0][0]
   language: und
   creation_time: 2023-10-16T16:06:29.000000Z
 Audio:
  stream#0, range: 0 +30155ms, frames: 1416
  codec: aac tag: 'mp4a' profile: 1 level: -99, sample size: 0/16, block align: 0, frame_size: 1024, f32p stereo(2) @48000Hz, bitrate: 129961
  extra data(2): 11 90
  Metadata:
   handler_name: Core Media Audio
   vendor_id: [0][0][0][0]
   language: deu
   creation_time: 2023-10-16T16:06:29.000000Z

0x7fffd4141890 prepared callback is invoked
default 0x7fffd4385750 FrameReader::update MediaStatus 0X2=>0X4
0x7fffd4385750 ***buffering progress 0%***
default 0x7fffd4385750 FrameReader::update MediaStatus 0X4=>0X14
ALSA ERROR@284 snd_pcm_pause(pcm_, value) (0XFFFFFFFB): Input/output error
++++++++++++BUFFERING START++++++++++++
default FrameReader0x7fffd4385750 state: 0=>2=>1, 1
default FrameReader0x7fffd4385750 update state: 0=>1
0x7fffd4385750 start to decode audio#0 packet @0.000000/0.000000 pos: 91244
[New Thread 0x7fff8bffedc0 (LWP 34409)]
default FrameReader0x7fffd4385750 state: 1=>1=>2, 1
default FrameReader0x7fffd4385750 update state: 1=>2
starting decode loop thread mdk.adec0@140735542193600
0x7fffd4385750 audio stream#0 starting decoding loop from decoder index 0...
0x7fffd4385750 start to decode video#1 packet @0.000000/0.000000 pos: 1303890x7fffd4385750 creating audio decoder: auto...
0x7fffd4385750 opening audio decoder: FFmpeg...

opening ffmpeg audio decoder: aac
[New Thread 0x7fff96b22dc0 (LWP 34410)]
AVCodec.Audio[aac.LC] decoder: 1 Single threads
aac starting decode loop thread mdk.vdec1@140735721647552
f32p, stereo @48000Hz
0x7fffd4385750 video stream#1 starting decoding loop from decoder index 0...
0x7fffd4385750 creating video decoder: FFmpeg...
0x7fffd4385750 opening video decoder: FFmpeg...
0x7fffd4385750 audio stream#0 sending 1 invalid AOT frame @0.001333s. seeking: 0
0x7fffd4141890 1st audio frame @0.001333
0x7fffd4141890 seek end audio frame @0.001333 seek_pos_: -1, sync_ao_ 1
opening ffmpeg video decoder: h264
AudioRenderer format: f32, stereo @48000Hz, requested: f32p, stereo @48000Hz
AudioRenderer format changed and reinitialize
AudioBackendALSA.close
ALSA ERROR@218 snd_pcm_drop(pcm_) (0XFFFFFFFB): Input/output error
buffer time(us): 1000~10922667, period time(us): 333~3640896, perdiods: 3~1024
snd_pcm_hw_params_set_buffer_time_near 85328 ret 85333
buffer_size dt: 5333, request periods: 16
snd_pcm_hw_params_set_periods_near 16 ret 16
NALU length bytes: 4
[New Thread 0x7fff95a46dc0 (LWP 34411)]
[New Thread 0x7fff95236dc0 (LWP 34412)]
period size: 256, time: 5333
[New Thread 0x7fff94a26dc0 (LWP 34413)]
Using audio backend: ALSA
[New Thread 0x7fff94216dc0 (LWP 34414)]
4096 buffer under flow(), state: PREPARED
[New Thread 0x7fff877eedc0 (LWP 34415)]
AVCodec.Video[h264.High] decoder: 5 Frame threads
unsupported avcodec options:  shader_resource=0
h264 1920x1080  yuv420p
0x7fffd4385750 decode stored recovery packets: 0
0x7fffd4385750 ***buffering progress 100%***
default 0x7fffd4385750 FrameReader::update MediaStatus 0X14=>0X124
0x7fffb80dbcd0 scale(1.000000,-1.000000, (nil))
ALSA ERROR@284 snd_pcm_pause(pcm_, value) (0XFFFFFFB3): File descriptor in bad state
getVideoOutContext (nil) => 0x5555563a6be0. vo count: 1
++++++++++++BUFFERING END++++++++++++
0x7fffb80dbcd0 setVideoSurfaceSize(1920x1080, (nil))
h264 codec pixel format list: (expected yuv420p)
vdpau
cuda
vaapi
yuv420p (selected)
yuv420p using avcodec software decoder...
0x7fffb80dbcc0 player.setLoop(0)
setLoop(0), now 0/0
0x7fffb80dbcc0 player.setVolume(1.000000, -1)
0x7fffd4141890 ao opened: 1, reopen: 1, bad ao: 0. valid: 0
0x7fffb80dbcc0 player.set(2)
0x7fffd4141890 virtual void mdk::MediaControlPush::setState(PlaybackState)@1068 requested state 2=>2, current state 2. status: 0X124
ALSA ERROR@284 snd_pcm_pause(pcm_, value) (0XFFFFFFB3): File descriptor in bad state
default FrameReader0x7fffd4385750 request to pause 1, loaded: 4.
default FrameReader0x7fffd4385750 state: 2=>2=>2, 0
flutter: [D] TIME: 2024-08-29T11:38:41.712538 Starting video playback (item ID 4a)
0x7fffb80dbcc0 player.set(1)
0x7fffd4141890 virtual void mdk::MediaControlPush::setState(PlaybackState)@1068 requested state 2=>1, current state 2. status: 0X124
default FrameReader0x7fffd4385750 request to pause 0, loaded: 4.
default FrameReader0x7fffd4385750 state: 2=>2=>1, 0
default FrameReader0x7fffd4385750 state requested: 1, current: 2
0x7fffb80dbcc0 player.setPlaybackRate(1.000000)
[New Thread 0x7fff86fdedc0 (LWP 34416)]
[New Thread 0x7fff867cedc0 (LWP 34417)]
[New Thread 0x7fff78bdedc0 (LWP 34418)]
default FrameReader0x7fffd4385750 state: 2=>1=>1, 1
default FrameReader0x7fffd4385750 update state: 2=>1
[New Thread 0x7fff63efedc0 (LWP 34419)]
0x7fff4440ded8 filter graph:
+-----------+
|    src    |default--[48000Hz fltp:stereo]--swr:default
| (abuffer) |
+-----------+

                                          +---------------+
swr:default--[48000Hz flt:stereo]--default|      dst      |
                                          | (abuffersink) |
                                          +---------------+

                                           +-------------+
src:default--[48000Hz fltp:stereo]--default|     swr     |default--[48000Hz flt:stereo]--dst:default
                                           | (aresample) |
                                           +-------------+

bad delay. written: 21 - delay = -58
bad delay. written: 21 - delay = -57
>>>>>>>>1st audio frame (after seek) rendered: 1, ao: 21, a: 1, delta: 20 +0.020000
0x7fffd4385750 audio stream#0 AOT frame is sent
0x7fffb80dbcd0 setRenderAPI(1, (nil))
0x7fffd4385750 video stream#1 sending 1 invalid AOT frame @0.000000s. seeking: 0
bad delay. written: 41 - delay = -53
0x7fffd4141890 1st video frame to render @0.000000s, sync time: 0.041000
VideoRenderer clear buffered frames
0-track seek end video frame @0.000000 seek_pos_: -1
bad delay. written: 41 - delay = -56
0x7fffd4141890 1st video frame to render @0.000000s, sync time: 0.041000
bad delay. written: 41 - delay = -61
bad delay. written: 41 - delay = -60
0x7fffd4385750 video stream#1 AOT frame is sent
bad delay. written: 41 - delay = -56
bad delay. written: 41 - delay = -56
bad delay. written: 41 - delay = -55
bad delay. written: 41 - delay = -53
bad delay. written: 41 - delay = -53
[Thread 0x7fffc8de6dc0 (LWP 34404) exited]
bad delay. written: 62 - delay = -37
VideoRenderer WxH=1920.000000x1080.000000 1920.000000x1080.000000, frame: 1920x1080
update transform 2d. scale: (1.000000, 1.000000), orientation: 0
m: mat<4, 4>(
1  0  0  0
0  -1  0  0
0  0  1  0
0  0  0  1
)
new Context object 0x555556138ac0(123) for native context handle 0x555555941680
ctx->api_: 0x7fffa4033b40
probing gl context... native: (nil)
select gl api resolver for EGL|OpenGL|OpenGLES
EGL_VERSION: 1.4
EGL_VENDOR: Mesa Project
EGL_CLIENT_APIS: OpenGL OpenGL_ES
Current EGL dso path: /lib/aarch64-linux-gnu/libEGL_mesa.so.0
GLESv2 dso loaded: /lib/aarch64-linux-gnu/libEGL_mesa.so.0
resolving gl common functions...
select gl api resolver for EGL|OpenGL|OpenGLES
using opengl api resolver: EGL
probing gl client context... major_: 0
GL_VENDOR: Broadcom
GL_RENDERER: V3D 7.1
GL_VERSION: 3.1 Mesa 23.2.1-1~bpo12+rpt3
GL_SHADING_LANGUAGE_VERSION: 1.40
EGL_ANDROID_blob_cache EGL_EXT_buffer_age EGL_EXT_client_extensions EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_EXT_pixel_format_float EGL_EXT_platform_base EGL_EXT_platform_device EGL_EXT_platform_wayland EGL_EXT_platform_x11 EGL_EXT_platform_xcb EGL_EXT_present_opaque EGL_EXT_swap_buffers_with_damage EGL_KHR_cl_event2 EGL_KHR_client_get_all_proc_addresses EGL_KHR_config_attribs EGL_KHR_context_flush_control EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_debug EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image_base EGL_KHR_no_config_context EGL_KHR_platform_gbm EGL_KHR_platform_wayland EGL_KHR_platform_x11 EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_KHR_swap_buffers_with_damage EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_MESA_image_dma_buf_export EGL_MESA_platform_gbm EGL_MESA_query_driver EGL_WL_bind_wayland_display EGL_WL_create_wayland_buffer_from_image GL_AMD_conservative_depth GL_AMD_draw_buffers_blend GL_AMD_multi_draw_indirect GL_AMD_performance_monitor GL_AMD_shader_trinary_minmax GL_AMD_texture_texture4 GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_APPLE_packed_pixels GL_ARB_ES2_compatibility GL_ARB_ES3_compatibility GL_ARB_arrays_of_arrays GL_ARB_base_instance GL_ARB_buffer_storage GL_ARB_clear_buffer_object GL_ARB_clear_texture GL_ARB_color_buffer_float GL_ARB_compatibility GL_ARB_compressed_texture_pixel_storage GL_ARB_conditional_render_inverted GL_ARB_conservative_depth GL_ARB_copy_buffer GL_ARB_copy_image GL_ARB_debug_output GL_ARB_depth_buffer_float GL_ARB_depth_texture GL_ARB_direct_state_access GL_ARB_draw_buffers GL_ARB_draw_buffers_blend GL_ARB_draw_elements_base_vertex GL_ARB_draw_indirect GL_ARB_draw_instanced GL_ARB_explicit_attrib_location GL_ARB_explicit_uniform_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_no_attachments GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_get_program_binary GL_ARB_get_texture_sub_image GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_invalidate_subdata GL_ARB_map_buffer_alignment GL_ARB_map_buffer_range GL_ARB_multi_bind GL_ARB_multi_draw_indirect GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_occlusion_query2 GL_ARB_parallel_shader_compile GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_polygon_offset_clamp GL_ARB_program_interface_query GL_ARB_provoking_vertex GL_ARB_robustness GL_ARB_sampler_objects GL_ARB_separate_shader_objects GL_ARB_shader_atomic_counter_ops GL_ARB_shader_atomic_counters GL_ARB_shader_bit_encoding GL_ARB_shader_objects GL_ARB_shader_storage_buffer_object GL_ARB_shader_subroutine GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shading_language_420pack GL_ARB_shading_language_include GL_ARB_shading_language_packing GL_ARB_shadow GL_ARB_stencil_texturing GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_buffer_range GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_cube_map_array GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_filter_anisotropic GL_ARB_texture_float GL_ARB_texture_gather GL_ARB_texture_mirror_clamp_to_edge GL_ARB_texture_mirrored_repeat GL_ARB_texture_multisample GL_ARB_texture_non_power_of_two GL_ARB_texture_query_levels GL_ARB_texture_query_lod GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_rgb10_a2ui GL_ARB_texture_stencil8 GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_ARB_texture_swizzle GL_ARB_texture_view GL_ARB_transform_feedback2 GL_ARB_transform_feedback_instanced GL_ARB_transpose_matrix GL_ARB_uniform_buffer_object GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_attrib_binding GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_window_pos GL_ATI_blend_equation_separate GL_ATI_draw_buffers GL_ATI_fragment_shader GL_ATI_separate_stencil GL_ATI_texture_compression_3dc GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_EXT_EGL_image_storage GL_EXT_EGL_sync GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_copy_texture GL_EXT_debug_label GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_polygon_offset_clamp GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shader_integer_mix GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_subtexture GL_EXT_texture GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_texture_rectangle GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_texture_shared_exponent GL_EXT_texture_snorm GL_EXT_texture_swizzle GL_EXT_transform_feedback GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_IBM_multimode_draw_arrays GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_INGR_blend_func_separate GL_KHR_context_flush_control GL_KHR_debug GL_KHR_no_error GL_KHR_parallel_shader_compile GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_sliced_3d GL_MESA_pack_invert GL_MESA_shader_integer_functions GL_MESA_texture_signed_rgba GL_MESA_window_pos GL_NV_ES1_1_compatibility GL_NV_blend_square GL_NV_conditional_render GL_NV_copy_image GL_NV_fog_distance GL_NV_half_float GL_NV_light_max_exponent GL_NV_packed_depth_stencil GL_NV_primitive_restart GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_NV_texture_rectangle GL_OES_EGL_image GL_OES_read_format GL_S3_s3tc GL_SGIS_generate_mipmap GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SUN_multi_draw_arrays
16 bit texture channel depth: 16
OpenGL Context thread: 140737301427840
OpenGL3.1 Compatibility profile, EGL140, GLSL140
Features PBO: 1, UBO: 0, RG texture: 1, 16bit texture: 1
resolving gl extensions...
select gl api resolver for EGL|OpenGL|OpenGLES
using opengl api resolver: EGL
context version: 310
gl api resolved. thread@ 140737301427840
0x5555558a7e30mdk::GLVideoRenderer::Private::Renderers::Renderers()
0x555556138ac0/0x555555941680 Context::setLocalData local data 0x5555558484d0 for key: 0x7b. size: 1
unknown, bpc:0, bpp:0(), channels:(), map: 0 0 0 0 => yuv420p, bpc:8, bpp:12(8,8,8), channels:(1,1,1), map: 0 1 2 0
bpp 2, bpc: 8. gl texture parameters:
    R8 |   RED | UNSIGNED_BYTE
    R8 |   RED | UNSIGNED_BYTE
    R8 |   RED | UNSIGNED_BYTE
texture created: 61713
plane linesize 0: padded = 1920, effective = 1920. theoretical plane size: 1920x1080. coordinate crop: 1.000000
texture created: 61714
plane linesize 1: padded = 960, effective = 960. theoretical plane size: 960x540. coordinate crop: 1.000000
texture created: 61715
plane linesize 2: padded = 960, effective = 960. theoretical plane size: 960x540. coordinate crop: 1.000000
crop_w=1.000000=>1.000000
frame color: BT709 BT709 BT709 Limited. gamma: 2.200000, signal peak: 1.000000
 -
output color: BT709 UNSPECIFIED RGB Full. gamma: 2.200000, signal peak: 1.000000
rgb primaries matrix: mat<3, 3>(
1  0  0
0  1  0
0  0  1
)
bad delay. written: 83 - delay = -15
scale: 1.000000, color transform: mat<bad delay. written: 83 - delay = -15
4, 4>(
1.16438  0  1.79274  -0.972945
1.16438  -0.213249  -0.532909  0.301483
1.16438  2.1124  0  -1.1334
0  0  0  1
)
EQ: mat<4, 4>(
1  0  0  0
0  1  0  0
0  0  1  0
0  0  0  1
)
shader id: 2305
bad delay. written: 83 - delay = -13
bad delay. written: 83 - delay = -13
texture 0: 1920x1080
texture 1: 960x540
texture 2: 960x540
material changed: (nil) => 0x905
planar: 1, alpha: 0, texture 2d: 1, external: 0, rg semi-planar: 0, 16=>8: 0, xyz: 0, yuv sampler: 0, generic packed yuv: 0, cocgsy: 0, primaries diff: 0, trc: 1=>1, tone map: 0
bind attribute: a_Position => 0
bind attribute: a_TexCoords0 => 1
uniform locations:
u_Texture0: 2
u_Texture1: 3
u_Texture2: 4
u_Matrix: 0, u_TexMatrix: 1
build glsl elapsed: 1152us
uniform cb.u_colorMatrix: 5
creating vbo...
creating vao...
bad delay. written: 83 - delay = -14
bad delay. written: 83 - delay = -12
[Thread 0x7ffff0d92dc0 (LWP 34405) exited]
flutter: [D] TIME: 2024-08-29T11:38:46.663386 Stopping video playback (item ID 4a)
flutter: [D] TIME: 2024-08-29T11:38:46.663467 Muting video playback (item ID 4a)
0x7fffb80dbcc0 player.setVolume(1.000000, -1)
0x7fffb80dbcc0 player.setVolume(0.900000, -1)
[Thread 0x7fff63efedc0 (LWP 34419) exited]
[Thread 0x7fff78bdedc0 (LWP 34418) exited]
[Thread 0x7fff867cedc0 (LWP 34417) exited]
[Thread 0x7fff86fdedc0 (LWP 34416) exited]
[New Thread 0x7fff63efedc0 (LWP 34420)]
[New Thread 0x7fff78bdedc0 (LWP 34421)]
[New Thread 0x7fff867cedc0 (LWP 34422)]
[New Thread 0x7fff86fdedc0 (LWP 34423)]
0x7fff4440ded8 filter graph:
+-----------+
|    src    |default--[48000Hz fltp:stereo]--vol:default
| (abuffer) |
+-----------+

                                          +---------------+
swr:default--[48000Hz flt:stereo]--default|      dst      |
                                          | (abuffersink) |
                                          +---------------+

                                           +----------+
src:default--[48000Hz fltp:stereo]--default|   vol    |default--[48000Hz fltp:stereo]--swr:default
                                           | (volume) |
                                           +----------+

                                           +-------------+
vol:default--[48000Hz fltp:stereo]--default|     swr     |default--[48000Hz flt:stereo]--dst:default
                                           | (aresample) |
                                           +-------------+

0x7fffb80dbcc0 player.setVolume(0.800000, -1)
0x7fffb80dbcc0 player.setVolume(0.700000, -1)
0x7fffb80dbcc0 player.setVolume(0.600000, -1)
0x7fffb80dbcc0 player.setVolume(0.500000, -1)
0x7fffb80dbcc0 player.setVolume(0.400000, -1)
0x7fffb80dbcc0 player.setVolume(0.300000, -1)
0x7fffb80dbcc0 player.setVolume(0.200000, -1)
0x7fffb80dbcc0 player.setVolume(0.100000, -1)
0x7fffb80dbcc0 player.setVolume(0.000000, -1)
0x7fffb80dbcc0 player.set(2)
0x7fffd4141890 virtual void mdk::MediaControlPush::setState(PlaybackState)@1068 requested state 1=>2, current state 1. status: 0X124
default FrameReader0x7fffd4385750 request to pause 1, loaded: 4.
default FrameReader0x7fffd4385750 state: 1=>1=>2, 0
default FrameReader0x7fffd4385750 state requested: 2, current: 1
flutter: [D] TIME: 2024-08-29T11:38:47.335646 Reseting timer. Elapsed: 5673 ms
flutter: [D] TIME: 2024-08-29T11:38:47.335824 Starting timer. Duration: 5000 ms
default FrameReader0x7fffd4385750 state: 1=>2=>2, 1
default FrameReader0x7fffd4385750 update state: 1=>2
[New Thread 0x7fffc8de6dc0 (LWP 34424)]
[New Thread 0x7fffc0ffedc0 (LWP 34425)]
flutter: [D] TIME: 2024-08-29T11:38:47.866051 Disposing video player (item ID 4a)
0x7fffb80dbcd0 setVideoSurfaceSize(-1x-1, (nil))
clear on stop
0x555556138ac0 destroying context local data 1...
0x5555558a7e30mdk::GLVideoRenderer::Private::Renderers::~Renderers()
cleanup shader cache
cleanup shader cache
0x555556138ac0->aboutToDestroy() erase context 0x555556138ac0(123) for native context handle 0x555555941680 ~~~~~~~~
~Context
0x555556138ac0->aboutToDestroy() done~~~~~~~~
0x555555849870UGL::opengl::Context::Local<mdk::GLVideoRenderer::Private::Renderers>::~Local() [T = mdk::GLVideoRenderer::Private::Renderers, DT = mdk::GLVideoRenderer::Private::Renderers]0x7b count: 1
mdk::VideoRenderer::Private::~Private() @127
0x7fffb80dbcc0 player.set(0)
0x7fffd4141890 virtual void mdk::MediaControlPush::setState(PlaybackState)@1068 requested state 2=>0, current state 2. status: 0X124
default FrameReader0x7fffd4385750 state: 2=>2=>0, 0
default0x7fffd4385750 stop, current state: %, drequested: 2
0x7fffd4385750 unload, current status 0x124, invalid: 0, loading: 0, loaded: 4, buffering: 0, seeking: 0, prepared: 256, EOF: 0
0x7fffa061b600 request avformat input interrupt
0x7fffa0000bb0 request to interrupt io operation
[Thread 0x7fff95a46dc0 (LWP 34411) exited]
[Thread 0x7fff95236dc0 (LWP 34412) exited]
[Thread 0x7fff94a26dc0 (LWP 34413) exited]
[Thread 0x7fff94216dc0 (LWP 34414) exited]
[Thread 0x7fff877eedc0 (LWP 34415) exited]
VideoFrame319946@5.547208 to be destroyed is not rendered by  0x5555557e6860
EOS video frame of track 0
0x7fffd4385750 video stream#1 decoding loop is finished. packets: 71, pts: [5.755750, 8.675333]
[Thread 0x7fff96b22dc0 (LWP 34410) exited]
0x7fffd4385750 unload_requested_. skip sending packet
0x7fffd4385750 default FrameReader@0x7fffd4385750 unload requested, close io
free custome avio: 0x7fffa061c210
0x7fffa0000b80 close url: file:///home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4
140735665892800default 0x7fffd4385750 update @1147: reset status_mask. status: 121
default 0x7fffd4385750 FrameReader::update MediaStatus 0X124=>0X1
FrameReader0x7fffd4385750 stop by user. clear packets, send eof for each loop
FrameReader@0x7fffd4385750 sending Packet::End to all packet queues. PacketIO@0x7fffa061bf70 ->url: file:///home/mkx/MKXMedia/Samples/2023_10_12_Silk-Neuheit.mp4
0x7fffd4385750 clear packet queue for stream 1
0x7fffd4385750 clear packet queue for stream 0
before changed() 1
default FrameReader0x7fffd4385750 state: 2=>0=>0, 0
0x7fffd4385750 unload, current status 0x1, invalid: 0, loading: 0, loaded: 0, buffering: 0, seeking: 0, prepared: 0, EOF: 0
EOS audio frame of track 0
0x7fffd4385750 audio stream#0 decoding loop is finished. packets: 2, pts: [0.000000, 0.000000]
default FrameReader0x7fffd4385750 state: 2=>0=>0, 1
0x7fffb80dbcc0 player.onEvent(0, (nil))[Thread 0x7fff8bffedc0 (LWP 34409) exited]

default FrameReader0x7fffd4385750 update state: 2=>0
0x7fffb80dbcc0 player.onStateChanged(0)
terminate called after throwing an instance of 'std::bad_function_call'
  what():  bad_function_call

Thread 2348 "mdk.read@140735" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff935f6dc0 (LWP 34408)]
mruettgers commented 2 months ago

I forgot the stacktrace:

(gdb) backtrace
#0  __pthread_kill_implementation (threadid=140735665892800, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1  0x00007ffff4030a64 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  0x00007ffff3fea76c in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff3fd74bc in __GI_abort () at ./stdlib/abort.c:79
#4  0x00007ffff42f49c8 in __gnu_cxx::__verbose_terminate_handler() () at /lib/aarch64-linux-gnu/libstdc++.so.6
#5  0x00007ffff42f23bc in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#6  0x00007ffff42f2420 in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#7  0x00007ffff42f2704 in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#8  0x00007ffff42ee21c in std::__throw_future_error(int) () at /lib/aarch64-linux-gnu/libstdc++.so.6
#9  0x00007ffff7f79590 in std::function<void (mdk::State)>::operator()(mdk::State) const (this=0x7fffd413e548, __args=mdk::State::NotRunning) at /usr/bin/../lib/gcc/aarch64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:590
#10 0x00007ffff7f79550 in mdk::Player::onStateChanged(std::function<void (mdk::State)> const&)::{lambda(MDK_State, void*)#1}::operator()(MDK_State, void*) const (this=0x0, value=MDK_State_NotRunning, opaque=0x7fffd413e490)
    at /home/mkx/workbench/mkxperience/linux/flutter/ephemeral/.plugin_symlinks/fvp/linux/mdk-sdk/include/mdk/Player.h:275
#11 0x00007ffff7f79500 in mdk::Player::onStateChanged(std::function<void (mdk::State)> const&)::{lambda(MDK_State, void*)#1}::__invoke(MDK_State, void*) (value=MDK_State_NotRunning, opaque=0x7fffd413e490)
    at /home/mkx/workbench/mkxperience/linux/flutter/ephemeral/.plugin_symlinks/fvp/linux/mdk-sdk/include/mdk/Player.h:272
#12 0x00007ffff3ed9874 in  () at /home/mkx/workbench/mkxperience/build/linux/arm64/debug/bundle/lib/libmdk.so.0
#13 0x00007ffff3ed9874 in  () at /home/mkx/workbench/mkxperience/build/linux/arm64/debug/bundle/lib/libmdk.so.0
#14 0x00007ffff3ed973c in  () at /home/mkx/workbench/mkxperience/build/linux/arm64/debug/bundle/lib/libmdk.so.0
#15 0x00007ffff3ed9f7c in  () at /home/mkx/workbench/mkxperience/build/linux/arm64/debug/bundle/lib/libmdk.so.0
#16 0x00007ffff3ed9978 in  () at /home/mkx/workbench/mkxperience/build/linux/arm64/debug/bundle/lib/libmdk.so.0
#17 0x00007ffff402ee58 in start_thread (arg=0x7fffe2fdc317) at ./nptl/pthread_create.c:442
#18 0x00007ffff4097f9c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79
wang-bin commented 2 months ago

libmdk.so*.dsym in the extracted dir is the debug symbol

mruettgers commented 2 months ago

Backtrace with Debug-Symbols:

(gdb) backtrace
#0  __pthread_kill_implementation (threadid=140735365705152, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44

#1  0x00007ffff4030a64 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  0x00007ffff3fea76c in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff3fd74bc in __GI_abort () at ./stdlib/abort.c:79
#4  0x00007ffff42f49c8 in __gnu_cxx::__verbose_terminate_handler() () at /lib/aarch64-linux-gnu/libstdc++.so.6
#5  0x00007ffff42f23bc in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#6  0x00007ffff42f2420 in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#7  0x00007ffff42f2704 in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#8  0x00007ffff42ee21c in std::__throw_future_error(int) () at /lib/aarch64-linux-gnu/libstdc++.so.6
#9  0x00007ffff7f79590 in std::function<void (mdk::State)>::operator()(mdk::State) const (this=0x7fffc83e8458, __args=mdk::State::NotRunning) at /usr/bin/../lib/gcc/aarch64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:590
#10 0x00007ffff7f79550 in mdk::Player::onStateChanged(std::function<void (mdk::State)> const&)::{lambda(MDK_State, void*)#1}::operator()(MDK_State, void*) const (this=0x0, value=MDK_State_NotRunning, opaque=0x7fffc83e83a0)
    at /home/mkx/workbench/mkxperience/linux/flutter/ephemeral/.plugin_symlinks/fvp/linux/mdk-sdk/include/mdk/Player.h:275
#11 0x00007ffff7f79500 in mdk::Player::onStateChanged(std::function<void (mdk::State)> const&)::{lambda(MDK_State, void*)#1}::__invoke(MDK_State, void*) (value=MDK_State_NotRunning, opaque=0x7fffc83e83a0)
    at /home/mkx/workbench/mkxperience/linux/flutter/ephemeral/.plugin_symlinks/fvp/linux/mdk-sdk/include/mdk/Player.h:272
#12 0x00007ffff3ed9874 in std::__1::function<void (mdk::abi::State)>::operator()(mdk::abi::State) const (this=<optimized out>, __arg=mdk::abi::State::NotRunning) at /usr/lib/llvm-19/bin/../include/c++/v1/__functional/function.h:428
#13 0x00007ffff3ed9874 in std::__1::function<void (mdk::abi::State)>::operator()(mdk::abi::State) const (this=<optimized out>, __arg=mdk::abi::State::NotRunning) at /usr/lib/llvm-19/bin/../include/c++/v1/__functional/function.h:428
#14 0x00007ffff3ed973c in mdk::abi::FrameReader::update(mdk::abi::State, bool) (this=<optimized out>, value=mdk::abi::State::NotRunning, now=<optimized out>) at /home/runner/work/mdk-sdk/mdk-sdk/mdk/core/FrameReader.cpp:1137
#15 0x00007ffff3ed9f7c in mdk::abi::FrameReaderImpl::reset() (this=0x7fffc833d160) at /home/runner/work/mdk-sdk/mdk-sdk/mdk/core/FrameReader.cpp:1706
#16 mdk::abi::FrameReaderImpl::run()::$_0::operator()() const (this=<optimized out>) at /home/runner/work/mdk-sdk/mdk-sdk/mdk/core/FrameReader.cpp:1525
#17 scope_exit_handler<mdk::abi::FrameReaderImpl::run()::$_0>::~scope_exit_handler() (this=<optimized out>) at /home/runner/work/mdk-sdk/mdk-sdk/mdk/base/scope_atexit.h:24
#18 mdk::abi::FrameReaderImpl::run() (this=0x7fffc833d160) at /home/runner/work/mdk-sdk/mdk-sdk/mdk/core/FrameReader.cpp:1660
#19 mdk::abi::FrameReaderImpl::load()::$_1::operator()() (this=<optimized out>) at /home/runner/work/mdk-sdk/mdk-sdk/mdk/core/FrameReader.cpp:1729
#20 std::__1::__invoke[abi:nn190100]<mdk::abi::FrameReaderImpl::load()::$_1>(mdk::abi::FrameReaderImpl::load()::$_1&&) (__f=<optimized out>) at /usr/lib/llvm-19/bin/../include/c++/v1/__type_traits/invoke.h:149
#21 _ZNSt3__112__async_funcIZN3mdk3abi15FrameReaderImpl4loadEvE3$_1JEE9__executeB8nn190100ITpTnmJEEEvNS_15__tuple_indicesIJXspT_EEEE (this=<optimized out>) at /usr/lib/llvm-19/bin/../include/c++/v1/future:1832
#22 std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1>::operator()[abi:nn190100]() (this=<optimized out>) at /usr/lib/llvm-19/bin/../include/c++/v1/future:1826
#23 std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::__execute() (this=<optimized out>) at /usr/lib/llvm-19/bin/../include/c++/v1/future:876
#24 0x00007ffff3ed9978 in std::__1::__invoke[abi:nn190100]<void (std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >*, , void>(void (std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::*&&)(), std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >*&&)
    (__f=@0x7fffc83d7c48: &virtual std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::__execute(), __a0=@0x7fffc83d7c58: 0x7ffef84c53a0)
    at /usr/lib/llvm-19/bin/../include/c++/v1/__type_traits/invoke.h:117
#25 std::__1::__thread_execute[abi:nn190100]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >*, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >*>&, std::__1::__tuple_indices<2ul>) (__t=...)
    at /usr/lib/llvm-19/bin/../include/c++/v1/__thread/thread.h:192
#26 std::__1::__thread_proxy[abi:nn190100]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >::*)(), std::__1::__async_assoc_state<void, std::__1::__async_func<mdk::abi::FrameReaderImpl::load()::$_1> >*> >(void*) (__vp=0x7fffc83d7c40) at /usr/lib/llvm-19/bin/../include/c++/v1/__thread/thread.h:201
#27 0x00007ffff402ee58 in start_thread (arg=0x7fffe2fdc327) at ./nptl/pthread_create.c:442
#28 0x00007ffff4097f9c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79
wang-bin commented 2 months ago

can you write a minimal example to reproduce the crash?

mruettgers commented 2 months ago

While writing the example, I realized that my callback, which handles the logic after playback, was triggered twice. This happened because the video controller's state _videoPlayerController.value.isCompleted was set to true too early. I’ve now added an additional condition to check if the end of the video has truly been reached.

Debug output when the controller's isCompleted state is set to true:

flutter: [D] TIME: 2024-09-04T19:17:45.325070 Video playback completed (1725470262271)
flutter: [D] TIME: 2024-09-04T19:17:45.325386 Video duration: 0:00:30.155000, position: 0:00:30.047000
flutter: [D] TIME: 2024-09-04T19:17:45.325484 Video completed callback called (1725470262271)
flutter: [D] TIME: 2024-09-04T19:17:45.325951 Video playback completed (1725470262271)
flutter: [D] TIME: 2024-09-04T19:17:45.326070 Video duration: 0:00:30.155000, position: 0:00:30.155000
flutter: [D] TIME: 2024-09-04T19:17:45.326172 Video completed callback called (1725470265325)

isCompleted was set to true at 0:00:30.047000, which is slightly earlier than the actual video duration and the handler has been called again at the end of the video.

The related code snipped:

void _initializeVideo() {
    _isInitialized = false;
    _completedCallbackCalled = false;
    LogService.debug('Initializing video player controller (${widget.id})');
    _videoPlayerController = VideoPlayerController.asset(widget.fileName)
      ..initialize().then((_) async {
        _videoPlayerController.addListener(() {
          if (_isInitialized && _videoPlayerController.value.isCompleted) {
            LogService.debug('Video playback completed (${widget.id})');
            LogService.debug('Video duration: ${_videoPlayerController.value.duration}, position: ${_videoPlayerController.value.position}');
            widget.onCompleted?.call();
          }
        });

        LogService.debug('Starting video playback (${widget.id})');
        await _videoPlayerController.seekTo(_videoPlayerController.value.duration - const Duration(seconds: 3));
        await _videoPlayerController.play();
        setState(() {
          _isInitialized = true;
        });
        widget.onInitialized?.call(this, _videoPlayerController);
      });
  }

I'll close this issue since I can no longer reproduce it after updating the code to handle the completion event only at the actual end of the video.

AlexV525 commented 1 month ago

Hi, I'm facing a similar issue on both simulators and real devices. Crashes happen when the controller calls dispose in most cases. Our use case with the video player is displaying media in the user's feed list. Multiple media can be on the screen, so multiple controllers can get initialized together, but only one media can be played at a time. We also have a mutex lock to ensure we dispose the controller in sequence, and only one gets disposed every 500 milliseconds.

Here is a part of the crash logs. Please advise if further information can be provided.

Thread 313 Crashed:: mdk.read@0x311da2000
0   ???                                    0x10284fa78 ???
1   <translation info unavailable>         0x103c3645c ???
2   libsystem_pthread.dylib                0x113897f30 pthread_kill + 262
3   libsystem_c.dylib                      0x111106d60 abort + 133
4   libc++abi.dylib                        0x10f8a11b2 abort_message + 241
5   libc++abi.dylib                        0x10f893370 demangling_terminate_handler() + 240
6   libobjc.A.dylib                        0x10ed805ee _objc_terminate() + 104
7   libc++abi.dylib                        0x10f8a060b std::__terminate(void (*)()) + 6
8   libc++abi.dylib                        0x10f8a2ea7 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
9   libc++abi.dylib                        0x10f8a2e6e __cxa_throw + 116
10  fvp                                    0x10e983dfc std::__1::__throw_bad_function_call[abi:v160006]() + 60 (function.h:72)
11  fvp                                    0x10e988d48 std::__1::__function::__value_func<void (mdk::State)>::operator()[abi:v160006](mdk::State&&) const + 40 (function.h:509)
12  fvp                                    0x10e988d0f std::__1::function<void (mdk::State)>::operator()(mdk::State) const + 31 (function.h:1156)
13  fvp                                    0x10e988cb3 mdk::Player::onStateChanged(std::__1::function<void (mdk::State)> const&)::'lambda'(MDK_State, void*)::operator()(MDK_State, void*) const + 67 (Player.h:283)
14  fvp                                    0x10e988c5f mdk::Player::onStateChanged(std::__1::function<void (mdk::State)> const&)::'lambda'(MDK_State, void*)::__invoke(MDK_State, void*) + 31 (Player.h:280)
15  mdk                                    0x11157e6ab 0x111434000 + 1353387
16  mdk                                    0x11157e6ab 0x111434000 + 1353387
17  mdk                                    0x11157e64d 0x111434000 + 1353293
18  mdk                                    0x111590ed9 0x111434000 + 1429209
19  mdk                                    0x1115907a8 0x111434000 + 1427368
20  libsystem_pthread.dylib                0x113898202 _pthread_start + 99
21  libsystem_pthread.dylib                0x113893bab thread_start + 15
wang-bin commented 3 weeks ago

@AlexV525 can you provide the code to reproduce the crash? I use https://github.com/abdelaziz-mahdy/universal_video_controls/tree/main/universal_video_controls/example to test multiple videos on macOS, no crash

PBomermustekiin commented 3 weeks ago

@wang-bin

It is crashing with multi video player usage. (using photo manager package for get gallery assets file, and multi video player package for play them, that package also using video_player in it)

Ekran Resmi 2024-10-29 00 31 48

         FutureBuilder(
                  future: pmController.storyDetailAssets[storyIndex].file,
                  builder: (context, snapshot) {
                    if (snapshot.connectionState ==
                        ConnectionState.waiting) {
                      return const GlobalLoadingWidget(
                        color: Colors.black,
                      );
                    } else if (snapshot.hasError) {
                      return const SizedBox();
                    } else if (snapshot.hasData) {
                      return MultiVideoPlayer.file(
                        height: double.infinity,
                        width: double.infinity,
                        videoSourceList: [snapshot.data],
                        scrollDirection: Axis.horizontal,
                        preloadPagesCount: 0,
                        showVideoProgressIndicator: false,
                        showControlsOverlay: false,
                        getCurrentVideoController: (controller) {},
                      );
                    } else {
                      debugPrint("error from story detail page video");
                      return const SizedBox();
                    }
                  },
                ),

If it is possible to fix that issue, it would be great. We have millon users as Photo Recovery gallery app. I see really good effect on videos after add fvp register, but it is causing crash after try to play another video in same screen with multi video player usage. I used video player directly in some pages like onboarding, they were working well without any crash. They using same controller with different paths. Probably that crash happening with multi video player controller. So, @AlexV525 last comment is really make sense.

Related with this issue also: https://github.com/wang-bin/fvp/issues/131

AlexV525 commented 3 weeks ago

I use example to test multiple videos on macOS, no crash

Can you test it on iOS real devices? I'm trying to extract a reproducible snippet but only if I can get some spare time.

wang-bin commented 3 weeks ago

I will try again this week @AlexV525 @PBomermustekiin

AlexV525 commented 3 weeks ago

I guess the simplest fix is to check if the state_cb_ is valid before calling it.

image image
12  fvp 0x10e988d0f std::__1::function<void (mdk::State)>::operator()(mdk::State) const + 31 (function.h:1156)
13  fvp 0x10e988cb3 mdk::Player::onStateChanged(std::__1::function<void (mdk::State)> const&)::'lambda'(MDK_State, void*)::operator()(MDK_State, void*) const + 67 (Player.h:283)
14  fvp 0x10e988c5f mdk::Player::onStateChanged(std::__1::function<void (mdk::State)> const&)::'lambda'(MDK_State, void*)::__invoke(MDK_State, void*) + 31 (Player.h:280)

Disclaimer: This is analyzed by ChatGPT and my little experience with C++.

AlexV525 commented 3 weeks ago

@wang-bin Could you make a quick evaluation about my above suggestion and update the mdk so we can test this in real quick?

wang-bin commented 3 weeks ago

I guess the simplest fix is to check if the state_cb_ is valid before calling it.

image image
12  fvp   0x10e988d0f std::__1::function<void (mdk::State)>::operator()(mdk::State) const + 31 (function.h:1156)
13  fvp   0x10e988cb3 mdk::Player::onStateChanged(std::__1::function<void (mdk::State)> const&)::'lambda'(MDK_State, void*)::operator()(MDK_State, void*) const + 67 (Player.h:283)
14  fvp   0x10e988c5f mdk::Player::onStateChanged(std::__1::function<void (mdk::State)> const&)::'lambda'(MDK_State, void*)::__invoke(MDK_State, void*) + 31 (Player.h:280)

Disclaimer: This is analyzed by ChatGPT and my little experience with C++.

no, the callback won't be invoked if it's null, https://github.com/wang-bin/libmdk-capi/blob/main/Player.cpp#L164

AlexV525 commented 3 weeks ago

no, the callback won't be invoked if it's null, https://github.com/wang-bin/libmdk-capi/blob/main/Player.cpp#L164

This is effective only when .opaque is valid, no? I'm talking about .state_cb_.

EDIT: opaque is a parameter as the callback, state_cb_ is a private field of Player.

wang-bin commented 3 weeks ago

https://github.com/wang-bin/libmdk-capi/blob/main/include/mdk/cpp/Player.h#L285 if statecb is null, opaque is null, and https://github.com/wang-bin/libmdk-capi/blob/main/Player.cpp#L165 this line will clear the callback internally

wang-bin commented 3 weeks ago

@PBomermustekiin @AlexV525 can you write a minimal example I can build and run directly? I'm don't have enough time to write myself. your crash are different

AlexV525 commented 3 weeks ago

if statecb is null, opaque is null

opaque was predicated immediately while the state_cb_ is called in a callback which is a potential cause of the exception?

AlexV525 commented 3 weeks ago

@PBomermustekiin @AlexV525 can you write a minimal example I can build and run directly? I'm don't have enough time to write myself. your crash are different

Sure, but it'll take a while too. :)

PBomermustekiin commented 3 weeks ago

@PBomermustekiin @AlexV525 can you write a minimal example I can build and run directly? I'm don't have enough time to write myself. your crash are different

sure i will create a mini project for you

PBomermustekiin commented 2 weeks ago

@wang-bin sample project is ready. You can see your iOS device videos in home page (your gallery videos). If u go asset detail page with click some video and try to change the current video with swipe right u will see the crash. Just keep going to swipe right until crashes.

https://github.com/PBomermustekiin/fvp_crash_sample

wang-bin commented 2 weeks ago

@AlexV525 @PBomermustekiin try master branch and upgrade dependency

AlexV525 commented 2 weeks ago

No longer see related bad_function_call so far. Cheers! 🍻