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

Disable Tone.Draw() programmatically or automatically #194

Closed
JackCA opened this issue Feb 7, 2017 · 3 comments
Closed

Disable Tone.Draw() programmatically or automatically #194

JackCA opened this issue Feb 7, 2017 · 3 comments

Comments

@JackCA
Copy link
Contributor

JackCA commented Feb 7, 2017

The new Draw functionality is really cool and it's great to see it in the newest release.

However, there doesn't seem to be a way to disable it for scenarios where there is already an existing usage of requestAnimationFrame running alongside it.

Using a single requestAnimationFrame can have a positive performance impact because the self of running the function itself can be impactful. Looks like there is other minor overhead from the _drawLoop function as well.

Here is a screenshot of the profile I ran to discover this:

screenshot 2017-02-07 15 56 51

Would it be possible to either provide a mechanism to programmatically disable it or to not have it running the callback until there is a scheduled event?

I can help with implementation with a bit of guidance.

@tambien
Copy link
Contributor

tambien commented Feb 8, 2017

Makes sense. I think the best fix would be if the draw loop only ran when something is pushed onto the events queue, and that it stops updating when the queue is empty.

While i was thinking through how to do it, i went ahead an implemented it. (I'll commit it in a moment). but thanks for the offer!

Do you think it'd be useful to be able to manually control the updating? for example, setting autoupdate = false and then manually call Tone.Draw.update() from within an animation frame. I wasn't sure if there is much overhead with scheduling multiple requestAnimationFrames each frame.

@JackCA
Copy link
Contributor Author

JackCA commented Feb 9, 2017

@tambien thanks for looking at this.

I agree that the automatic scheduling works well (especially in my situation as I'm not currently using the Draw functionality).

As to manually being able to update, yes I think that could be useful for power users who are using Draw but want to manage when it is invoked manually in their own loop.

🎶

@JackCA
Copy link
Contributor Author

JackCA commented Feb 14, 2017

@tambien now that I'm looking at this a little closer, the autoupdate = false option would be more helpful in my personal scenario. I have scheduled events (in a Part) but I'm not using the drawloop for anything at this time.

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