Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release时anr及其频繁 #3019

Open
Moster1h opened this issue Oct 28, 2020 · 13 comments
Open

release时anr及其频繁 #3019

Moster1h opened this issue Oct 28, 2020 · 13 comments

Comments

@Moster1h
Copy link

Moster1h commented Oct 28, 2020

问题描述:

释放的时候出现Anr, 使用的是exo

问题机型/系统:

Huawei Y6II, Huawei P8 青春版, Motorola moto g(6) play,
Motorola Moto X Play,Motorola Moto G(4) Plus,Motorola Moto G4 Play,
Sony Xperia X Compact

GSY依赖版本

implementation 'com.shuyu:gsyVideoPlayer-java:7.1.4'
implementation 'com.shuyu:GSYVideoPlayer-exo2:7.1.4'

问题log(如果有)

com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer.releaseVideos (GSYVideoPlayer.java:1)

  at java.lang.Object.wait (Native method)
  at f.h.b.c.s0.a (PlayerMessage.java:8)
  at f.h.b.c.x0.a (SimpleExoPlayer.java:73)
  at f.h.b.c.x0.b (SimpleExoPlayer.java:4)
  at tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer.setSurface (IjkExo2MediaPlayer.java:5)
  at tv.danmaku.ijk.media.exo2.Exo2PlayerManager.showDisplay (Exo2PlayerManager.java:3)
  at f.p.a.b.setDisplay (GSYVideoBaseManager.java:5)
  at com.shuyu.gsyvideoplayer.video.base.GSYVideoView.setDisplay (GSYVideoView.java:1)
  at com.shuyu.gsyvideoplayer.video.base.GSYTextureRenderView.onSurfaceDestroyed (GSYTextureRenderView.java:1)
  at com.shuyu.gsyvideoplayer.render.view.GSYTextureView.onSurfaceTextureDestroyed (GSYTextureView.java:2)
  at android.view.TextureView.releaseSurfaceTexture (TextureView.java:249)
  at android.view.TextureView.onDetachedFromWindowInternal (TextureView.java:222)
  at android.view.View.dispatchDetachedFromWindow (View.java:18409)
  at android.view.ViewGroup.removeAllViewsInLayout (ViewGroup.java:5574)
  at android.view.ViewGroup.removeAllViews (ViewGroup.java:5520)
  at com.shuyu.gsyvideoplayer.video.base.GSYVideoView.onCompletion (GSYVideoView.java:5)
  at f.p.a.c.c (GSYVideoManager.java:2)
  at com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer.releaseVideos (GSYVideoPlayer.java:1)
  at com.shuyu.gsyvideoplayer.video.base.GSYVideoView$2.run (GSYVideoView.java:2)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6923)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:870)
  at com.google.android.exoplayer2.ExoPlayerImplInternal.release (ExoPlayerImplInternal.java:257)

 at java.lang.Object.wait! (Native method)
  at com.google.android.exoplayer2.ExoPlayerImplInternal.release (ExoPlayerImplInternal.java:257)
  at com.google.android.exoplayer2.ExoPlayerImpl.release (ExoPlayerImpl.java:440)
  at com.google.android.exoplayer2.SimpleExoPlayer.release (SimpleExoPlayer.java:1297)
  at tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer.reset (IjkExo2MediaPlayer.java:274)
  at tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer.release (IjkExo2MediaPlayer.java:335)
  at tv.danmaku.ijk.media.exo2.Exo2PlayerManager.release (Exo2PlayerManager.java:127)
  at com.shuyu.gsyvideoplayer.GSYVideoBaseManager$MediaHandler.handleMessage (GSYVideoBaseManager.java:573)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:150)
  at android.app.ActivityThread.main (ActivityThread.java:5621)
  at java.lang.reflect.Method.invoke! (Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:794)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:684)
  at java.lang.Object.wait! (Native method)
  at com.google.android.exoplayer2.ExoPlayerImplInternal.waitUninterruptibly (ExoPlayerImplInternal.java:587)
  at com.google.android.exoplayer2.ExoPlayerImplInternal.release (ExoPlayerImplInternal.java:402)
  at com.google.android.exoplayer2.ExoPlayerImpl.release (ExoPlayerImpl.java:713)
  at com.google.android.exoplayer2.SimpleExoPlayer.release (SimpleExoPlayer.java:1710)
  at tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer.reset (IjkExo2MediaPlayer.java:274)
  at tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer.release (IjkExo2MediaPlayer.java:335)
  at tv.danmaku.ijk.media.exo2.Exo2PlayerManager.release (Exo2PlayerManager.java:133)
  at com.shuyu.gsyvideoplayer.GSYVideoBaseManager$MediaHandler.handleMessage (GSYVideoBaseManager.java:573)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6123)
  at java.lang.reflect.Method.invoke! (Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:867)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:757)
@CarGuo
Copy link
Owner

CarGuo commented Oct 28, 2020

不是很理解问题出在哪里

@Moster1h
Copy link
Author

是在Activity销毁的时候出现的Anr

    @Override
    public void onDestroy() {
        super.onDestroy();

        GSYVideoManager.releaseAllVideos();
    }

@Moster1h
Copy link
Author

是不是释放的时候,handler卡住ui线程了

@Moster1h
Copy link
Author

ijkplayer#3456
这个issues可取吗,release放在子线程中执行?但是你的是handler发送的消息进行处理.

@bananaCaptain
Copy link

当连接入一个无法上网的wifi后这个情况会必现,然而无法将release放到子线程中执行,然后想通过判断网络状态去切换内核到exo减缓UI卡顿问题,效果不太理想,请问有解决的办法不?谢谢

@zhkrb
Copy link

zhkrb commented Nov 27, 2020

ijkplayer弱网释放的问题我是通过ip拉流解决的,也就是先手动或使用第三方在子线程中解析dns,替换url中host并设置header: Host: xxxx.com再加载数据,可以有效改善anr问题

@LyraHeartString
Copy link

大概率是销毁surface在先
然后又调用了release吧

@LyraHeartString
Copy link

EXO2 在2.8+版本有个ANR
在setSurface为null的时候
message.blockUntilDelivered这个方法里面有个wait
好象是在等待解码。
新版本2.13+的版本同样的地方有个时间限制,超过时间后就释放锁,EXO2本身问题,我这里已经解决了。

@Liangwenb
Copy link

#00 pc 0x89ccc libc.so (syscall + 28)
#01 pc 0xf46a8 libc.so (pthread_join + 260)
#02 pc 0x12bb8 split_config.arm64_v8a.apk!libijksdl.so (SDL_WaitThread + 32)
#03 pc 0x1ab9c split_config.arm64_v8a.apk!libijkplayer.so 
#04 pc 0x2071c split_config.arm64_v8a.apk!libijkplayer.so (ffp_wait_stop_l + 32)
#05 pc 0x2748c split_config.arm64_v8a.apk!libijkplayer.so (ijkmp_shutdown_l + 56)
#06 pc 0x2c2f8 split_config.arm64_v8a.apk!libijkplayer.so 
       at tv.danmaku.ijk.media.player.IjkMediaPlayer._release(IjkMediaPlayer.java)
       at tv.danmaku.ijk.media.player.IjkMediaPlayer.release(IjkMediaPlayer.java:704)
       at com.shuyu.gsyvideoplayer.player.IjkPlayerManager.release(IjkPlayerManager.java:188)
       at com.shuyu.gsyvideoplayer.GSYVideoBaseManager$MediaHandler.handleMessage(GSYVideoBaseManager.java:573)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:257)
       at android.app.ActivityThread.main(ActivityThread.java:8104)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)

 
xmd   多个播放器播放时候 ANR       这个有办法解决吗

@hanbaokun
Copy link

1
"main" prio=5 tid=1 Native
2
| group="main" sCount=1 dsCount=0 flags=1 obj=0x738c9540 self=0x7a83c10800
3
| sysTid=6193 nice=-10 cgrp=default sched=1073741825/2 handle=0x7b0abbd0d0
4
| state=S schedstat=( 5695073421 197062518 6088 ) utm=470 stm=99 core=7 HZ=100
5
| stack=0x7fddeca000-0x7fddecc000 stackSize=8192KB
6
| held mutexes=
7
kernel: (couldn't read /proc/self/task/6193/stack)
8
native: #00 pc 000000000006cbbc /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
9
native: #1 pc 00000000000cfd94 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_join+244)
10
native: #2 pc 0000000000012bb8 /data/app/com.lanjingren.ivwen-ES6BisSmIjZ1I1wVMAYhJQ==/lib/arm64/libijksdl.so (SDL_WaitThread+32)
11
native: #3 pc 000000000001aa3c /data/app/com.lanjingren.ivwen-ES6BisSmIjZ1I1wVMAYhJQ==/lib/arm64/libijkplayer.so (???)
12
native: #4 pc 00000000000204b4 /data/app/com.lanjingren.ivwen-ES6BisSmIjZ1I1wVMAYhJQ==/lib/arm64/libijkplayer.so (ffp_wait_stop_l+32)
13
native: #5 pc 0000000000027224 /data/app/com.lanjingren.ivwen-ES6BisSmIjZ1I1wVMAYhJQ==/lib/arm64/libijkplayer.so (ijkmp_shutdown_l+56)
14
native: #6 pc 000000000002c090 /data/app/com.lanjingren.ivwen-ES6BisSmIjZ1I1wVMAYhJQ==/lib/arm64/libijkplayer.so (???)
15
native: #7 pc 0000000000150350 /apex/com.android.runtime/lib64/libart.so (art_quick_generic_jni_trampoline+144)
16
native: #8 pc 0000000000147334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548)
17
native: #9 pc 00000000001561b4 /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+252)
18
native: #10 pc 00000000002fd900 /apex/com.android.runtime/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+384)
19
native: #11 pc 00000000002f8bd0 /apex/com.android.runtime/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912)
20
native: #12 pc 00000000005cd910 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+400)
21
native: #13 pc 0000000000141914 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_direct+20)
22
native: #14 pc 0000000000338888 [anon:dalvik-DEX data] (tv.danmaku.ijk.media.player.IjkMediaPlayer.release+20)
23
native: #15 pc 00000000005cb874 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1432)
24
native: #16 pc 0000000000141814 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual+20)
25
native: #17 pc 0000000000465910 [anon:dalvik-DEX data] (com.shuyu.gsyvideoplayer.e.d.c+8)
26
native: #18 pc 00000000005cd074 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1752)
27
native: #19 pc 0000000000141a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20)
28
native: #20 pc 0000000000463e84 [anon:dalvik-DEX data] (com.shuyu.gsyvideoplayer.b$a.handleMessage+60)
29
native: #21 pc 00000000002ce22c /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.1772238600391939451+320)
30
native: #22 pc 00000000005bc0a4 /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1012)
31
native: #23 pc 0000000000150468 /apex/com.android.runtime/lib64/libart.so (art_quick_to_interpreter_bridge+88)
32
at tv.danmaku.ijk.media.player.IjkMediaPlayer._release(IjkMediaPlayer.java)
33
at tv.danmaku.ijk.media.player.IjkMediaPlayer.release(IjkMediaPlayer.java:704)
34
at com.shuyu.gsyvideoplayer.player.IjkPlayerManager.release(IjkPlayerManager.java:185)
35
at com.shuyu.gsyvideoplayer.GSYVideoBaseManager$MediaHandler.handleMessage(GSYVideoBaseManager.java:573)
36
at android.os.Handler.dispatchMessage(Handler.java:110)
37
at android.os.Looper.loop(Looper.java:219)
38
at android.app.ActivityThread.main(ActivityThread.java:8668)
39
at java.lang.reflect.Method.invoke(Method.java)
40
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
41
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

Repository owner locked and limited conversation to collaborators Jun 27, 2022
Repository owner unlocked this conversation Jun 27, 2022
@yangjieK
Copy link

yangjieK commented Jul 1, 2022

Up Code主, 我也出现了ANR. 我review了ANR issue挺多的,大于是release造成的,从2019就有anr问题

能否设计一个合理的线程管理接口, 由调用的人控制,而非主线程.

#00 pc 0x89ccc libc.so (syscall + 28)
#1 pc 0xf46a8 libc.so (pthread_join + 260)
#2 pc 0x12bb8 split_config.arm64_v8a.apk!libijksdl.so (SDL_WaitThread + 32)
#3 pc 0x1ab9c split_config.arm64_v8a.apk!libijkplayer.so
#4 pc 0x2071c split_config.arm64_v8a.apk!libijkplayer.so (ffp_wait_stop_l + 32)
#5 pc 0x2748c split_config.arm64_v8a.apk!libijkplayer.so (ijkmp_shutdown_l + 56)
#6 pc 0x2c2f8 split_config.arm64_v8a.apk!libijkplayer.so
at tv.danmaku.ijk.media.player.IjkMediaPlayer._release(IjkMediaPlayer.java)
at tv.danmaku.ijk.media.player.IjkMediaPlayer.release(IjkMediaPlayer.java:704)
at com.shuyu.gsyvideoplayer.player.IjkPlayerManager.release(IjkPlayerManager.java:188)
at com.shuyu.gsyvideoplayer.GSYVideoBaseManager$MediaHandler.handleMessage(GSYVideoBaseManager.java:573)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:257)
at android.app.ActivityThread.main(ActivityThread.java:8104)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)

@CarGuo CarGuo mentioned this issue Nov 18, 2022
@itsgm
Copy link

itsgm commented Aug 26, 2024

12608-25 20:33:58.349 17017 17017 D IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
12708-25 20:33:58.349 17017 17017 D IJKMEDIA: ffpipeline_set_surface()
12808-25 20:33:58.349 17017 17017 D IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
12908-25 20:33:58.417 17017 17017 D IJKMEDIA: IjkMediaPlayer_release
13008-25 20:33:58.417 17017 17017 D IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
13108-25 20:33:58.417 17017 17017 D IJKMEDIA: ffpipeline_set_surface()
13208-25 20:33:58.417 17017 17017 D IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
13308-25 20:33:58.417 17017 17017 D IJKMEDIA: ijkmp_shutdown_l()
13408-25 20:33:58.417 17017 17017 D IJKMEDIA: wait for read_tid
13508-25 20:33:58.418 17017 20784 D IJKMEDIA: message_loop exit
13608-25 20:33:58.418 17017 20784 I IJKMEDIA: SDL_JNI_DetachThreadEnv: [20784]
13708-25 20:33:58.418 17017 20798 I IJKMEDIA: convert image convert_frame_count = 0
13808-25 20:33:58.418 17017 20798 I IJKMEDIA: SDL_JNI_DetachThreadEnv: [20798]
13908-25 20:33:58.423 17017 20785 I IJKMEDIA: SDL_JNI_DetachThreadEnv: [20785]
14008-25 20:33:58.521 17017 20786 I IJKMEDIA: SDL_JNI_DetachThreadEnv: [20786]
14108-25 20:33:58.522 17017 20792 I IJKMEDIA: SDL_JNI_DetachThreadEnv: [20792]
14208-25 20:49:40.477 1578 7438 D CollectByFileModifyDate: file is not exists, path: /storage/emulated/0/null

调用GSYVideoManager.releaseAllVideos();日志跟踪

@CarGuo 可以看出来出现ANR的原因么

@CarGuo
Copy link
Owner

CarGuo commented Aug 26, 2024

@itsgm 没看出来,看起来就是退出播放页的时候,触发了一次 setSurface null,然后 release,ijk 内部也会调用一次 surface null ,之后 message_loop exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants