Tencent / Tencent/libpag

pag使用过程anr异常

Open
#2,530 1 comment 0 reactions 1 assignee View on GitHub

@kevingpqi123 is already working on this.

Since Oct 15, 2024.

Dominant language
HTML
Stars
5.8k
Forks
531
Avg merge
8d 55m
Merged PRs (30d)
17

Description

【版本信息】

latest.release 最新版本

【平台信息】

Android 10

【预期的表现】

1、app首页有多个pag view需要轮换播放,其中一个用的网络url一直循环播放,其它的都是本地assets下的文件,其它的隔一段时间轮换播放,用的PAGView加载,pag文件都不大100k以内

2、另一个场景界面,多个按钮,一个PAGView,点击不同按钮加载不同的pag资源,都是网络资源,文件也都不大,50kb以内

【实际的情况】

上述场景使用过程会偶先anr,在两个场景来回快速切换,或者静置一段时间再操作,出现概率会提高

上述两种场景用PAGView还是PAGImageView更好,界面退出或者暂停的时候需不需要调用freeCache、stop或者其它释放方法

【Demo及附件】

网络加载用的是以下方式
lifecycleScope.launch(Dispatchers.IO) {
pag_ai.composition = PAGFile.Load(pagUrl)
withContext(Dispatchers.Main) {
pag_ai.play()
}
}
anr日志1
Input dispatching timed out

ANR Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 6. Wait queue head age: 6943.2ms.)

解析原始
1
org.libpag.PAGSurface.freeCache(Native method)
2
org.libpag.PAGSurface.release(SourceFile:1)
3
org.libpag.PAGView.onDetachedFromWindow(SourceFile:4)
4
android.view.View.dispatchDetachedFromWindow(View.java:19622)
5
android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
6
android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
7
android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
8
android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:4158)
9
android.view.ViewRootImpl.doDie(ViewRootImpl.java:7163)
10
android.view.ViewRootImpl.die(ViewRootImpl.java:7140)
11
android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:490)
12
android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:428)
13
android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:126)
14
android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5016)
15
android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
16
android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
17
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
18
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2025)
19
com.wanjian.cockroach.Cockroach$2.handleMessage(Cockroach.java:129)
20
android.os.Handler.dispatchMessage(Handler.java:103)
21
android.os.Looper.loop(Looper.java:214)
22
android.app.ActivityThread.main(ActivityThread.java:7386)
23
java.lang.reflect.Method.invoke(Native method)
24
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
25
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1072)

日志2
org.libpag.DisplayLink.onUpdate(Native method)
2
org.libpag.DisplayLink.onAnimationUpdate(SourceFile:1)
3
android.animation.ValueAnimator.animateValue(ValueAnimator.java:1558)
4
android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1349)
5
android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1481)
6
android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
7
android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
8
android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
9
android.view.Choreographer$CallbackRecord.run(Choreographer.java:1050)
10
android.view.Choreographer.doCallbacks(Choreographer.java:875)
11
android.view.Choreographer.doFrame(Choreographer.java:806)
12
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1037)
13
android.os.Handler.handleCallback(Handler.java:883)
14
android.os.Handler.dispatchMessage(Handler.java:100)
15
android.os.Looper.loop(Looper.java:214)
16
com.wanjian.cockroach.Cockroach.safeMode(Cockroach.java:216)
17
com.wanjian.cockroach.Cockroach.access$200(Cockroach.java:26)
18
com.wanjian.cockroach.Cockroach$1.uncaughtException(Cockroach.java:70)
19
java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
20
java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
21
java.lang.Thread.dispatchUncaughtException(Thread.java:2187)

日志3
executing service com.lingben.householdrb/.service.StatusBarService

ANR executing service com.lingben.householdrb/.service.StatusBarService

解析原始
1
org.libpag.PAGPlayer.prepare(Native method)
2
org.libpag.PAGView.play(SourceFile:1)
3
com.lingben.householdrb.activity.MyAiActivity$playAi$1$1.invokeSuspend(MyAiActivity.kt:210)
4
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
5
kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
6
android.os.Handler.handleCallback(Handler.java:883)
7
android.os.Handler.dispatchMessage(Handler.java:100)
8
android.os.Looper.loop(Looper.java:214)
9
com.wanjian.cockroach.Cockroach.safeMode(Cockroach.java:216)
10
com.wanjian.cockroach.Cockroach.access$200(Cockroach.java:26)
11
com.wanjian.cockroach.Cockroach$1.uncaughtException(Cockroach.java:70)
12
java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
13
java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
14
java.lang.Thread.dispatchUncaughtException(Thread.java:2187)

日志4
Input dispatching timed out

ANR Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 13. Wait queue head age: 6499.7ms.)

解析原始
1
org.libpag.PAGSurface.freeCache(Native method)
2
org.libpag.PAGView.freeCache(SourceFile:2)
3
com.lingben.householdrb.activity.MyAiActivity.onDestroy(MyAiActivity.kt:222)
4
android.app.Activity.performDestroy(Activity.java:8057)
5
android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1341)
6
android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4950)
7
android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4994)
8
android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
9
android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
10
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
11
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2025)
12
com.wanjian.cockroach.Cockroach$2.handleMessage(Cockroach.java:129)
13
android.os.Handler.dispatchMessage(Handler.java:103)
14
android.os.Looper.loop(Looper.java:214)
15
android.app.ActivityThread.main(ActivityThread.java:7386)
16
java.lang.reflect.Method.invoke(Native method)
17
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
18
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1072)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.