-
Notifications
You must be signed in to change notification settings - Fork 320
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
infinite loop and OOM caused by wrong passedTime #53
Comments
one solution is to fix incorrect modification of |
for example: // tick 1
this.time === 1000;
Date.now === 1100;
passedTime got 100;
this.time += 100;
this.time === 1100;
// change system time from 1100 to 900
// tick 2
this.time === 1100;
Date.now === 900;
passedTime got -200;
this.time -= -200;
this.time === 1300;
// tick 3
this.time === 1300;
Date.now === 901;
passedTime got -399;
this.time -= -399;
this.time === 1699;
// tick 4
this.time === 1699;
Date.now === 902;
passedTime got -796;
this.time -= -796;
this.time === 2495;
// tick N
this.time boom to Infinity
passedTime boom to -Infinity |
I also found the same mistake exists in the implemention of CSharp and Java, but I have not debug into the inner processing logic and I am not sure whether it will lead to infinite loop. but it is ok in the implemention of CPP...(it does not use |
thanks to @qingyangmoke 's commit fix/modifytime_2018_01_28 he fix same error when timeScale not equal to 1.0 here is PR commit 001c609 |
clock 内部的系统时间不应该是一个递减的值,我们期望时间应该始终向前流动,所以才尝试修正负向的流逝时间,但是完全没有考虑到因此可能带来的问题,感谢提供的例子信息,我们会尝试让这个地方的逻辑更合理 :) |
回复及时啊:) 烦请关注/推动对应同事关注 |
一定会将其他语言的逻辑也都统一的,请放心:) |
we found that js enter infinite loop and go into OutOfMemory soon when system time changed backward with
dragonBoneesJS@5.0.0
。And I will show the whole steps in master branch.passedTime
got negative number when system time changed backward at WorldClock.ts#L106this.time -= passedTime
madethis.time
become larger indeed ( subtracting a negative number means adding a positive number) at WorldClock.ts#L114this.time
became a huge number such as1e308
passedTime
got a negative maximum after it is subtracted from the hugethis.time
in next tick at WorldClock.ts#L106passedTime
such as-1e308
at WorldClock#45negative -1e308
changed topositive 1e308
at Animation.advanceTime#L151this._time
gotInfinity
afterthis._time += passedTime;
due to JavaScript Number accuracy issues at AnimationState.advanceTime #L744this.currentTime
got NaN at TimelineState.update#L149frameIndex
get undefined becauseNaN
at TimelineState.update#L150crossedFrameIndex(always number) === frameIndex(always undefined)
at TimelineState.update#L247The text was updated successfully, but these errors were encountered: