-
Notifications
You must be signed in to change notification settings - Fork 7
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
performance improvement #6
Comments
Hey @micuat thanks for having a look into this and super interesting to learn that
Within P5LIVE, I still get quite good speeds using the existing and webcam – demo w/ circle |
original version with the example I provided above (btw I updated p5.js to 1.4.0) so... I don't know if I made a fair comparison, I think 1) not only the blocking issue,
I directly added to the library: https://glitch.com/edit/#!/p5-glitch-testing?path=p5.glitch.edit.js L173
I think
or for example,
I think internally everything is a canvas... so there shouldn't be a problem using a native canvas as a webgl texture, but p5 might have some metadata that has to be passed on... I'm not sure.
it seems working fine, but when I increase the speed of the circle (e.g., `(frameCount * 10) % width) I start to see hiccup. |
Playing with it in this remix, and I agree it is definitely getting a better/smoother framerates. It's clear that A few things I noticed while playing around:
UPDATE: figured out a way to fail quietly! first implemented a |
I've been testing if I can improve the performance
https://glitch.com/edit/#!/p5-glitch-testing
https://p5-glitch-testing.glitch.me/
(note that
frameRate()
is deceiving so I added a moving circle to visualize the framerate)some changes:
toDataURL
seem to block everything on the page. It is better to usetoBlob
, but as it is asynchronous, functions likelimitBytes
cannot be used in the way how it is implemented. In the test I hardcoded it in the library...p5.loadImage
seems not efficient so it may be better to use the base64 string directly into<img>
. Then you can render it usingp5.drawingContext.drawImage()
... perhaps through a helper function.The result is still not super smooth, but the difference is perceivable especially that the improved one is not blocking other processes (the circle's movement is jaggier in the original version)
Next step is to propose a PR but I don't know if it's possible without changing the API as explained above.
The text was updated successfully, but these errors were encountered: