【版本信息】
4.5.52
【平台信息】
iOS 原生 SwiftUI
【实际的情况】
通过 UIViewRepresentable 将 PAGView 封装成 SwiftUI View 使用,通过 Coordinator 添加 PAGViewListener onAnimationUpdate 代理的时候,在 swift 6 严格模式下运行App,当触发 onAnimationUpdate 时 App 崩溃。实测下来是 PAGView 内部异步调用 onAnimationUpdate 代理方法导致的,onAnimationUpdate 方法跨线程调用,导致出错。
实测通过 pagView.setSync(true) 方式可以解决这个问题。
现在我有两个问题
- PAGView 源码里 sync 的注释说,无论动画是否异步运行,所有侦听器回调都将在UI线程上调用。原注释内容:Indicates whether the animation is allowed to run in the UI thread. The default value is NO. Regardless of whether the animation runs asynchronously, all listener callbacks will be called on the UI thread. 那么我的问题是,为什么 onAnimationUpdate 会在异步线程里面调用?是你们的bug吗?后续可考虑修复?
- 当前我通过 setSync(true) 的方式解决了我的问题,那么我修改这个设置之后,是否会有性能问题?会造成主线程卡顿或者阻塞吗?
期待你的回复
【Demo及附件】
崩溃堆栈信息如下:

【版本信息】
4.5.52
【平台信息】
iOS 原生 SwiftUI
【实际的情况】
通过 UIViewRepresentable 将 PAGView 封装成 SwiftUI View 使用,通过 Coordinator 添加 PAGViewListener onAnimationUpdate 代理的时候,在 swift 6 严格模式下运行App,当触发 onAnimationUpdate 时 App 崩溃。实测下来是 PAGView 内部异步调用 onAnimationUpdate 代理方法导致的,onAnimationUpdate 方法跨线程调用,导致出错。
实测通过 pagView.setSync(true) 方式可以解决这个问题。
现在我有两个问题
期待你的回复
【Demo及附件】
崩溃堆栈信息如下: