After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 479875 - performance problem drawing a complex selection
performance problem drawing a complex selection
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: User Interface
2.4.x
Other All
: Low minor
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
: 468658 472828 493284 495652 498550 502673 506806 508632 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-09-24 16:03 UTC by Régal
Modified: 2010-08-26 18:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Result of bug (140.45 KB, image/jpeg)
2007-09-25 13:07 UTC, JRd1st
  Details
marching ants with G_PRIORITY_DEFAULT_IDLE (840 bytes, patch)
2008-01-04 14:19 UTC, Hans Breuer
committed Details | Review

Description Régal 2007-09-24 16:03:29 UTC
Steps to reproduce:
1. open a large JPG file (5 MB or larger)with a prominent color.
2. choose the tool "select by color".
3. select the prominent color.
Gimp crashes!!!
This does not happen with small JPG-files


Stack trace:


Other information:
Windows XP
CPU: Pentium 4 HT 3 Gh
Memory: 2.5 GB
Harddisk: 100 GB free
Comment 1 Sven Neumann 2007-09-24 16:10:45 UTC
It would be nice if you could upload an example file somewhere and post an URL here so that we can try to reproduce the problem.
Comment 2 Martin Nordholts 2007-09-24 17:29:56 UTC
I would also be helpful if you specified the exact tool options you use that causes the crash.
Comment 3 Régal 2007-09-24 20:29:25 UTC
(In reply to comment #2)
> I would also be helpful if you specified the exact tool options you use that
> causes the crash.

It happens with any option!
Comment 4 Régal 2007-09-24 20:40:04 UTC
With Gimp 2.2.17 and Gimp 2.3.19 there is no such problem. This makes me think the code has changed, and not in a good way...
Comment 5 Martin Nordholts 2007-09-25 06:36:13 UTC
This might be a rendering problem rather than a Select by Color problem. Does RC3 crash if you make the selection in 2.3.19, save as .xcf (which will keep the selection), and open the image in RC3?
Comment 6 Régal 2007-09-25 09:25:01 UTC
(In reply to comment #5)
> This might be a rendering problem rather than a Select by Color problem. Does
> RC3 crash if you make the selection in 2.3.19, save as .xcf (which will keep
> the selection), and open the image in RC3?

I just figured out that the shortcuts "CTRL-C" and "CTRL-V" work, but you can't use the menu's to copy and paste (neither any other menu when you first click on the picture to select a color with "select by color".
Maybe this will help the programmers to correct the bug...
Comment 7 JRd1st 2007-09-25 13:07:13 UTC
Created attachment 96166 [details]
Result of bug

This pic shows the result of Select by Color on a moderate sized jpg
Comment 8 JRd1st 2007-09-25 13:07:49 UTC
GIMP 2.4 RC3, Vista, 2GB RAM, AMD A64X2

I can confirm this. But GIMP doesn't exactly crash, in my case.  What happens is that the part the tool selects starts to flicker and if you try to open any menus, only the outline of the menu opens around a transparent menu.  But, if I do a CTRL-Z, I can usually undo the select and the program sort of recovers.

I tried this with a tiny jpg and the problem didn't occur, but with even a 667 x 500 jpg, the problem occurred.  Trying this on any large image causes this problem, also.
Comment 9 Sven Neumann 2007-09-25 15:17:01 UTC
Most probably this is a performance problem in the Windows GDK backend. It seems to have problems rendering the selection outline.
Comment 10 Sven Neumann 2007-09-26 08:51:02 UTC
We still need an example image to reproduce this report.
Comment 11 Régal 2007-09-26 14:10:05 UTC
(In reply to comment #10)
> We still need an example image to reproduce this report.

http://picasaweb.google.nl/JefRegal/NatuurfotoS/photo#5114512589173205138
Comment 12 Sven Neumann 2007-09-26 17:50:52 UTC
As expected this is not a problem on Linux/X11.

We did some changes to the selection drawing code compared to GIMP 2.2. Someone should investigate what effect these changes have for calls into GDK. It would also be helpful if someone could use a debugger on Windows and find out where exactly GIMP gets stuck.
Comment 13 Michael Schumacher 2007-09-28 14:09:30 UTC
Could be a duplicate of bug #468658 or vice versa.
Comment 14 Sven Neumann 2007-10-02 16:29:44 UTC
Michael, is this reproducable for you?
Comment 15 JRd1st 2007-10-04 14:05:56 UTC
I have a question concerning this;  if this tool is "Select By Color", why is there a Drop-Down Menu for "Select By:" ?  It would make more sense if the tool options remained the way they are shown to be in figure 12.13 of the help PDF.

Anyway, sometimes this tool works and sometimes it selects too much (it breaks out) and makes GIMP bog down.  The "Fuzzy Select" has the same problem, but not as bad.
Comment 16 Régal 2007-11-03 13:19:23 UTC
(In reply to comment #14)
> Michael, is this reproducable for you?

The same problem still exists in Gimp 2.4.0 and in Gimp 2.4.1
Comment 17 Sven Neumann 2007-11-04 10:50:07 UTC
*** Bug 493284 has been marked as a duplicate of this bug. ***
Comment 18 Sven Neumann 2007-11-12 12:37:22 UTC
*** Bug 495652 has been marked as a duplicate of this bug. ***
Comment 19 Sven Neumann 2007-11-20 19:36:53 UTC
*** Bug 498550 has been marked as a duplicate of this bug. ***
Comment 20 Melissa 2007-11-20 20:21:15 UTC
Comment #8 is exactly my case....so, how can this be fixed? Or can it be fixed?
Comment 21 Melissa 2007-11-20 20:40:43 UTC
(In reply to comment #8)
> GIMP 2.4 RC3, Vista, 2GB RAM, AMD A64X2
> 
> I can confirm this. But GIMP doesn't exactly crash, in my case.  What happens
> is that the part the tool selects starts to flicker and if you try to open any
> menus, only the outline of the menu opens around a transparent menu.  But, if I
> do a CTRL-Z, I can usually undo the select and the program sort of recovers.
> 
> I tried this with a tiny jpg and the problem didn't occur, but with even a 667
> x 500 jpg, the problem occurred.  Trying this on any large image causes this
> problem, also.
> 

Did you ever resolve this issue?
Thanks!
Melissa
Comment 22 Sven Neumann 2007-11-20 21:11:55 UTC
If it was resolved, this bug report would have changed state.
Comment 23 Melissa 2007-11-20 21:22:07 UTC
Sven Neuman...You are a smart-ellic! You could have simply said "no M'am it hasn't...keep checking back for a change of status" If it's hard for you to be polite, maybe you can get someone to make a polite response template for answers to questions that you may get all-too-often, if that is the case. 
This is my first time using this board, so I am not familiar with how things work yet.
I'd appreciate your understanding.
Sincerely,
Melissa
Comment 24 stego 2007-11-23 03:43:15 UTC
I am also experiencing the problem, not only with "select by color", but also with  "fuzzy select" and "free select" (at least after using any of the others).

I also suspect that the problem isn't the selection itself, but the rendering when  complicated selection is active: one sees the re-rendering of the image slowly going on and if we are careful enough to use only the right keyboard shortcuts and mouse clicks, and wait long enough, we can get on with the work (for instance, if we activate the bucket fill, click on the selection and immediately deselect everything, the program gets responsive again and presents the selection filled).

I am using Gimp 2.4.1 now, but 2.4.0 presented the same problem. I tried several values for the number of undo levels, memory used by tiles and undos and I didn't found any improvement or worsening. I use a P4 HT 3.2 with 1 Gb RAM and Win XP SP2, mainly with JPG photos with 8 Mpx.
Comment 25 Sven Neumann 2007-11-23 08:08:23 UTC
The problem is in the drawing routines. There is nothing you can do to fix it but looking at the code. This needs to be fixed in the Win32 backend of GDK or an optimization in the GIMP code could be tried.

Since the main development platform is not affected, this is not likely going to be solved until someone who is actually using Windows sits down and does the necessary work to track down and fix this problem.
Comment 26 Michael Schumacher 2007-12-06 09:33:23 UTC
*** Bug 472828 has been marked as a duplicate of this bug. ***
Comment 27 Michael Schumacher 2007-12-06 09:33:37 UTC
*** Bug 468658 has been marked as a duplicate of this bug. ***
Comment 28 Martin Nordholts 2007-12-09 14:57:59 UTC
*** Bug 502673 has been marked as a duplicate of this bug. ***
Comment 29 fabius 2007-12-09 19:48:55 UTC
If could be of some help I'd found that the problem seems to shows up zooming the image below 100% or, maybe more correct, when the selected area showed in the image window is very large. Hope this helps a bit the gimp4win devs.
Comment 30 Sven Neumann 2007-12-09 21:16:59 UTC
I guess we should try to simplify the selection boundary somehow, probably depending on the zoom ratio. It might help to use a tile-pyramid for the selection mask, similar to the projection. The selection boundary could then be created from the scaled-down mask. But I guess that this wouldn't solve all problems.
Comment 31 Sven Neumann 2007-12-18 10:13:18 UTC
This should be on the 2.4 milestone. If it turns out that the fix is too complex (such as the approach I outlined in comment #30), then we can postpone it to 2.6.
Comment 32 fabius 2007-12-18 10:43:54 UTC
if I could toss my 10c, I would suggest to drop that annoying crossing-eyes moving dashes to a different-looking boundary masking - a still plain red mask would be great to me.
Comment 33 Michael Schumacher 2007-12-18 11:40:09 UTC
... unless you work on a red image.
Comment 34 fabius 2007-12-18 12:13:39 UTC
you gotme - so how about a (very mildly) flashing red mask?
Comment 35 PhotoComiX 2008-01-02 21:56:15 UTC
For who was looking for a workaround (not a solution...)

Simply grow selection of 1 pixel, i can do even when everything is flickering seems solve slowing down and flickering

1 pixel grow don't change much the selection, as visually perceived , but greatly semplify it,(simplify the staus of many  partially selected pixels)  and flickering stop as soon this is done.(at least on my PC )
(then done you may even shrink  back selection of 1 pixel, if needed)
Comment 36 Hans Breuer 2008-01-04 14:15:49 UTC
The workaround would be to increase the marching ants speed to 1000 (instead of the not so recent default 100). The only regression I could find is the change of the default from 300 to 100 (done in revision 20709, 2006-09-04).

Although the implementation on windows is less efficient than on Linux it is possible to bring GIMP down to its knees on Linux as well. With a 2560x2048 image pattern-filled with "Stripes Fine" and selected-by-color, with a marching ants speed of 10 (the minimum) there is no interaction possible anymore.

To overcome the issue I think the marching ants speeds needs to get a priority below the user interface handlers. At the moment it is unconditionally g_timeout_add. Changing to g_time_out_add_full (G_PRIORITY_DEFAULT_IDLE, ...) makes the menu accessible again. Patch follows.
Comment 37 Hans Breuer 2008-01-04 14:19:28 UTC
Created attachment 102120 [details] [review]
marching ants with G_PRIORITY_DEFAULT_IDLE

ok to apply?
Comment 38 fabius 2008-01-04 15:33:55 UTC
at the price to became pesky, I'll try again with my suggestion:
why not to take this opportunitiy to make the selection stuff better? I pointed out before how bothersome are those moving ants for my eyes, so I find a better solution to have an inverted masking of the UNselected zones (just as for the crop selection where you see the outside to crop grayed) because in such a way, I have a clear idea of what is selected and what is not, a thing that I do not have with those ants, expecially having very small selected areas.
Keep in mind that I'm a user not a dev so my suggestion is devoted to a better use from my side not to ease the devs job, therefore I apologise if my post is out of topic in some extent.
Comment 39 Sven Neumann 2008-01-04 16:18:49 UTC
Please commit this change to both branches.

fabius, your comments are inappropriate here as they are not strictly related to the bug report. What you are suggesting would need to be discussed on the gimp-developer mailing-list first.
Comment 40 Michael Natterer 2008-01-04 18:32:47 UTC
Hans, can you please commit this to trunk too?
Comment 41 Sven Neumann 2008-01-04 18:40:30 UTC
Done already:

2008-01-04  Sven Neumann  <sven@gimp.org>

	Merged from gimp-2-4 branch:

	* app/display/gimpdisplayshell-selection.c:
	draw marching ants with G_PRIORITY_DEFAULT_IDLE; fixes bug #479875.
Comment 42 Sven Neumann 2008-01-04 18:41:59 UTC
Should we also change the default marching-ants speed back to 300? Perhaps only on the Windows platform?
Comment 43 Hans Breuer 2008-01-04 18:57:45 UTC
I was about to merge it myself but it took some time to make gimp-2.5 compile at all on win32. When I was finally through it I got a conflict because Sven was too fast ;)

Regarding the marching ants speed I don't think we need special casing on win32. It just gets the 100% cpu load a little bit faster there. But I'm uncertain if 10Hz of display update is appropriate at all. If you look at the selection from my test image the only thing visible is some quite disturbing flickering. Of course that wont change much with 300ms cycle instead of 100. Some more smart selection visualization - as mentioned by Sven above - seems to be the better (long-term) solution.
Comment 44 Sven Neumann 2008-01-04 19:09:18 UTC
Shouldn't hurt to reduce the speed somewhat. I have applied this to both branches.

2008-01-04  Sven Neumann  <sven@gimp.org>

	* app/config/gimpdisplayconfig.c: changed the default marching ants
	speed to 200.

Lowering the priority and severity of this bug report...
Comment 45 Sven Neumann 2008-01-09 11:39:20 UTC
*** Bug 506806 has been marked as a duplicate of this bug. ***
Comment 46 Sven Neumann 2008-01-11 10:28:07 UTC
*** Bug 508632 has been marked as a duplicate of this bug. ***
Comment 47 Sven Neumann 2008-07-13 20:41:28 UTC
We don't have a clever plan on how to improve this and it should not block the release. Let's bump it to the 2.8 milestone.
Comment 48 Michael Schumacher 2009-08-10 22:51:26 UTC
For some users, the flickering has been traced back to a bug in Nvidia's drivers.
Comment 49 Martin Nordholts 2010-01-23 10:11:46 UTC
Removing from any milestone but keeping it accepted.
Comment 50 Michael Natterer 2010-08-26 18:55:21 UTC
The slow code is gone, this bug is fixed:

commit be2bd189cd6d96c63e4a8a41cff98486e740ebf4
Author: Michael Natterer <mitch@gimp.org>
Date:   Thu Aug 26 20:52:52 2010 +0200

    app: completely switch to cairo-drawing the selection
    
    and remove all old selection drawing code. Thanks to Benjamin Otte for
    pointing out the right optimization.
    
    Also fixes bug #479875 - performance problem drawing a complex selection.

 app/display/gimpcanvas.c                 |  184 -------------------
 app/display/gimpcanvas.h                 |    7 -
 app/display/gimpdisplayshell-draw.c      |   26 ++-
 app/display/gimpdisplayshell-draw.h      |    7 +-
 app/display/gimpdisplayshell-selection.c |  289 +++---------------------------
 5 files changed, 53 insertions(+), 460 deletions(-)