bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.55k stars 8.13k forks source link

android端demo播放网络视频时,UI进程被VideoActivity的onStop阻塞 #1167

Open abc1225 opened 8 years ago

abc1225 commented 8 years ago

重现:手机连接到内网,域名解析不了,打开任意一个demo中的网络视频,退出该界面时,onStop被阻塞近50s

04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ wait for read_tid 04-13 16:34:50.850 24786-24890/tv.danmaku.ijk.media.sample E/IJKMEDIA﹕ Failed to resolve hostname devimages.apple.com.edgekey.net: No address associated with hostname

Blocked UI process in function onStop:
protected void onStop() { super.onStop(); Log.d(TAG, "----VideoActivity: " +"onStop begin"); if (mBackPressed || !mVideoView.isBackgroundPlayEnabled()) { mVideoView.stopPlayback(); mVideoView.release(true); mVideoView.stopBackgroundPlay(); } else { mVideoView.enterBackground(); } IjkMediaPlayer.native_profileEnd(); Log.d(TAG, "----VideoActivity: " + "onStop end"); }

版本号: versionName = "0.4.5.1"

Log:

04-13 16:33:50.650 24786-24786/tv.danmaku.ijk.media.sample D/VideoActivity﹕ ----VideoActivity: onCreate 04-13 16:33:50.670 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ Trying to load lib /data/app-lib/tv.danmaku.ijk.media.sample-1/libijkffmpeg.so 0x431dece8 04-13 16:33:50.680 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ Added shared lib /data/app-lib/tv.danmaku.ijk.media.sample-1/libijkffmpeg.so 0x431dece8 04-13 16:33:50.680 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ No JNI_OnLoad found in /data/app-lib/tv.danmaku.ijk.media.sample-1/libijkffmpeg.so 0x431dece8, skipping init 04-13 16:33:50.680 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ Trying to load lib /data/app-lib/tv.danmaku.ijk.media.sample-1/libijksdl.so 0x431dece8 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ Added shared lib /data/app-lib/tv.danmaku.ijk.media.sample-1/libijksdl.so 0x431dece8 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.os.Build$VERSION' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.os.Build' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'java.nio.Buffer' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'java.nio.ByteBuffer' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'java.util.ArrayList' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample I/J4A﹕ API-Level: 19 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.media.AudioTrack' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.media.MediaCodec$BufferInfo' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.media.MediaCodec' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.media.MediaFormat' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample W/J4A﹕ J4ALoader: Ignore: 'android.media.PlaybackParams' need API 19 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'android.os.Bundle' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'tv.danmaku.ijk.media.player.misc.IMediaDataSource' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/J4A﹕ J4ALoader: OK: 'tv.danmaku.ijk.media.player.IjkMediaPlayer' loaded 04-13 16:33:50.690 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ Trying to load lib /data/app-lib/tv.danmaku.ijk.media.sample-1/libijkplayer.so 0x431dece8 04-13 16:33:50.700 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ Added shared lib /data/app-lib/tv.danmaku.ijk.media.sample-1/libijkplayer.so 0x431dece8 04-13 16:33:50.700 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_native_profileBegin 04-13 16:33:50.700 24786-24786/tv.danmaku.ijk.media.sample D/aprof-fake﹕ fake-monstartup libijkplayer.so 04-13 16:33:50.700 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ monstartup: libijkplayer.so 04-13 16:33:50.770 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_native_init 04-13 16:33:50.770 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_native_setup 04-13 16:33:50.770 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ av_version_info: ff2.8--ijk0.4.4.1--dev0.3.3--rc7 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ffpipeline_create_from_android() 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_inject_opaque(0x1d200462) 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_inject_opaque()=void 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_android_set_mediacodec_select_callback() 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ffpipeline_set_mediacodec_select_callback 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_android_set_mediacodec_select_callback()=void 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_native_setLogLevel(3) 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ moncleanup 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setOptionLong 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/tv.danmaku.ijk.media.player.IjkMediaPlayer﹕ Couldn't open file on client side, trying server side 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setDataSourceAndHeaders 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample V/IJKMEDIA﹕ setDataSource: path http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/prog_index.m3u8 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_data_source(url="http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/prog_index.m3u8") 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_data_source(url="http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/prog_index.m3u8")=0 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setVideoSurface 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_android_surface(surface=0x3da0001d) 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ffpipeline_set_surface() 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_android_surface(surface=0x3da0001d)=void 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_prepareAsync 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_prepare_async() 04-13 16:33:50.780 24786-24888/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ SDL_RunThread: [24888] ff_msg_loop 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ ===== versions ===== 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ FFmpeg : ff2.8--ijk0.4.4.1--dev0.3.3--rc7 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ libavutil : 54.31.100 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ libavcodec : 56.60.100 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ libavformat : 56.40.101 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ libswscale : 3.1.101 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ libswresample: 1.2.101 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ ===== options ===== 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ player-opts : mediacodec = 0 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ player-opts : opensles = 0 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ player-opts : overlay-format = 842225234 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ player-opts : framedrop = 1 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ player-opts : start-on-prepared = 0 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ format-opts : ijkinject-opaque = 488637538 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ format-opts : http-detect-range-support = 0 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ codec-opts : skip_loop_filter = 48 04-13 16:33:50.780 24786-24786/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ =================== 04-13 16:33:50.780 24786-24888/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ message_loop 04-13 16:33:50.780 24786-24888/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ FFP_MSG_FLUSH: 04-13 16:33:50.790 24786-24889/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ SDL_RunThread: [24889] ff_vout 04-13 16:33:50.790 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_prepare_async()=0 04-13 16:33:50.790 24786-24890/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ SDL_RunThread: [24890] ff_read 04-13 16:33:57.930 24786-24786/tv.danmaku.ijk.media.sample D/VideoActivity﹕ ----VideoActivity: onBackPressed 04-13 16:33:58.030 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_setVideoSurface 04-13 16:33:58.030 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_android_surface(surface=0x0) 04-13 16:33:58.030 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ffpipeline_set_surface() 04-13 16:33:58.030 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_android_surface(surface=0x0)=void 04-13 16:33:58.330 24786-24786/tv.danmaku.ijk.media.sample D/VideoActivity﹕ ----VideoActivity: onStop begin 04-13 16:33:58.330 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_stop() 04-13 16:33:58.330 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_stop()=0 04-13 16:33:58.330 24786-24889/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ SDL_JNI_DetachThreadEnv: [24889] 04-13 16:33:58.340 24786-24888/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ message_loop exit 04-13 16:33:58.340 24786-24888/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ SDL_JNI_DetachThreadEnv: [24888] 04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_release 04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_android_surface(surface=0x0) 04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ffpipeline_set_surface() 04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_set_android_surface(surface=0x0)=void 04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_shutdown_l() 04-13 16:33:58.340 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ wait for read_tid 04-13 16:34:50.850 24786-24890/tv.danmaku.ijk.media.sample E/IJKMEDIA﹕ Failed to resolve hostname devimages.apple.com.edgekey.net: No address associated with hostname 04-13 16:34:50.850 24786-24890/tv.danmaku.ijk.media.sample E/IJKMEDIA﹕ http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/prog_index.m3u8: I/O error 04-13 16:34:50.850 24786-24890/tv.danmaku.ijk.media.sample I/IJKMEDIA﹕ SDL_JNI_DetachThreadEnv: [24890] 04-13 16:34:50.850 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ wait for video_refresh_tid 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_shutdown_l()=void 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_dec_ref(): ref=0 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_shutdown_l() 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ ijkmp_shutdown_l()=void 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_native_profileEnd 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/aprof-fake﹕ fake-momcleanup 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ moncleanup 04-13 16:34:50.860 24786-24786/tv.danmaku.ijk.media.sample D/VideoActivity﹕ ----VideoActivity: onStop end 04-13 16:34:51.120 24786-24786/tv.danmaku.ijk.media.sample D/dalvikvm﹕ GC_FOR_ALLOC freed 930K, 5% free 28754K/30252K, paused 23ms, total 23ms 04-13 16:34:51.130 24786-24795/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_native_finalize 04-13 16:34:51.130 24786-24795/tv.danmaku.ijk.media.sample D/IJKMEDIA﹕ IjkMediaPlayer_release

bbcallen commented 8 years ago

Seems blocked at getaddrinfo() in libavformat/tcp.c

Jucongyuan commented 8 years ago

我遇到了一样的问题,当我在onDestroy()调用MediaPlayer的release()方法时

Thread suspend timeout mutator lock level=46 owner=18446744073709551615 state=1 num_pending_writers=0 num_pending_readers=0 DALVIK THREADS (25): "main" prio=5 tid=1 Native | group="main" sCount=1 dsCount=0 obj=0x74b45f28 self=0xb7672ce8 | sysTid=2746 nice=0 cgrp=default sched=0/0 handle=0xb6f9ebec | state=S schedstat=( 741475705 134590381 480 ) utm=62 stm=12 core=0 HZ=100 | stack=0xbe33c000-0xbe33e000 stackSize=8MB | held mutexes= native: #00 pc 00012a24 /system/lib/libc.so (syscall+28) native: #01 pc 00016b6f /system/lib/libc.so (pthread_join+90) native: #02 pc 0000eca5 /data/app/com.wangxiaobao.adplayer-1/lib/arm/libijksdl.so (SDL_WaitThread+12) native: #03 pc 0000926b /data/app/com.wangxiaobao.adplayer-1/lib/arm/libijkplayer.so (???) native: #04 pc 0000cab3 /data/app/com.wangxiaobao.adplayer-1/lib/arm/libijkplayer.so (ffp_wait_stop_l+14) native: #05 pc 000108c1 /data/app/com.wangxiaobao.adplayer-1/lib/arm/libijkplayer.so (ijkmp_shutdown_l+28) native: #06 pc 000135f5 /data/app/com.wangxiaobao.adplayer-1/lib/arm/libijkplayer.so (???) native: #07 pc 0000688f /data/data/com.wangxiaobao.adplayer/cache/slice-tv.danmaku.ijk.media-ijkplayer-java-0.4.5.1_0bd12f867517d0aee54d50c0bf3ba81ea39cfee9-classes.dex (Java_tv_danmaku_ijk_media_player_IjkMediaPlayer1release+82) at tv.danmaku.ijk.media.player.IjkMediaPlayer._release(Native method) at tv.danmaku.ijk.media.player.IjkMediaPlayer.release(IjkMediaPlayer.java:666) at com.wangxiaobao.adplayer.fragment.VideoFragment.releaseMediaPlayer(VideoFragment.java:206) at com.wangxiaobao.adplayer.fragment.VideoFragment.onDestroy(VideoFragment.java:193) at com.wangxiaobao.adplayer.fragment.HybridFragment.onDestroy(HybridFragment.java:88) at android.support.v4.app.Fragment.performDestroy(Fragment.java:2202) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1196) at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1349) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:708) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570) at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:164) at android.support.v4.view.ViewPager.populate(ViewPager.java:1177) at android.support.v4.view.ViewPager.populate(ViewPager.java:1025) at android.support.v4.view.ViewPager$3.run(ViewPager.java:254) at android.support.v4.view.ViewPager.completeScroll(ViewPager.java:1910) at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:631) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:609) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:570) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:562) at com.wangxiaobao.adplayer.activity.PlayerActivity$2.handleMessage(PlayerActivity.java:81) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5631) at java.lang.reflect.Method.invoke!(Native method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

该怎么解决呢?急!!

abc1225 commented 8 years ago

等着吧,下个release希望能够解决。。。

Jucongyuan commented 8 years ago

还有能播放flv的第三方开源库吗?

Jucongyuan commented 8 years ago

解决了吗

abc1225 commented 8 years ago

不会c++等着老大解决了。。。

abc1225 commented 8 years ago

不会c++等着老大解决了。。。

zhanggao commented 7 years ago

getaddrinfo blocked 的问题解决了吗?@bbcallen

boydos commented 7 years ago

解决了么,遇到同样的问题 @bbcallen @abc1225 @Jucongyuan