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

browser rendering method can cover up button effects #185

Open
qiemem opened this issue Dec 10, 2014 · 3 comments
Open

browser rendering method can cover up button effects #185

qiemem opened this issue Dec 10, 2014 · 3 comments

Comments

@qiemem
Copy link
Member

qiemem commented Dec 10, 2014

To reproduce, open up this model in Tortoise and NetLogo. setup, go, and then hit the crt num-turtles... button over and over. In NetLogo, you'll see turtles pop up briefly and disappear. Not so in Tortoise.

My first thought here was frame skipping. However, button presses trigger redraws, and when you disable frame skipping altogether, the problem persists.

After experimenting, I'm pretty sure what's happening is that the browser is drawing everything to a back buffer and then only flips buffers every so often. The go loop uses requestAnimationFrame, which queues a repaint and sets up the callback to trigger right before the repaint occurs (the callback being forever buttons and redrawing) right before the browser repaints. I think what's happening is that, when the button is pressed, another repaint has already been queued with the go loop callback set to come before. So, the button draws the turtles to the back buffer, but then before it renders to the display, the go loop runs, running go on top of it, clearing the turtles and overwriting the back buffer. Then the display updates. Indeed, when you set the speed slider way down, you can get the turtles to show up. This is because the forever loop skips calling go at slow speeds.

Honestly, I'm not sure this is actually fixable. It would be fixable if we could control the buffering behavior ourselves. That said, not sure if it would really be worth it even if it were possible.

@TheBizzle
Copy link
Member

Link the model?

@qiemem
Copy link
Member Author

qiemem commented Dec 10, 2014

Possible fix: cancel and re-request the animation frame from button presses to bump it from the queue. Not sure if it would work, it would likely be up to browser implementation, and it's really pretty gross. I don't like this solution, but if this becomes a serious problem, it might be worth trying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants