Closed mruettgers closed 2 weeks 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
libmdk.so*.dsym in the extracted dir is the debug symbol
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
can you write a minimal example to reproduce the crash?
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.
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
@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
@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)
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
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.
I will try again this week @AlexV525 @PBomermustekiin
I guess the simplest fix is to check if the state_cb_
is valid before calling it.
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++.
@wang-bin Could you make a quick evaluation about my above suggestion and update the mdk so we can test this in real quick?
I guess the simplest fix is to check if the
state_cb_
is valid before calling it.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
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
.
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
@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
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?
@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 @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
@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.
@AlexV525 @PBomermustekiin try master branch and upgrade dependency
No longer see related bad_function_call
so far. Cheers! 🍻
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:
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