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

get() and/or pixelDensity() lag since v1.8.0 #7061

Open
ffd8 opened this issue May 20, 2024 · 1 comment
Open

get() and/or pixelDensity() lag since v1.8.0 #7061

ffd8 opened this issue May 20, 2024 · 1 comment

Comments

@ffd8
Copy link
Contributor

ffd8 commented May 20, 2024

Topic

This is pretty odd issue – but ever since p5.js version 1.8.0 was released, nearly all of my previous sketches which experiment with visual feedback, using get() (especially when combined with pixelDesnity() for upscaling images) – slowed to a halt (even on an M1 Max). I know some significant changes happened to both of these functions in that release, and that there were some sizing issue that got cleared up, however is there a chance an accidental bug still exists in the updates that is causing this?

Example:
https://editor.p5js.org/ffd8/sketches/r367LzyK7

  • toggle on v1.9.2 and uncomment line 4, prod = 10 – which lags out on my M1 Max, however with v1.7.2 (or any version prior) it works just fine.

Sure, this is using pixelDensity() in a weird way – but these sketches worked fine on a mobile phone with normal pixelDensity(), however if I try updating to later versions, they also lag out... so I believe the issue is with get().

@davepagurek
Copy link
Contributor

Previously, get() would always return an image of pixel density 1, regardless of the density of the main canvas, making it impossible to capture the full resolution of the canvas to a p5.Image. Now, it continues to use the same density as the main canvas. So while previously get() would return an image 1/100th of the size of the main canvas if you used pixelDensity(10), it will now be using the full size.

I think if you wanted to replicate the old behaviour, you would have to createGraphics(width, height), set its pixel density to 1, and then use image() to draw the main canvas to the graphic (which is essentially what it was doing under the hood before.) I tried making a little demo here: https://editor.p5js.org/davepagurek/sketches/qA0891h1z

Also, in that version, you can try setting the pixel density of the graphic to 10 too, and it doesn't lag nearly as much as the image version. Seems to be garbage collection is the main thing making it lag, so if you reuse a graphic rather than making new images, it seems to run more smoothly.

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