p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

Slow since version 1.0

Open peeter2 opened this issue 1 year ago • 4 comments

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [X] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [X] WebGL
  • [ ] Build Process
  • [ ] Unit Testing
  • [ ] Internalization
  • [ ] Friendly Errors
  • [ ] Other (specify if possible)

p5.js version

1.9.0

Web browser and version

all

Operating System

all

Steps to reproduce this

The performance is still slow. I have created a speed test sketch that performs really fast on versions older than 1.0.0. It is very fast on version 0.9.0 for example as in this example: https://editor.p5js.org/shangtsung/sketches/j080fh87C

And it is very slow on every newer version starting from version 1.0.0 (no matter what browser or device) as you can see when you change p5.js version number in the sketch.

Seems like new version is not always better. Any idea when this bug will be fixed?

peeter2 avatar Jan 15 '24 16:01 peeter2

I seem to have run into a similar issue.

This sketch seems to run much faster on version <= 1.5.0 https://codepen.io/kemmel-dev/pen/LYvzXqp?editors=1111

codevogel avatar Apr 01 '24 11:04 codevogel

First step is to find out which commit causes the performance to down.

some records

git diff v1.5.0..v1.6.0 --stat
 src/webgl/3d_primitives.js                              |  228 ++++++++++---
 src/webgl/material.js                                   |   21 +-
 src/webgl/p5.Camera.js                                  |   49 +--
 src/webgl/p5.Geometry.js                                |  252 ++++++++++++--
 src/webgl/p5.RenderBuffer.js                            |    7 +
 src/webgl/p5.RendererGL.Immediate.js                    |   41 ++-
 src/webgl/p5.RendererGL.Retained.js                     |    8 +
 src/webgl/p5.RendererGL.js                              |  143 ++++++--
 src/webgl/p5.Shader.js                                  |   18 +-
 src/webgl/p5.Texture.js                                 |   16 +-
 src/webgl/shaders/basic.frag                            |    6 +-
 src/webgl/shaders/font.frag                             |    6 +-
 src/webgl/shaders/font.vert                             |   16 +-
 src/webgl/shaders/light.vert                            |    7 +
 src/webgl/shaders/light_texture.frag                    |   10 +-
 src/webgl/shaders/line.frag                             |   47 ++-
 src/webgl/shaders/line.vert                             |  140 +++++++-
 src/webgl/shaders/normal.vert                           |    6 +
 src/webgl/shaders/phong.frag                            |   10 +-
 src/webgl/shaders/phong.vert                            |    7 +
 src/webgl/shaders/point.frag                            |   30 +-
 src/webgl/shaders/vertexColor.frag                      |    4 +-
 src/webgl/text.js                                       |   24 +-

so

git diff v1.5.0..v1.6.0 -- src/webgl/*

could print the diff

asukaminato0721 avatar May 04 '24 18:05 asukaminato0721

This is a tough one for me because on my computers, I don't notice the same slowdown other commenters are seeing (see also https://github.com/processing/p5.js/issues/6438, this is possibly a duplicate of the same issue?) Might need some community help bisecting to find the commit.

davepagurek avatar May 05 '24 05:05 davepagurek

I seem to have run into a similar issue.

This sketch seems to run much faster on version <= 1.5.0 https://codepen.io/kemmel-dev/pen/LYvzXqp?editors=1111

I think this is a separate issue: this one is due to stroke quality being higher in new versions of p5. Turning off strokes makes this sketch run fast again, and this was a known tradeoff we made. A suggestion for p5 2.0 was made to add a low fidelity line rendering option in https://github.com/processing/p5.js/issues/6678#issuecomment-2076172350 if you're interested!

OP's sketch was having issues even without lines.

davepagurek avatar May 05 '24 05:05 davepagurek