如何错误处理 requestAnimationFrame 函数

问题描述

正在寻找一种方法来检查 animate() 函数中的任何错误。如果 animate() 函数中发生任何错误,我的浏览器就会崩溃并且我的计算机会发热。

我试图将代码放在 try/catch 处理程序中,但这不起作用

animate(){
    this.renderer.render(this.scene,this.camera);

    try {
       // functions that update scene
    } catch (error) {
        gsap.ticker.remove(() => this.animate());
        console.error(error);
    }
}

Codepen Example

关于如何正确处理“requestAnimationFrame”/gsap.tick 循环的任何建议?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)