lottie-miniprogram icon indicating copy to clipboard operation
lottie-miniprogram copied to clipboard

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

Open bigkrys opened this issue 3 years ago • 5 comments

bigkrys avatar Dec 21 '20 08:12 bigkrys

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

seasonhuang avatar Jan 13 '21 06:01 seasonhuang

` 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次的时候,整个页面就会卡死,在安卓手机下甚至会崩溃

bigkrys avatar Jan 13 '21 08:01 bigkrys

@bigkrys 有没有完整的代码片段 https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

seasonhuang avatar Mar 15 '21 08:03 seasonhuang

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

Zenfeder avatar Aug 17 '21 12:08 Zenfeder

每次重新setup一下

Genuifx avatar Mar 31 '22 08:03 Genuifx