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

当快速多次切换动画速度后,整个小程序就会卡死甚至崩溃了 #27

Closed
bigkrys opened this issue Dec 21, 2020 · 5 comments

Comments

@bigkrys
Copy link

bigkrys commented Dec 21, 2020

No description provided.

@seasonhuang
Copy link
Collaborator

@bigkrys 请提供个代码片段试试

@bigkrys
Copy link
Author

bigkrys commented Jan 13, 2021

` draw(animationData,assetsPath,animationSpeed,loop,autoplay){
wx.createSelectorQuery().select('#c1').node(res => {
const canvas = res.node
context = canvas.getContext('2d')
let rate = 750/1334
canvas.width = (_that.data.width) * _that.data.pixelRatio
canvas.height = (_that.data.width * rate ) * _that.data.pixelRatio
canvas.top = 0
canvas.left = 0
context.scale(_that.data.pixelRatio, _that.data.pixelRatio)
lottie.setup(canvas)//要执行动画,必须调用setup,传入canvas对象
_that.changeAnimationType(animationData,assetsPath,animationSpeed,loop,autoplay)
}).exec()
},
changeAnimationType(animationData,assetsPath,animationSpeed,loop,autoplay){
animation = lottie.loadAnimation({
loop: loop,//是否循环播放(选填)
autoplay: autoplay,//是否自动播放(选填)
animationData:animationData,
rendererSettings:{
context:context,
},
assetsPath:assetsPath,
})
animation.setSpeed(animationSpeed)
},
changeAnimation(animationType,animationSpeed){
console.info('_that.data.animationType',_that.data.animationType)
_that.setData({
animationType:animationType
})
let animationData = null,assetsPath = '',loop = true,autoplay = true
if(animationType == 0){
//跑步
animationData = require("../../animation/running/running.js")
}else if(animationType == 5){
//走路
animationData = require("../../animation/walking/walking.js")
}
if(animation && animation.animationID){
_that.changeAnimationType(animationData,assetsPath,animationSpeed,loop,autoplay)
}else{
_that.draw(animationData,assetsPath,animationSpeed,loop,autoplay)

}

},
`
当调用loadAnimation超过2次的时候,整个页面就会卡死,在安卓手机下甚至会崩溃

@seasonhuang
Copy link
Collaborator

@Zenfeder
Copy link

@bigkrys 请问小程序奔溃的问题有解决方案么?

@Genuifx
Copy link

Genuifx commented Mar 31, 2022

每次重新setup一下

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

4 participants