PhotoFlow: new caching mechanism - TESTING NEEDED!

Well, a bayer demosaicer gets something like RGRG (GBGB in next row) as input and has to spit out three values for each of the input values. So I would not think, the output format is the factor which increases processing time (maybe a little bit, but not much).

[edited to fix problems with SIP on macOS 10.11 and newer]

On macOS 10.11 (El Capitan) and newer, SIP blocks changes to DYLD* environment variables from being passed through lldb. To fix this, you have to set DYLD_LIBRARY_PATH from inside lldb before launching photoflow:

osascript -e 'display alert "DEBUG VERSION!! Launch from terminal"'
lldb "$bundle_contents/Resources/bin/$name" -o "process launch --environment DYLD_LIBRARY_PATH=\"$bundle_lib\" -- \"$@\" $EXTRA_ARGS"

The osascript command reminds me to run this version from a terminal if I forget and double click the application icon instead.

I’ll let you know how I get on.

I think the freezing it’s because of gdb, as stated in the Rawtherapee doc:

Do what you did to trigger the crash, and when RawTherapee does crash, its window will just freeze, it won’t close. You can tell that it crashed by the fact that everything in that window will have stopped responding. Alt+Tab back to the GDB terminal window.

https://rawpedia.rawtherapee.com/How_to_write_useful_bug_reports

I still have the terminal open, is this what you want?

phf_tile_cache_build(): out ref count: 0x7fffa52051a0->1
OpParBase::build_many_internal(): adding tilecache for output image #0, padding=0
phf_tile_cache_build(): out ref count: 0x7fff67014980->1
OpParBase::build_many_internal(): added tilecache for output image #0, padding=0
ICCTransformPar::build(): matching input and output profiles, no transform needed

(photoflow:6877): GLib-GObject-WARNING **: 07:47:21.715: value "-1" of type 'gint' is invalid or out of range for property 'width' of type 'gint'
[New Thread 0x7fffbffff700 (LWP 3184)]
[New Thread 0x7fffd8d20700 (LWP 3185)]
[New Thread 0x7fffbf7fe700 (LWP 3186)]
[New Thread 0x7fffd9521700 (LWP 3187)]
[Thread 0x7fffd8d20700 (LWP 3185) exited]
[Thread 0x7fffd9521700 (LWP 3187) exited]
[Thread 0x7fffbffff700 (LWP 3184) exited]
[Thread 0x7fffbf7fe700 (LWP 3186) exited]
[New Thread 0x7fffd9521700 (LWP 3188)]
[New Thread 0x7fffbf7fe700 (LWP 3189)]
[Thread 0x7fffd9521700 (LWP 3188) exited]
[New Thread 0x7fffd8d20700 (LWP 3190)]
[New Thread 0x7fffbffff700 (LWP 3191)]
[Thread 0x7fffd8d20700 (LWP 3190) exited]
[Thread 0x7fffbffff700 (LWP 3191) exited]
[Thread 0x7fffbf7fe700 (LWP 3189) exited]
[New Thread 0x7fffbffff700 (LWP 3194)]
[New Thread 0x7fffd8d20700 (LWP 3196)]
[New Thread 0x7fffbf7fe700 (LWP 3197)]
[New Thread 0x7fffd9521700 (LWP 3198)]

Thread 7341 "worker" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd8d20700 (LWP 3196)]
0x0000555555d92ec9 in LUT<float>::operator[]<float, void> (
    index=-nan(0x400000), this=0x7fffa503d0a0)
    at /home/gustavo/PhotoFlow/src/base/../rt/rtengine/LUT.h:449
449	        int idx = (int)index;  // don't use floor! The difference in negative space is no problems here
(gdb) set pagination off
(gdb) set logging file log.txt
(gdb) set logging on
Copying output to log.txt.
(gdb) info threads
  Id   Target Id         Frame 
  1    Thread 0x7ffff7fada00 (LWP 6877) "photoflow" 0x00007ffff60a7607 in __libc_sendmsg (fd=11, msg=0x7fffffff9a70, flags=16384) at ../sysdeps/unix/sysv/linux/sendmsg.c:28
  2    Thread 0x7fffe94a7700 (LWP 6881) "image_processor" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  3    Thread 0x7fffe1b1c700 (LWP 6882) "gmain" 0x00007ffff2f9dbf9 in __GI___poll (fds=0x555558e17690, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:

@gadolf you’ve missed step 8 - upload log.txt.

:smiley: I have already done it.
It’s the same crash.
Thanks anyway.

1 Like

Here’s another one, when trying to delete a curves layer.

[Thread 0x7fffd8b9f700 (LWP 16561) exited]
[Thread 0x7fffdaffd700 (LWP 16564) exited]

(photoflow:14431): Gdk-WARNING **: 21:06:09.732: gdk_window_set_icon_list: icons too large
ICCTransformPar::build(): matching input and output profiles, no transform needed
[New Thread 0x7fffdaffd700 (LWP 16565)]
[New Thread 0x7fffdbfff700 (LWP 16566)]
[New Thread 0x7fffda7fc700 (LWP 16567)]
[New Thread 0x7fffd8b9f700 (LWP 16568)]
[Thread 0x7fffda7fc700 (LWP 16567) exited]
[Thread 0x7fffdaffd700 (LWP 16565) exited]
[Thread 0x7fffdbfff700 (LWP 16566) exited]
[Thread 0x7fffd8b9f700 (LWP 16568) exited]
[New Thread 0x7fffd8b9f700 (LWP 16569)]
[New Thread 0x7fffda7fc700 (LWP 16570)]
[New Thread 0x7fffdbfff700 (LWP 16571)]
[Thread 0x7fffd8b9f700 (LWP 16569) exited]
[Thread 0x7fffdbfff700 (LWP 16571) exited]
[Thread 0x7fffda7fc700 (LWP 16570) exited]
[New Thread 0x7fffdaffd700 (LWP 16572)]
[Thread 0x7fffdaffd700 (LWP 16572) exited]
[New Thread 0x7fffdaffd700 (LWP 16573)]
[New Thread 0x7fffdbfff700 (LWP 16574)]
[New Thread 0x7fffda7fc700 (LWP 16575)]
[New Thread 0x7fffd8b9f700 (LWP 16576)]
[Thread 0x7fffdaffd700 (LWP 16573) exited]
[Thread 0x7fffd8b9f700 (LWP 16576) exited]
[Thread 0x7fffdbfff700 (LWP 16574) exited]
[Thread 0x7fffda7fc700 (LWP 16575) exited]
OperationConfigGUI::disable_editing(): setting editing flag to false
ICCTransformPar::build(): matching input and output profiles, no transform needed
[New Thread 0x7fffd8b9f700 (LWP 16582)]
[New Thread 0x7fffda7fc700 (LWP 16583)]
[New Thread 0x7fffdbfff700 (LWP 16584)]
[New Thread 0x7fffdaffd700 (LWP 16585)]
[Thread 0x7fffdaffd700 (LWP 16585) exited]
[Thread 0x7fffdbfff700 (LWP 16584) exited]
[Thread 0x7fffda7fc700 (LWP 16583) exited]
[Thread 0x7fffd8b9f700 (LWP 16582) exited]
ControlsDialog::on_hide() called.
[New Thread 0x7fffdaffd700 (LWP 16586)]
[New Thread 0x7fffdbfff700 (LWP 16587)]
[New Thread 0x7fffda7fc700 (LWP 16588)]
[New Thread 0x7fffd8b9f700 (LWP 16589)]
[Thread 0x7fffdbfff700 (LWP 16587) exited]
[Thread 0x7fffdaffd700 (LWP 16586) exited]
[Thread 0x7fffd8b9f700 (LWP 16589) exited]
[Thread 0x7fffda7fc700 (LWP 16588) exited]
[New Thread 0x7fffd8b9f700 (LWP 16590)]
[New Thread 0x7fffda7fc700 (LWP 16591)]
[New Thread 0x7fffdbfff700 (LWP 16592)]
[New Thread 0x7fffdaffd700 (LWP 16593)]
[Thread 0x7fffda7fc700 (LWP 16591) exited]
[Thread 0x7fffd8b9f700 (LWP 16590) exited]
[Thread 0x7fffdbfff700 (LWP 16592) exited]
[Thread 0x7fffdaffd700 (LWP 16593) exited]
ControlsDialog::on_hide() called.
MainWindow::on_button_save_clicked(): editor->get_image()->get_filename()="/home/gustavo/Pictures/playraw/dreamy creek landscape/20190919-084717-IMG_0003.pfi"
ext: pfi
ControlsDialog::on_hide() called.
OperationConfigGUI::collapse(): resetting editing flag
~OpParBase(): deleting operation 0x7fff7c000040 (curves)
~OpParBase(): deleting operation 0x7fffe6cce870 (uniform)
~OpParBase(): deleting operation 0x7fff9d1cd230 (blender)
~OpParBase(): deleting operation 0x7fff7c303d90 (curves)
~OpParBase(): deleting operation 0x7fff9e2d49e0 (uniform)
~OpParBase(): deleting operation 0x7fff9d1fd330 (blender)
~OpParBase(): deleting operation 0x7fff9d25e8b0 (curves)
~OpParBase(): deleting operation 0x7fffe6909d50 (uniform)
~OpParBase(): deleting operation 0x7fffe6956070 (blender)
~OpParBase(): deleting operation 0x55555b8436d0 (curves)
~OpParBase(): deleting operation 0x55555b72e060 (uniform)
~OpParBase(): deleting operation 0x55555b5e5180 (blender)
ColorCorrectionPar::build(): 1  0  1
ConvertColorspacePar::build(): Getting built-in profile: sRGB
ConvertColorspacePar::build(): tr_par->get_LSh_format()=0
ColorCorrectionPar::build(): 1  0  1
ConvertColorspacePar::build(): Getting built-in profile: sRGB
ConvertColorspacePar::build(): tr_par->get_LSh_format()=0
ICCTransformPar::build(): matching input and output profiles, no transform needed
ColorCorrectionPar::build(): 1  0  1
ConvertColorspacePar::build(): Getting built-in profile: sRGB
ConvertColorspacePar::build(): tr_par->get_LSh_format()=0
[New Thread 0x7fffdaffd700 (LWP 16602)]
[New Thread 0x7fffdbfff700 (LWP 16603)]
[New Thread 0x7fffda7fc700 (LWP 16604)]
[New Thread 0x7fffd8b9f700 (LWP 16605)]

Thread 2011 "worker" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffdaffd700 (LWP 16602)]
0x0000555555de6f32 in vips_layer_gen (oreg=0x55555bba43a0, seq=0x7fffb04f89e0, 
    a=<optimized out>, b=0x7fff9f826590, stop=<optimized out>)
    at /home/gustavo/PhotoFlow/src/vips/layer.cc:192
192	      layer->processor->get_par()->transform_inv(r, &s, i);
(gdb) set pagination off
(gdb) set logging file log.txt
(gdb) set logging on
Copying output to log.txt.
(gdb) info threads
  Id   Target Id         Frame 
  1    Thread 0x7ffff7fada00 (LWP 14431) "photoflow" syscall () at ../sysdeps/unix/sysv/

log.txt (101.6 KB)

and what I had done so far:
20190919-084717-IMG_0003.pfi (31.3 KB)

The image is from the Dreamy Creek Landscape play raw.

I could reproduced the crash many times:
1 - Reopened the pfi file
2 - Answered yes to restore from the last crash
3 - Tried to delete the first curve from bottom to top

1 Like

Confirmed, I am looking into it.

@gadolf the crash when deleting layers should be fixed now. I have also fixed the Glib warning that appeared in the terminal output from time to time, although it was harmless…

new packages are ready for download.

Thanks!

1 Like

Thanks, eager to try it!

I started building it but I won’t be able to test it before tonight or tomorrow morning.

Can confirm that @gadolf’s test case is no longer crashing on macOS with the latest (9831e) version.
(well done finding a reproducable test case by the way)

The colour shift at non 1:1 scaling is fixed.
The crop tool is fixed.
The perspective correction tool is fixed.
“assign profile” is still strange

1 Like

Just found a crash in (9831e):

(this is using the file I uploaded for the colour shift case)
DSC_1018_crash.pfi (47.4 KB)

Steps to reproduce:

  1. Open DSC_1018_crash.pfi
  2. Open the mask on the top ‘curves’ layer
  3. Click ‘Show Mask’
  4. Turn off the curves layer on the mask.

The log shows an assertion failure:

... layer "colorspace conversion" finished
PF::Image::do_update(): pipeline #0 updated.
PF::Image::do_update(): preparing pipeline #1
PF::Image::do_update(): updating pipeline #1
LayerManager::rebuild_chain(): rebuilding blender output for layer "curves"
LayerManager::rebuild_chain(): vips_image_invalidate_all() called on node->blended
Building layer "layer clone"...
... layer "layer clone" finished
Building layer "basic adjustments"...
... layer "basic adjustments" finished
Building layer "colorspace conversion"...
ConvertColorspacePar::build(): Getting built-in profile: sRGB
ConvertColorspacePar::build(): tr_par->get_LSh_format()=0
... layer "colorspace conversion" finished

(photoflow:22473): GLib-GObject-WARNING **: 11:27:30.564: invalid uninstantiatable type '<invalid>' in cast to 'GObject'
**
ERROR:/Users/travis/build/aferrero2707/PhotoFlow/src/base/photoflow.cc:443:void PF::pf_object_unref(GObject *, const char *): assertion failed: (object->ref_count > 0)

Crash report:

0   libsystem_kernel.dylib        	0x00007fff5f7952c6 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff5f850bf1 pthread_kill + 284
2   libsystem_c.dylib             	0x00007fff5f6ff6a6 abort + 127
3   libglib-2.0.0.dylib           	0x0000000105304688 g_assertion_message + 423
4   libglib-2.0.0.dylib           	0x00000001053046e6 g_assertion_message_expr + 94
5   photoflow                     	0x00000001029fd12b PF::pf_object_unref(_GObject*, char const*) + 59

EDIT: Never mind, the source for the Clone Layer on the mask wasn’t set. If I set it then the crash goes away.

Still got time to build it and repeat the delete layer test case and I confirm it works now, thanks.
As for the warning, it still shows now and then

(photoflow:15587): Gdk-WARNING **: 08:18:09.017: gdk_window_set_icon_list: icons too large

Later on I’ll do more edits.

EDIT: I completed an edit of the dreamy creek play raw without a crash. It’s very fast. The only thing noticeable happened when I inserted a film emulation layer in the middle of the pipe and chose a film: it took some time to process, at a very high cpu rate. Different from all other layers I manipulated.

This is exactly the kind of thing that the code in the improved-pipeline branch will solve once merged, that is to provide a correct and meaningful default input to all layers (including mask layers).

Good to know. Although the fixes I introduced for the crash upon layer deletion should have no impact on the other crashes that occur when moving sliders very fast. If that happen again, please let me know and provide logs if possible…

Glad to know the processing is getting faster with the new code!

The first time a film emulation preset is used, GMIC has to load and decompress the CLUT from disk, and this step takes a bit of time. However this is only executed once, and the processing should be much faster afterwards. Is that the case?

Correct.

Now I’m trying to edit this play raw but the computer is swapping again and completely freezing, so I don’t have a way to send you anything.
I tried using valgrind the way you mentioned above, but it takes forever to do the initial rendering.
The steps I took before freezing:

  1. Opened the raw
  2. Added a scale layer to fix the angle
  3. Back to the raw dev layer, I set highlights recovery to blend,
  4. then I switched to the advanced tab, and pushed the white level to around 55,000.
  5. Back to the input tab, I started tweaking with the exposure slider and, at that point, ram was filling up and swapping began, forcing me to reboot.

Look at the green indicator, at the top, which is ram usage (screenshot after completing step 4 above)

Confirmed. Moving the exposure slider without any additional layer already increases the memory. There is a big memory leak somewhere, I will look at this later today.

1 Like

There was an important memory leak in the demosaicing phase, which got amplified by the recent changes in the processing pipeline. It should be completely fixed now.

I could reproduce the odd behavior and I started to look into it, but I do not have a fix yet. Hopefully tomorrow…

:clap: It has been bothering for a long time. Thanks @gadolf for providing more concrete evidence; not good at doing that myself. :blush:

2 Likes

I have also fixed the stable branch, so no need to download the more experimental new-caching version.

New packages should be ready by now…

1 Like

ok, thanks. One question: if I want to send you debug info concerning the stable branch, is it just starting with this and repeat all other steps?

git clone https://github.com/aferrero2707/PhotoFlow.git --branch stable --single-branch