Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.78k stars 314 forks source link

Better curve controle : using the NURBS model #148

Closed Beep6581 closed 9 years ago

Beep6581 commented 9 years ago

Originally reported on Google Code with ID 157

It may be hard to have the right curve using the "personnal" curve editor.

I'm currently implementing (well... trying to) a new curve type : NURBS of degre 2,
that will be named "control cage".

Work in progress...

Reported by natureh.510 on 2010-07-09 00:12:30

Beep6581 commented 9 years ago
Sounds interesting :-)

Reported by wyatt.olson on 2010-07-11 20:00:12

Beep6581 commented 9 years ago
Done. Enjoy ;)

In fact, this NURBS curve, degree 2 and all weight to 1.0, is a succession of Bézier
curve of degree 2, but i keept NURBS denomination in the source.

The patch also cleanup a little bit how are handled the curves internally, so one can
add a new type easier.

Reported by natureh.510 on 2010-07-14 21:05:47


Beep6581 commented 9 years ago
Pushed to staging.

Reported by wyatt.olson on 2010-07-14 21:14:03

Beep6581 commented 9 years ago
Hello, when placing three dots on the cage curve, my rt3a1-staging (changeset: 179:b924dda4f620)
freezes. Perfectly repeatable. Ubuntu 10.04, 32-bit. Terminal output and bt: 

[New Thread 0x8d12eb70 (LWP 19989)]
[New Thread 0x8c92db70 (LWP 19990)]
[Thread 0x8c92db70 (LWP 19990) exited]
[Thread 0x8d12eb70 (LWP 19989) exited]

glibmm-ERROR **: 
unhandled exception (type std::exception) in signal handler:
what: std::bad_alloc

aborting...

Program received signal SIGABRT, Aborted.
0xb7fe2430 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fe2430 in __kernel_vsyscall ()
#1  0xb6ee7651 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb6eeaa82 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb7e3f026 in g_logv () from /lib/libglib-2.0.so.0
#4  0xb7e3f056 in g_log () from /lib/libglib-2.0.so.0
#5  0xb7dd565d in Glib::exception_handlers_invoke() ()
   from /usr/lib/libglibmm-2.4.so.1
#6  0xb7596de9 in ?? () from /usr/lib/libgtkmm-2.4.so.1
#7  0xb7b02424 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#8  0xb7ede252 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#9  0xb7ef2d90 in ?? () from /usr/lib/libgobject-2.0.so.0
#10 0xb7ef3c33 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#11 0xb7ef4256 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#12 0xb7c2f4da in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#13 0xb7afaa5d in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#14 0xb7afbe07 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#15 0xb798539a in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#16 0xb7e345e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#17 0xb7e382d8 in ?? () from /lib/libglib-2.0.so.0
#18 0xb7e38817 in g_main_loop_run () from /lib/libglib-2.0.so.0
#19 0xb7afc3c9 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#20 0xb750d3a7 in Gtk::Main::run_impl() () from /usr/lib/libgtkmm-2.4.so.1
#21 0xb750d4c8 in Gtk::Main::run(Gtk::Window&) ()
---Type <return> to continue, or q <return> to quit---
   from /usr/lib/libgtkmm-2.4.so.1
#22 0x082abcde in main (argc=1, argv=0xbffff4b4)
    at /home/paul/rt3a1-staging-clean/rtgui/main.cc:105
(gdb) 

Reported by paul.matthijsse4 on 2010-07-23 08:48:14

Beep6581 commented 9 years ago
@Paul

You said "Perfectly repeatable.", but i don't have such issue on Windows. In fact,
RT crash sometime when manipulating curves, sometimes when loading the thumbnails of
a directory. Both heavily uses mltithreading, so i guess we have to dig in that direction,
the new curve type is not responsible of those crashes.

Btw, i'm looking at handling pen pointers, so are you willing to collaborate by email
to test the new mechanism. I don't have a pen device, so i need someone to compile
and test the files i would send.

Drop me a line on my email if you are okay : natureh CHEZ free POINT fr

Reported by natureh.510 on 2010-07-24 13:36:14

Beep6581 commented 9 years ago
Hello Hombre,

Yes, perfectly repeatable on Ubuntu. Does not happen when using the manual curve. 

I'm happy to help you with the curves, I'll drop you a mail. 

Regards, Paul. 

Reported by paul.matthijsse4 on 2010-07-24 13:48:36

Beep6581 commented 9 years ago
It happens to me too on WinXP, but only randomly in release.

Reported by ffsup2@yahoo.it on 2010-07-25 09:00:03

Beep6581 commented 9 years ago
Regarding comment #4 (RT freezes), I found out that this is a problem in my local copy
of rt3a1-staging. This doesn't happen with a clean build. So forget about this. 

Regards, Paul. 

Reported by paul.matthijsse4 on 2010-07-25 10:14:43

Beep6581 commented 9 years ago
Well, I am having a problem with RT freezing when using the cage control (for me it
happens when trying to place a second control point on the NURBS curve).  With my standard
local copy I have a problem with both the cage control, and the ordinary custom curve
option.  The custom curve doesn't allow points to be placed anywhere except along the
diagonal, and they cannot be dragged anywhere away from the diagonal, which of course
renders the curve tool inoperable.  The cage control is even worse, not only can one
not place the control points away from the diagonal, after placing the second one RT
freezes, then crashes.

With a fresh install on another machine, the curves control was working as expected,
but again the cage control freezes the machine, and nearly crashed the machine and
not just the app.

I also have an older copy of RT staging lying around, not updated since I installed
the green equilibration routine (I'm not sure which specific build it is; is there
a way to find out?).  Custom curve works beautifully.

It seems as though there is something weird with the new curves code.  All the above
issues are on OSX 10.5 or 10.6.

Reported by ejm.60657 on 2010-07-31 15:55:59

Beep6581 commented 9 years ago
That's very strange, effectively !

So, if i understand correctly, the curves now works correctly (you can put the points
wherever you want), but the cage control freeze the machine, right ? I'm not sure that
it's related to the new curve version, as i experienced such freeze with current build
but not when using the curves. I think it's an event handling issue while dealing with
multi-threading. I'll look at it...

Reported by natureh.510 on 2010-08-01 11:54:02

Beep6581 commented 9 years ago
By the way, what is your GTK version ?

Reported by natureh.510 on 2010-08-01 11:54:48

Beep6581 commented 9 years ago
I have it installed through macports:

gtk2 @2.18.8_0+x11

This is the most current version available from them.

Reported by ejm.60657 on 2010-08-01 12:03:38

Beep6581 commented 9 years ago
Emil wrote: "(I'm not sure which specific build it is; is there a way to find out?)."
See the date stamp of the folder that older rt build is in, then do hg log in a terminal.
Gives at least an indication which build you are using. 

Btw, on Ubuntu both curves work well now. 

Reported by paul.matthijsse4 on 2010-08-01 13:27:03

Beep6581 commented 9 years ago
Hello!

I just tried to use new "cage" curve and experinced problems:

I created two points. Then I wanted to move one of points, pointed mouse onto the point,
pressed the left button and started moving the mouse. At this moment cursor disappeared,
and the program became frozen. The memory usage grown very fast, reached the memory
size (4 Gb in my case) and started swapping. The system did not react neither to mouse
nor to keyboard.

Ubuntu 10.04 x64, latest repository revision 2f52d43de68b

Reported by iliaworld@yandex.ru on 2010-08-01 14:44:27

Beep6581 commented 9 years ago
It is the normal behaviour that the cursor disappear, but it shouldn't consume all the
memory...

Did you build RT yourself ?

Reported by natureh.510 on 2010-08-01 16:36:15

Beep6581 commented 9 years ago
The behavior described in comment #14 is *exactly* the same behavior as on my system.

Reported by ejm.60657 on 2010-08-01 19:11:35

Beep6581 commented 9 years ago
Yes, i do build it myself. If you need more information, please ask.

Reported by iliaworld@yandex.ru on 2010-08-01 21:06:16

Beep6581 commented 9 years ago
same problem here with the cage curve, tryed a minute ago
the system freeze (ubuntu 10.04 64bit fully updated, 2gb ram)

Reported by alessandro.torri on 2010-08-01 21:10:58

Beep6581 commented 9 years ago
"I created two points. Then I wanted to move one of points, pointed mouse onto the point,
pressed the left button and started moving the mouse. At this moment cursor disappeared,
and the program became frozen."

It you move your mouse fluently, does it froze just after the button press, or 0.5
later, or 1s later, or... ?

And you confirm that there's no problem with the "Personal curve", right ?

Reported by natureh.510 on 2010-08-02 20:21:04

Beep6581 commented 9 years ago
First time it was very fast, but i just tried again and it was after about 1 sec. All
other types of curves work --- Custom and Parametric (except for three sliders on bar
with gradient just below the Parametric curve which don't cause any change in image)

Reported by iliaworld@yandex.ru on 2010-08-02 20:44:47

Beep6581 commented 9 years ago
Emil, does you OS10.5 and 10.6 64 bits ? All the freeze problems seem to occures only
on 64 bits machines...

Reported by natureh.510 on 2010-08-03 08:49:18

Beep6581 commented 9 years ago
Yes they are both 64 bit capable.

Reported by ejm.60657 on 2010-08-03 11:19:55

Beep6581 commented 9 years ago
And is RT compiled in 64bit mode ?

Reported by natureh.510 on 2010-08-03 12:17:29

Beep6581 commented 9 years ago
How do I find out?  I just run cmake with default settings other than turning off OpenMP
and building as "Release" for more optimization.

Reported by ejm.60657 on 2010-08-03 12:54:32

Beep6581 commented 9 years ago
I don't know :(

Please, if you have a 64bit version of RT and are experiencing a freeze of RT/system
while adding or moving knot in the "cage control" curve editor, try to build the application
in 32 bit mode (adding "--32" to the CFLAGS and CXXFLAGS should be sufficient, i hope),
and tell me if it's still crashing.

Tell me also which thread system you're using : type

gcc -v --help

to have the output of all options possible and some config (i don't know how to have
the building options otherwise, but if someone know ;) ).

Reported by natureh.510 on 2010-08-03 23:32:23

Beep6581 commented 9 years ago
Here is a new patch. If the merge is too complicated, you'd better replace the 2 files
by the attached ones...

I would appreciate if you could test it on Linux and MacOS, and report me weird behaviours.

Test it in debug mode too if you can, as i've figured out something very strange :
it crashes quite often when ran normally, and rock solid when ran with the debugger
(gdb) !!! (wich is a little bit annoying to debug it...) Does someone have an explanation
?

Wyatt, can you add me as a contributor ? And if i don't have the rights for that, set
me as the owner if the issue, please.

Reported by natureh.510 on 2010-08-17 23:28:47


Beep6581 commented 9 years ago
As far as I remember in some cases uninitialized variables are automatically initialized
to zero in debug mode. And this was a root of problem when I encoutered different behaviour
of my programs in debug and release modes. May be look this way? Also you can use compiler
flag like -Wall to have all possible compiler warnings, there may be something useful.

Reported by iliaworld@yandex.ru on 2010-08-18 07:53:16

Beep6581 commented 9 years ago
Now it doesn't freeze immediately (as it always did before); now I can move the curve
control points for a while, but eventually the program freezes and crashes.  The terminal
from which I launched RT gets a few error messages:

rt(20866,0xb1d73000) malloc: *** mmap(size=1073741824) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

glibmm-ERROR **: 
unhandled exception (type std::exception) in signal handler:
what: St9bad_alloc

aborting...
Abort trap

Reported by ejm.60657 on 2010-08-18 15:33:11

Beep6581 commented 9 years ago
Forgot to mention -- if I try to add anything beyond two control points, the curve program
immediately freezes as it did before, and crashes after a few seconds.

Reported by ejm.60657 on 2010-08-18 15:36:58

Beep6581 commented 9 years ago
Is it with or without Fabio's patch correcting the memory leak ?

Reported by natureh.510 on 2010-08-18 16:41:49

Beep6581 commented 9 years ago
Sorry for the delay -- I have added you as a contributor and pushed the patch to head.

Cheers

Reported by wyatt.olson on 2010-08-18 16:46:48

Beep6581 commented 9 years ago

Reported by wyatt.olson on 2010-08-18 16:47:10

Beep6581 commented 9 years ago
What patch from Fabio?  I don't see it above.  I just copied your mycurve.cc and mycurve.h
linked above into my working copy of the last revision of staging.

Reported by ejm.60657 on 2010-08-18 17:16:57

Beep6581 commented 9 years ago
I'm talking about the patch he sent us privately by mail on August 18.

Reported by natureh.510 on 2010-08-18 17:58:52

Beep6581 commented 9 years ago
OK, no I had not applied that one.  I applied it, and now the curve control freezes
the first time I put in a control point.  It's worse than before this patch.

Reported by ejm.60657 on 2010-08-18 18:33:24

Beep6581 commented 9 years ago
Here is a patch for pen device users. Unfortunately, it doesn't correct the freeze on
Mac

Reported by natureh.510 on 2010-08-18 22:02:55


Beep6581 commented 9 years ago
Pushed to head

Reported by wyatt.olson on 2010-08-18 22:05:14

Beep6581 commented 9 years ago
Hello, my Wacom pen works perfect now with this patch, thanks! 

Reported by paul.matthijsse4 on 2010-08-21 15:31:27

Beep6581 commented 9 years ago
As a reminder : the bug that did RT crash on Linux & MacOS is solved, but already freed
memory is being freed again, and it crash on Linux. The environement varaible MALLOC_CHECK_=0
before compiling can avoid this, but it should be solved in the code...

Reported by natureh.510 on 2010-09-04 17:46:55

Beep6581 commented 9 years ago

Reported by natureh.510 on 2010-09-04 22:14:52