libpag icon indicating copy to clipboard operation
libpag copied to clipboard

Android平台某手机无法正常播放动画

Open YoungPeak opened this issue 5 months ago • 1 comments

【版本信息】

4.4.35

【平台信息】

Android 原生,华为Pura 70,HBN-AL00,Android 12

【预期的表现】

动画可以正常播放

【实际的情况】

动画一闪而过,没有收到onAnimationStart回调,在很短时间内收到了onAnimationEnd回调

【Demo及附件】

代码片段:

file?.let {
    pagBackground = PAGView(context)
    pagBackground?.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
    pagBackground?.apply {
        binding.clContainer.addView(this, 1)
        setPathAsync(it.absolutePath) {
            PagTrack.reportPostAction("setPathAsync_callback")
            setScaleMode(PAGScaleMode.Zoom)
            setRepeatCount(-1)
            addListener(object: PAGViewListener {
                override fun onAnimationStart(p0: PAGView?) {
                    postDelayed({
                        binding.llContainer.visibility = View.VISIBLE
                        binding.llContainer.scaleX = 0.5f
                        binding.llContainer.scaleY = 0.5f

                        binding.llContainer.animate().scaleX(1f).scaleY(1f).setDuration(100).start()
                    }, 50)
                }

                override fun onAnimationEnd(p0: PAGView?) {
                    PagTrack.reportPostAction("onAnimationEnd")
                }

                override fun onAnimationCancel(p0: PAGView?) {
                }

                override fun onAnimationRepeat(p0: PAGView?) {
                }

                override fun onAnimationUpdate(p0: PAGView?) {
                }

            })

            post {
                play()
            }
        }
    }
}

YoungPeak avatar Jun 17 '26 03:06 YoungPeak

感谢你的使用与反馈!

经分析确认,该问题有两个层面:

  1. 用户侧:如果开发者选项中的 "Animator Duration Scale"(动画时长缩放) 设为 0(关闭动画),系统会跳过所有动画的播放过程,导致动画只渲染第一帧即结束。建议通过以下命令确认:

```bash adb shell settings get global animator_duration_scale ```

如果输出为 0,说明系统动画已被关闭。

  1. libpag 侧:在上述情况下,PAGAnimator 的 onAnimationStart 回调确实没有被调用(直接跳到了 onAnimationUpdate 和 onAnimationEnd),这不是预期行为。我们已经修复了该问题,修复内容将包含在后续版本中。

建议你升级到最新的 release/4.4 版本或者 release/4.5 版本验证。

CodeJhF avatar Jun 22 '26 08:06 CodeJhF