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

Tweener の _updateTask で "Uncaught RangeError: Maximum call stack size exceeded" #171

Open
fukuyama opened this issue Aug 12, 2015 · 7 comments

Comments

@fukuyama
Copy link
Contributor

tweener を使うときに以下の条件で_updateTask() の無限再帰呼び出しが発生します。

  • call か set のみの _tasks で、loop フラグを true にする
  • loop フラグを true にしたまま、tweener.clear() のみを呼び出す
@simiraaaa
Copy link
Contributor

callとsetのみはTweenerではなくupdateかenterframeイベントを使用
clearはタスクをクリアするだけなので、アニメーションを止める場合はpauseを使用

これで大丈夫じゃないかと思います

@simiraaaa
Copy link
Contributor

clearはニュアンス的にアニメーション無くすような感じなのでclearでloopにfalseセットすれば、clearの方は大丈夫ですね

@fukuyama
Copy link
Contributor Author

たしかに call / set のみの tweener は、使う側で気を付けるのはありかも。wait いれれば、動かすこともできるし、
MenuDialog は、enterframe でやってみて、問題なさそうでした。

loop を clear で、初期化してないのは、何か理由があるのかな~?とか思ってました^^
クリアしても問題ないですよね。たぶん。

clear しなくても _tasks が空で、loop == ture にすると、やっぱりひっかるので…
_updateTask の loop 部分で、_index を確認すれば防げると思うけど、どうでしょうか?

            var task = this._tasks[this._index];
            if (!task) {

                if (this.loop === true && this._index > 0) {
                    this._index = 0;
                    return this._updateTask(app);
                }
                else {
                    this.isPlaying = false;
                }

                return ;
            }

@simiraaaa
Copy link
Contributor

そこでチェック入れてもいいですが、普通に考えても何もアニメーション追加せずにsetLoop(true)するのはおかしいですよねw

clearは意図的にアニメーションクリアするので、こっちでloop=falseするのは入れといたほうがいいですね。
clearにこれがないのは確か、loopをあとから追加したからだと思います。

@fukuyama
Copy link
Contributor Author

なんとなく、どんなふうに使っても致命的なエラーには、ならないようにしておいた方が使う人にとっては良いかな~と思うところもあるんですよね。初心者な人とか特に。
でも、あまりガチガチにチェックして処理が重くなっても嫌だし…ってことで、このくらいなら良いかな?と

call / set の方は、うまい解決方法が思いつかない、使う人が注意で 😄

@simiraaaa
Copy link
Contributor

call、setは一応、一度でもcallとset以外のアニメーションがセットされたかどうかのフラグを作ってそれでチェックすればできると思います。(このフラグはclearで消さないといけない)

@fukuyama
Copy link
Contributor Author

MenuDialog の方は、enterfarme にして、プルリクします。

fukuyama added a commit to fukuyama/tmlib.js that referenced this issue Aug 13, 2015
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

2 participants