Xamarin Forms Binding Events and Call Stop() cause the Android App Crash
Summary
Android App will crash when call stop() no matter if manually or automatically as long as there is a binding event to MediaPlayer.
Minimal project and steps to reproduce
Create a blank xamarin forms project, install libvlcsharp nuget package, init in the native platform, create a videoview in mainview.xmal, binding mediaplayer in viewmodel. In the viewmodel, add some event handler to mediaplayer, like timechanged\positionchanged or whatever you like, then play a video, and wait til the video finish. It will crash when the video finishes playing. I assume it is because when the video is finished, the stop() function is called automatically. I also tried removing those event handlers, the app won't crash when the video finished playing. Also, if there are some event handlers, calling the stop() function manually also causes this same crash.
What is the current bug behavior?
The App crashes.
What is the expected correct behavior?
The App should not crash.
Does it work on other plaforms? Does it work with the official VLC apps?
iOS won't reproduce this behavior.
Relevant LibVLC logs and/or screenshots
Aborting thread: "Thread-26" prio=10 tid=46 Native | group="" sCount=0 ucsCount=0 flags=0 obj=0x135c00b8 self=0x7e2a5a4c10 | sysTid=24024 nice=-10 cgrp=top-app sched=0/0 handle=0x7c0ccffcb0 | state=R schedstat=( 1374977492 86248861 15293 ) utm=54 stm=83 core=6 HZ=100 | stack=0x7c0cc08000-0x7c0cc0a000 stackSize=991KB | held mutexes= "abort lock" native: #00 pc 000000000056b020 /apex/com.android.art/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+144) native: #1 (closed) pc 00000000006862bc /apex/com.android.art/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits >&, bool, BacktraceMap*, bool) const+368) native: #2 (closed) pc 000000000064b6dc /apex/com.android.art/lib64/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits >&, art::Thread*) const+72) native: #3 (closed) pc 0000000000635c10 /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+2436) native: #4 (closed) pc 0000000000016bc4 /system/lib64/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+80) native: #5 (closed) pc 0000000000016184 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+368) native: #6 (closed) pc 0000000000458e98 /apex/com.android.art/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+2524) native: #7 (closed) pc 0000000000447cd4 /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckAttachedThread(char const*)+188) native: #8 pc 000000000044348c /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::GetJavaVM(_JNIEnv*, _JavaVM**) (.llvm.11342356196538880199)+68) native: #9 (closed) pc 0000000000488d54 /data/app/~~uD35_zJNbOKN3n-D8wAY_Q==/com.ycy.qchimobile-Bbp40N9D2cCes_2Ls-hFkQ==/lib/arm64/libvlc.so (???) native: #10 (closed) pc 00000000000b769c /apex/com.android.runtime/lib64/bionic/libc.so (pthread_key_clean_all()+136) native: #11 (closed) pc 00000000000b6df4 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_exit+76) native: #12 (closed) pc 00000000000b6c70 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+316) native: #13 (closed) pc 000000000005329c /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (no managed stack frames)
JNI DETECTED ERROR IN APPLICATION: a thread (tid 24024 is making JNI calls without being attached in call to GetJavaVM [libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24024 (Thread-26), pid 23883
Environment
- OS: Android
- Version 11
- Device: iQOO8 Pro
- LibVLC version and architecture 3.6.6
- LibVLCSharp version 3.6.6