hapjs-platform / hapjs

快应用标准框架实现,支持快应用的加载、运行、渲染,提供必要API的支持
Apache License 2.0
186 stars 118 forks source link

Android 13出现较多Sorting went bad, the start event should always be at index 0错误 #605

Open charles-chai opened 1 year ago

charles-chai commented 1 year ago

Sorting went bad, the start event should always be at index 0 java.lang.UnsupportedOperationException: Sorting went bad, the start event should always be at index 0 at android.animation.AnimatorSet.sortAnimationEvents(AnimatorSet.java:1638) at android.animation.AnimatorSet.createDependencyGraph(AnimatorSet.java:1534) at android.animation.AnimatorSet.getTotalDuration(AnimatorSet.java:1745) at android.animation.AnimationHandler.lambda$new$0$android-animation-AnimationHandler(AnimationHandler.java:224) at android.animation.AnimationHandler$$ExternalSyntheticLambda0.doFrame(Unknown Source:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1384) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1394) at android.view.Choreographer.doCallbacks(Choreographer.java:1013) at android.view.Choreographer.doFrame(Choreographer.java:904) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1366) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:211) at android.os.Looper.loop(Looper.java:300) at android.app.ActivityThread.main(ActivityThread.java:8152) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)

charles-chai commented 1 year ago

问题原因: 这个问题和锁屏时google新增的动画处理逻辑相关。 之前版本中,锁屏后无限循环的动画依然会触发,谷歌对这个问题进行了处理;这个处理导致Android13上的动画会崩溃并报错。

https://android.googlesource.com/platform/frameworks/base/+blame/4440afb9352b326fca3840bac64bd4b6df491413/core/java/android/animation/AnimationHandler.java

    /**
161      * This method is called from ViewRootImpl or WallpaperService when either a window is no
162      * longer visible (enable == false) or when a window becomes visible (enable == true).
163      * If animators are not properly disabled when activities are backgrounded, it can lead to
164      * unnecessary processing, particularly for infinite animators, as the system will continue
165      * to pulse timing events even though the results are not visible. As a workaround, we
166      * pause all un-paused infinite animators, and resume them when any window in the process
167      * becomes visible.
168      */
169     public static void requestAnimatorsEnabled(boolean enable, Object requestor) {
170         getInstance().requestAnimatorsEnabledImpl(enable, requestor);
171     }
charles-chai commented 9 months ago

复现方法:"router_uri":"hap://app/com.lingmao.quickapp/reader?_PARAM_PAGEANIMATION=%7B%22openEnter%22%3A%22none%22%2C%22closeEnter%22%3A%22none%22%2C%22openExit%22%3A%22none%22%2C%22closeExit%22%3A%22none%22%7D&recommended_position_name=deeplink&chapterId=&last_page=%E9%A6%96%E9%A1%B5&recommended_page_name=&recommended_position_id=&recommended_plate_name=&bookId=221195" 使用这个uri进行跳转,然后过滤日志 ExtensionManager,在快应用打开,图标闪过白屏的时候立刻切到后台,这时候日志如果显示调用了system.animation enable/play 方法,等待10s中左右框架就会崩溃