yixia / VitamioBundle

Vitamio for Android
http://www.vitamio.org/en/
Other
5.27k stars 2.07k forks source link

[Android] Random crash with VideoView.setVideoUri #418

Open FavoRiteKK opened 8 years ago

FavoRiteKK commented 8 years ago

Hello, I have a app with a ViewPager. The ViewPager can display image and video. Here is the setup video method:

private void setupVideoView(final int pos) {

            if (mVideoView.isPlaying()) {
                mVideoView.stopPlayback();
            }

            mVideoView.setVideoURI(Uri.parse(prevPath));
            if (!mVideoView.isFocused()) {
                mVideoView.requestFocus();
            }

            if (mVideoView.isValid()) {
                mVideoView.start();
            }
}

And the app gets random crash while swiping/navigating from and to the video item. Sometime the crash rarely happen. Here is the logcat:

08-31 15:46:58.560 21891-25226/ A/art: art/runtime/thread.cc:1057] Native thread exited without calling DetachCurrentThread: Thread[16,tid=25226,Native,Thread=0x4258f000,peer=0x0,""] 08-31 15:46:58.655 21891-25226/ A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc8 in tid 25226 (esoft.) 08-31 15:46:58.755 1940-1940/? I/DEBUG: ** * * * * * * * * * * * * * * * 08-31 15:46:58.755 1940-1940/? I/DEBUG: Build fingerprint: 'samsung/GT-N7000/GT-N7000:4.0.3/IML74K/ZCLP6:user/release-keys' 08-31 15:46:58.755 1940-1940/? I/DEBUG: Revision: '8' 08-31 15:46:58.755 1940-1940/? I/DEBUG: ABI: 'arm' 08-31 15:46:58.755 1940-1940/? I/DEBUG: pid: 21891, tid: 25226, name: esoft. >>> <<< 08-31 15:46:58.760 1940-1940/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGVMAPERR), fault addr 0xc8 08-31 15:46:58.910 1940-1940/? I/DEBUG: Abort message: 'art/runtime/thread.cc:1057] Native thread exited without calling DetachCurrentThread: Thread[16,tid=25226,Native,Thread=0x4258f000,peer=0x0,""]' 08-31 15:46:58.910 1940-1940/? I/DEBUG: r0 00000000 r1 535fbdb0 r2 40290e04 r3 0000000c 08-31 15:46:58.910 1940-1940/? I/DEBUG: r4 746ea178 r5 ba7a7aaf r6 42af8000 r7 fffffa98 08-31 15:46:58.910 1940-1940/? I/DEBUG: r8 530efd40 r9 00000000 sl 00000038 fp 746ea18c 08-31 15:46:58.910 1940-1940/? I/DEBUG: ip 42af5c94 sp 535fb248 lr 42a589ed pc 42a588e4 cpsr 80070030 08-31 15:46:58.910 1940-1940/? I/DEBUG: backtrace: 08-31 15:46:58.910 1940-1940/? I/DEBUG: #00 pc 002588e4 /system/lib/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc(art::mirror::ArtMethod, unsigned int, std::1::vector<unsigned int, std::1::allocator >)+35) 08-31 15:46:58.910 1940-1940/? I/DEBUG: #01 pc 001ed6f1 /system/lib/libart.so (art::Monitor::VisitLocks(art::StackVisitor, void ()(art::mirror::Object, void), void_, bool)+216) 08-31 15:46:58.910 1940-1940/? I/DEBUG: #02 pc 0022b265 /system/lib/libart.so (art::StackDumpVisitor::VisitFrame()+348) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #03 pc 002264a1 /system/lib/libart.so (art::StackVisitor::WalkStack(bool)+260) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #04 pc 0022c099 /system/lib/libart.so (art::Thread::DumpJavaStack(std::1::basic_ostream<char, std::__1::char_traits >&) const+168) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #05 pc 0022d6bd /system/lib/libart.so (art::Thread::Dump(std::1::basic_ostream<char, std::1::char_traits >&) const+152) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #06 pc 00236a85 /system/lib/libart.so (art::ThreadList::DumpLocked(std::__1::basic_ostream<char, std::1::char_traits >&)+104) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #07 pc 0021d75f /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::chartraits >&)+238) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #08 pc 0021d9a5 /system/lib/libart.so (art::Runtime::Abort()+72) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #09 pc 000a6b3d /system/lib/libart.so (art::LogMessage::~LogMessage()+1316) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #10 pc 0022b05f /system/lib/libart.so (art::Thread::ThreadExitCallback(void)+170) 08-31 15:46:58.915 1940-1940/? I/DEBUG: #11 pc 00014541 /system/lib/libc.so (pthread_key_clean_all()+80) 08-31 15:46:58.920 1940-1940/? I/DEBUG: #12 pc 000141bb /system/lib/libc.so (pthreadexit+30) 08-31 15:46:58.920 1940-1940/? I/DEBUG: #13 pc 0000a680 /data/data//libs/libvplayer.so 08-31 15:46:58.920 1940-1940/? I/DEBUG: #14 pc 00010348 /system/lib/libc.so 08-31 15:46:58.920 1940-1940/? I/DEBUG: #15 pc 0022c464 /system/lib/libart.so (art::Thread::InstallImplicitProtection()+63) 08-31 15:46:58.920 1940-1940/? I/DEBUG: #16 pc 0022c669 /system/lib/libart.so (art::Thread::InitStackHwm()+300) 08-31 15:46:58.920 1940-1940/? I/DEBUG: #17 pc 0022cb5d /system/lib/libart.so (art::Thread::Init(art::ThreadList, art::JavaVMExt)+324) 08-31 15:46:58.920 1940-1940/? I/DEBUG: #18 pc 0023172f /system/lib/libart.so (art::Thread::Attach(char const, bool, jobject, bool)+114) 08-31 15:46:58.925 1940-1940/? I/DEBUG: #19 pc 0021aea9 /system/lib/libart.so (art::Runtime::AttachCurrentThread(char const_, bool, jobject, bool)+12) 08-31 15:46:58.925 1940-1940/? I/DEBUG: #20 pc 001bdc8b /system/lib/libart.so (art::JII::AttachCurrentThread(JavaVM, _JNIEnv, void_)+190) 08-31 15:46:58.925 1940-1940/? I/DEBUG: #21 pc 000bf649 /system/lib/libart.so (art::CheckJII::AttachCurrentThread(JavaVM, JNIEnv**, void)+96) 08-31 15:46:58.925 1940-1940/? I/DEBUG: #22 pc 0001b3e4 /data/data/com./libs/libvplayer.so 08-31 15:46:58.925 1940-1940/? I/DEBUG: #23 pc 00013ecb /system/lib/libc.so (pthreadstart(void)+30) 08-31 15:46:58.925 1940-1940/? I/DEBUG: #24 pc 00011eff /system/lib/libc.so (start_thread+6) 08-31 15:46:59.335 2308-3605/system_process W/ActivityManager: getTasks: caller 10062 does not hold GET_TASKS; limiting output 08-31 15:46:59.630 2308-25244/system_process W/ActivityManager: Force finishing activity 1

I think if I somehow make the call to VideoView.setVideoUri more thread safe, the crash might be fix. Though I'm not sure and don't know how to. Is there anyone have suggestion? Thanks!