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

MyPaint slow/lagging once symmetry tool is enabled #883

Open
hzulla opened this issue Dec 17, 2017 · 6 comments
Open

MyPaint slow/lagging once symmetry tool is enabled #883

hzulla opened this issue Dec 17, 2017 · 6 comments
Labels
cat.Canvas Issue relates to the canvas cat.Performance Issue is related to application performance platform.Linux Issue is reported on Linux type.Enhancement Issue requests feature.

Comments

@hzulla
Copy link

hzulla commented Dec 17, 2017

Description of the problem

Using MyPaint on a relatively slow RPi3 computer with a Wacom tablet works fine. Unless the user activates the symmetry tool. Once adding a symmetry line to the drawing, the drawing on the screen significantly lags behind the tablet pen movements.

Basic system details

MyPaint 1.2.0 on Raspbian Stretch (November 2017) using Raspberry Pi Desktop

Steps to reproduce

  1. Connect Wacom tablet to RPi3
  2. Start MyPaint
  3. Draw a little, notice the screen drawing not lagging (at least, not much)
  4. Add symmetry line
  5. Draw again, notice the screen drawing lagging a lot
@achadwick achadwick added the cat.Performance Issue is related to application performance label Jan 2, 2018
@achadwick
Copy link
Member

Symmetry mode necessitates more work from the brush engine, that's just a fact of life.

Q: does the laggy behaviour go away after the symmetry mode is turned off?

I would normally suggest using a newer MyPaint, but I'm not sure that would really help you with this particular machine.

Whoever tries to deal with this should probably have a look at DEBUGGING.md#Profiling to get started.

@hzulla
Copy link
Author

hzulla commented Jan 2, 2018

Yes, the lag goes away when the symmetry tool is inactive again.

@briend
Copy link
Contributor

briend commented Mar 17, 2019

For anyone looking at this, try turning on Debug-->Visualize Rendering. With symmetry mode active the bounding box for redrawing the dirty tiles becomes bigger as you move away from the center line. If you turn on horizontal and vertical the problem becomes exponential as you very quickly begin to redraw the entire screen. Ouch!

I don't know how to begin fixing this. . . maybe make the brush engine return separate bounding boxes for each dab draw instead of one giant bounding box.

@jplloyd
Copy link
Member

jplloyd commented Nov 7, 2019

For anyone looking at this, try turning on Debug-->Visualize Rendering. With symmetry mode active the bounding box for redrawing the dirty tiles becomes bigger as you move away from the center line.

Yep, the problem is indeed in the redrawing in MyPaint. libmypaint does not even break a sweat when rendering e.g. rotational symmetry with 50 rotational lines (unless the brush itself is heavy).

If you turn on horizontal and vertical the problem becomes exponential as you very quickly begin to redraw the entire screen. Ouch!

Not quite exponential, but a very nice visual example of quadratic complexity ;-)

I don't know how to begin fixing this. . . maybe make the brush engine return separate bounding boxes for each dab draw instead of one giant bounding box.

Funnily enough, @jonnor suggested this in a comment in libmypaint/brushlib over 7 years ago, but I don't think it was ever implemented (no need at the time, I guess). At any rate, I implemented a naive version of multi-rectangle bounding boxes today, and while there is still some lag on fast strokes, it's a huge improvement for the new symmetry modes overall!

Edit: With the separate rectangles, the bottleneck moves to the 16b->8b tile conversion function(s?) in lib/pixops.cpp (severity depending on the total area of updated regions that are visible in any viewport).

Now that those tile conversions are a bit heavier (due to the eotf exponentiation), it might be worth implementing multithreading for that part of the rendering.

@jplloyd
Copy link
Member

jplloyd commented Nov 17, 2019

The quadratic behavior is fixed with commits 0dd0de8 and mypaint/libmypaint@ec0447e

The overall performance is still slower than it needs to be, due to the previously mentioned bottlenecks, but that is not related directly to the symmetry modes (the slowness of the mode is just a symptom of the way redrawing is handled).

@jplloyd jplloyd closed this as completed Nov 17, 2019
@jplloyd
Copy link
Member

jplloyd commented Nov 17, 2019

Actually, I just remembered that there still are performance issues related more closely to the symmetry mode. The fix I referenced above don't fix e.g. line mode being very slow when symmetry is enabled. Presumably the inking mode is just as bad.

@jplloyd jplloyd reopened this Nov 17, 2019
@AesaraB AesaraB added type.Bug Something isn't working as intended platform.Linux Issue is reported on Linux cat.Canvas Issue relates to the canvas type.Enhancement Issue requests feature. and removed type.Bug Something isn't working as intended labels Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat.Canvas Issue relates to the canvas cat.Performance Issue is related to application performance platform.Linux Issue is reported on Linux type.Enhancement Issue requests feature.
Development

No branches or pull requests

5 participants