-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Servo animation enqueue is buggy #1837
Comments
So you see "2 end" but never "3 start" correct? No errors thrown? |
That is correct, I can give you more insight if you wish. For some reason, I've added some console logs inside I suspect some kind of race conditions. I think this could also be nice to buffer things before everything starts. Adding an If I can contribute, just let me know. I'm also doing a big work updating typescript definition typings DefinitelyTyped/DefinitelyTyped#67063 |
@dtex Any idea on that ? |
I don't know if it's a race condition, or we're just popping things off the queue too aggressively. I'll set up a test and see if I can find where that's happening. |
Alright thank you very much, Keep me in touch, I would be really pleased because i need this feature, I'm trying debugging on my side. |
@dtex Issue happen on Line 94 in 094bf6c
Added this code Constructorclass Animation extends Emitter {
constructor(target) {
super();
// Necessary to avoid loading temporal unless necessary
if (!temporal) {
temporal = require("temporal");
}
console.log("Before constructor assign", this.segments?.length)
Object.assign(this, new Animation.Segment());
console.log("After constructor assign", this.segments?.length)
this.defaultTarget = target || {};
} Output is
This is initializing the array to 0, which is fine. Segments shifting in loop console.log("Before shift", this.segments.length)
const firstElement = this.segments.shift()
console.log("After Shift",this.segments.length)
Object.assign(this, new Animation.Segment(firstElement));
console.log("After assign",this.segments.length) Output is
It's
if ((this.progress === 1 && !this.reverse) || (progress === this.loopback && this.reverse)) {
if (this.loop || (this.metronomic && !this.reverse)) {
if (this.onloop) {
this.onloop();
}
if (this.metronomic) {
this.reverse = this.reverse ? false : true;
}
this.normalizeKeyframes();
this.progress = this.loopback;
this.startTime = Date.now() - this.scaledDuration * this.progress;
this.endTime = this.startTime + this.scaledDuration;
} else {
this.isRunning = false;
if (this.oncomplete) {
process.nextTick(() => this.oncomplete());
}
console.log("loopFunction",this.segments.length)
if (this.segments.length > 0) {
process.nextTick(() => this.next());
} else {
this.stop();
} FIXESI've been able to fix the code doing this Object.assign(this, new Animation.Segment(firstElement), {segments: this.segments}); We need to re-apply segments otherwise we crush the segment array each time. Or we need to pass current second to options so I can make a pull request if you think it's okay. |
@dtex @rwaldron Hi I'm trying to sequence animations on 3 servos using this code:
Using this code, 3 never starts… I don't get why.
Have a look at #1376 but still having issues.
Also, it's impossible to
pause
the sequence before something has been enqueued.Any idea?
The text was updated successfully, but these errors were encountered: