siggame / Viseur

Visualizer for the Cadre AI game framework
http://vis.siggame.io
MIT License
5 stars 10 forks source link

Visualizer randomly pauses #48

Open Tarnasa opened 5 years ago

Tarnasa commented 5 years ago

The visualizer will randomly pause, and must be manually unpaused by clicking the pause/unpause button.

From src/viseur/time-manager.ts

        this.viseur.gui.events.playbackSlide.on((value) => {
            const index = Math.floor(value);
            const dt = value - index;
            const current = this.getCurrentTime();
            if (Math.abs(value - current.index - current.dt) > 0.10) {
                // the change in time was too great, they probably clicked far away
                this.pause(index, dt);
            }
        });

While the intent of this code is to pause the visualizer when the user clicks on the slider, it seems to also trigger randomly because the slider is not always in sync with the timer.

I'm not sure of the reason for the desynchronization, the pauses are always at different deltas even for the same gamelog, so I'm inclined to believe there is some sort of race condition.

A proper fix would distinguish human-generated clicks on the slider from programmatic changes to the slider's value, however the necessary information to distinguish (event.isTrusted) does not seem to be piped through.

An easier fix would be to replace this.pause(index, dt); with this.setTime(index, dt); So that changes to the slider never cause a pause. If the user wants to jump to a specific point while paused, they can simply pause, and then click.