CarVac / filmulator-gui

Filmulator --- Simplified raw editing with the power of film
https://filmulator.org
Other
672 stars 32 forks source link

MacOS: Crashes & imports not displayed #71

Closed Benitoite closed 6 years ago

Benitoite commented 6 years ago

I thought I'd give building filmulator-gui on mac... This is a crash when trying to start up filmulator-gui built on mac Mac OS X 10.12.6 w/ Qt 5.11.0. System crash report:

Process:               filmulator-gui [62965]
Path:                  /Users/USER/*/filmulator-gui.app/Contents/MacOS/filmulator-gui
Identifier:            kd6kxr.filmulator-gui
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           filmulator-gui [62965]
User ID:               501

Date/Time:             2018-09-12 20:53:35.061 -0700
OS Version:            Mac OS X 10.12.6 (16G1510)
Report Version:        12
Anonymous UUID:        567E9ED4-5465-6075-F9A6-523A0FD4EEEA

Time Awake Since Boot: 130000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fffaa016d42 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fffaa104457 pthread_kill + 90
2   libsystem_c.dylib               0x00007fffa9f7c420 abort + 129
3   org.qt-project.QtCore           0x00000001017ff079 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) + 9
4   org.qt-project.QtCore           0x000000010180085f QMessageLogger::fatal(char const*, ...) const + 213
5   org.qt-project.QtCore           0x000000010180bb4c QThread::~QThread() + 252
6   kd6kxr.filmulator-gui           0x00000001007e79f2 FilmImageProvider::~FilmImageProvider() + 242
7   kd6kxr.filmulator-gui           0x00000001007e7a85 non-virtual thunk to FilmImageProvider::~FilmImageProvider() + 21
8   org.qt-project.QtQml            0x00000001014a1421 QHash<QString, QSharedPointer<QQmlImageProviderBase> >::deleteNode2(QHashData::Node*) + 49
9   org.qt-project.QtCore           0x00000001018614f9 QHashData::free_helper(void (*)(QHashData::Node*)) + 73
10  org.qt-project.QtQml            0x0000000101497862 QQmlEnginePrivate::~QQmlEnginePrivate() + 930
11  org.qt-project.QtQml            0x000000010152abf3 QQmlApplicationEnginePrivate::~QQmlApplicationEnginePrivate() + 115
12  org.qt-project.QtCore           0x00000001019ee868 QObject::~QObject() + 1880
13  org.qt-project.QtQml            0x0000000101499572 QQmlEngine::~QQmlEngine() + 370
14  kd6kxr.filmulator-gui           0x00000001007c5c35 main + 3269
15  libdyld.dylib                   0x00007fffa9ee8235 start + 1
CarVac commented 6 years ago

Oh boy, my first Mac bug report.

A crash on startup, huh... Can you try debugging it in Qt Creator?

Benitoite commented 6 years ago

I'm having trouble bundling these modules. I think that is causing the abort termination msgs.

QQmlApplicationEngine failed to load component
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:2 module "QtQuick.Controls" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:2 module "QtQuick.Controls" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:2 module "QtQuick.Controls" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:2 module "QtQuick.Controls" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed

Seem to be narrowing things down, still looking for these modules...

QQmlApplicationEngine failed to load component
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:5 module "QtQuick.Controls.Styles" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:3 module "QtQuick.Layouts" is not installed
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:4 module "QtQuick.Dialogs" is not installed
Benitoite commented 6 years ago

QtQuick Layouts and Dialogs still giving me a headache. I am trying to figure out what to link, how, and where to put them in the bundle, etc. macdeployqt should be scanning for imports and grabbing the modules, but I may have to do some hand holding with the -qmldir= parameters.

Benitoite commented 6 years ago

in case you are curious what i had to do to get it to compile in the first place:

diff --git a/filmulator-gui/core/diffuse.cpp b/filmulator-gui/core/diffuse.cpp
index a28bbef..bc66ef2 100644
--- a/filmulator-gui/core/diffuse.cpp
+++ b/filmulator-gui/core/diffuse.cpp
@@ -18,7 +18,7 @@
  */
 #include "filmSim.hpp"
 #include <utility>
-#include <omp.h>
+#include </opt/local/include/omp.h>
 #include "math.h"
 #define ORDER 7 //This is the number of box blur iterations.
 using namespace std;
diff --git a/filmulator-gui/core/filmSim.hpp b/filmulator-gui/core/filmSim.hpp
index ae86f78..15575eb 100644
--- a/filmulator-gui/core/filmSim.hpp
+++ b/filmulator-gui/core/filmSim.hpp
@@ -20,16 +20,16 @@
 #ifndef FILMSIM_H
 #define FILMSIM_H

-#include "tiffio.h"
+#include "/opt/local/include/tiffio.h"
 #include <iostream>
 #include <fstream>
 #include <cmath>
 #include <cstdlib>
-#include "jpeglib.h"
+#include "/opt/local/include/jpeglib.h"
 #include <setjmp.h>
-#include <exiv2/exiv2.hpp>
+#include </opt/local/include/exiv2/exiv2.hpp>
 #include "lut.hpp"
-#include "libraw/libraw.h"
+#include "/opt/local/include/libraw/libraw.h"
 #include "matrix.hpp"
 #include <sys/time.h>
 #include "interface.h"
diff --git a/filmulator-gui/core/layerMix.cpp b/filmulator-gui/core/layerMix.cpp
index 56535a2..2eb782a 100644
--- a/filmulator-gui/core/layerMix.cpp
+++ b/filmulator-gui/core/layerMix.cpp
@@ -18,7 +18,7 @@
  */
 #include "filmSim.hpp"
 #include <math.h>
-#include <omp.h>
+#include </opt/local/include/omp.h>

 //This function implements diffusion between the active developer layer
 // adjacent to the film and the reservoir of inactive developer.
diff --git a/filmulator-gui/core/whiteBalance.cpp b/filmulator-gui/core/whiteBalance.cpp
index 20c69c5..4e1f8ee 100644
--- a/filmulator-gui/core/whiteBalance.cpp
+++ b/filmulator-gui/core/whiteBalance.cpp
@@ -1,6 +1,7 @@
 #include "filmSim.hpp"
 #include <utility>
 #include <iostream>
+#include <array>

 using std::cout;
 using std::endl;
diff --git a/filmulator-gui/database/exifFunctions.h b/filmulator-gui/database/exifFunctions.h
index 46cc9a3..89b4490 100644
--- a/filmulator-gui/database/exifFunctions.h
+++ b/filmulator-gui/database/exifFunctions.h
@@ -1,7 +1,7 @@
 #ifndef EXIFFUNCTIONS_H
 #define EXIFFUNCTIONS_H

-#include <exiv2/exiv2.hpp>
+#include </opt/local/include/exiv2/exiv2.hpp>
 #include <QString>
 #include <QDateTime>

diff --git a/filmulator-gui/database/importModel.h b/filmulator-gui/database/importModel.h
index d51b476..ed159ee 100644
--- a/filmulator-gui/database/importModel.h
+++ b/filmulator-gui/database/importModel.h
@@ -3,7 +3,7 @@

 #include "sqlModel.h"
 #include <QString>
-#include <exiv2/exiv2.hpp>
+#include </opt/local/include/exiv2/exiv2.hpp>
 #include <deque>
 #include "importWorker.h"
 #include <QThread>
diff --git a/filmulator-gui/database/organizeModel.h b/filmulator-gui/database/organizeModel.h
index be758a5..baa2c5f 100644
--- a/filmulator-gui/database/organizeModel.h
+++ b/filmulator-gui/database/organizeModel.h
@@ -7,7 +7,7 @@
 #include <QDateTime>
 #include <QTimeZone>
 #include <QByteArray>
-#include <exiv2/exiv2.hpp>
+#include </opt/local/include/exiv2/exiv2.hpp>

 class OrganizeModel : public SqlModel
 {
diff --git a/filmulator-gui/database/sqlInsertion.h b/filmulator-gui/database/sqlInsertion.h
index ef92fda..985ec7d 100644
--- a/filmulator-gui/database/sqlInsertion.h
+++ b/filmulator-gui/database/sqlInsertion.h
@@ -1,7 +1,7 @@
 #ifndef SQLINSERTION_H
 #define SQLINSERTION_H

-#include <exiv2/exiv2.hpp>
+#include </opt/local/include/exiv2/exiv2.hpp>
 #include <QDateTime>
 #include <QString>
 #include <iostream>
diff --git a/filmulator-gui/database/sqlModel.cpp b/filmulator-gui/database/sqlModel.cpp
index cb1011a..75acf41 100644
--- a/filmulator-gui/database/sqlModel.cpp
+++ b/filmulator-gui/database/sqlModel.cpp
@@ -1,7 +1,7 @@
 #include "sqlModel.h"
 #include <iostream>
 #include <QStringList>
-#include <exiv2/exiv2.hpp>
+#include </opt/local/include/exiv2/exiv2.hpp>>
 #include <QCryptographicHash>
 #include <QSqlRecord>
 #include <QModelIndex>
diff --git a/filmulator-gui/filmulator-gui.pro b/filmulator-gui/filmulator-gui.pro
index c53b3f7..f929037 100644
--- a/filmulator-gui/filmulator-gui.pro
+++ b/filmulator-gui/filmulator-gui.pro
@@ -104,11 +104,11 @@ HEADERS += \
     ui/thumbWriteWorker.h

-QMAKE_CXXFLAGS += -std=c++11 -DTOUT -O3 -fprefetch-loop-arrays -fopenmp -fno-strict-aliasing -ffast-math
-#QMAKE_CFLAGS_DEBUG += -DTOUT -O3 -fprefetch-loop-arrays -fopenmp
-QMAKE_LFLAGS += -std=c++11 -O3 -fopenmp
+QMAKE_CXXFLAGS += -std=c++11 -DTOUT -O3 -fprefetch-loop-arrays  -fno-strict-aliasing -ffast-math
+#QMAKE_CFLAGS_DEBUG += -DTOUT -O3 -fprefetch-loop-arrays 
+QMAKE_LFLAGS += -std=c++11 -O3 

-LIBS += -lpthread -ltiff -lexiv2 -ljpeg -lraw_r -lgomp
+LIBS += -lpthread -L/opt/local/lib -ltiff  -lexiv2 -ljpeg -lraw_r 

 QT += sql core quick qml widgets

diff --git a/filmulator-gui/filmulator-gui80.png b/filmulator-gui/filmulator-gui80.png
deleted file mode 100644
index a1b1c36..0000000
Binary files a/filmulator-gui/filmulator-gui80.png and /dev/null differ
diff --git a/filmulator-gui/main.cpp b/filmulator-gui/main.cpp
index 545c2ca..94af24a 100644
--- a/filmulator-gui/main.cpp
+++ b/filmulator-gui/main.cpp
@@ -96,14 +96,14 @@ int main(int argc, char *argv[])
     if( appdir )
     {
         QString qmlfile = appdir;
-        qmlfile += "/usr/qml/main.qml";
+        qmlfile += "/Contents/Resources/qml/filmulator-gui/main.qml";
         if (QFile(qmlfile).exists())
         {
             cout << "loading UI from copy in appdir directory" << endl;
             engine.load(qmlfile);
         }
     } 
-    else if (QFile("qml/filmulator-gui/main.qml").exists())
+    else if (QFile("/Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml").exists())
     {
         cout << "loading UI from copy in directory" << endl;
         engine.load("qml/filmulator-gui/main.qml");

disabled omp for experimenting, etc. also experimented with a .icns file for a mac app icon.

CarVac commented 6 years ago

Hmm, so at least for the compilation changes, we need to somehow set the include directory in the build system, rather than specifying specific directories in each file. I'll have to look into how to do that in qmake.

I'll also try to do some research on how to bundle Qt Quick...

CarVac commented 6 years ago

https://forum.qt.io/topic/70633/plugin-qtquickcontrolsplugin-not-found/4

This may be relevant.

Benitoite commented 6 years ago

Turns out main.qml wants to know which folder to find the modules, which I adjusted as:

-import QtQuick 2.2
-import QtQuick.Controls 1.2
-import QtQuick.Layouts 1.1
-import QtQuick.Dialogs 1.1
-import QtQuick.Controls.Styles 1.2
+import "../../../Frameworks/QtQuick.framework" 2.2
+import "../../../Frameworks/QtQuickControls2.framework" 1.2
+import "../../../Plugins/QtQuick/Layouts/l" 1.1
+import "../../../Plugins/QtQuick/Dialogs/d" 1.1
+import "../../../Resources/qml/Base" 1.2

As you can see, It want's either a bonafide framework or the dylib to be in it's own folder. Not sure if this is correct, because there are still errors. Got past qml module imports at the top. Now onto this next one...

QQmlApplicationEngine failed to load component
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:28 SplitView is not a type
QQmlApplicationEngine failed to load component
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/main.qml:145 MouseArea is not a type

What type are these supposed to be?

CarVac commented 6 years ago

For some reason I don't think you're supposed to hardcode the paths to the qml modules that are distributed in Qt... I've never seen that in any code samples anywhere.

SplitView and MouseArea are standard Qt Quick components. SplitView comes from QtQuick.Layouts if I remember correctly.

If it can't find them, then it's not actually importing them with these changes you made.

Benitoite commented 6 years ago

You are right, and I am missing my entire qt qml folder... time to refresh qt and try again.

Benitoite commented 6 years ago

ok got it working(launched it)....! had to remove my -always-overwrite option on macdeployqt. ill share a build later, going to try and put the icon in the bundle.

crash on import...if update file locations is not activated. trying to import a single file:

 QSqlQuery::value: not positioned on a valid record    

and it looks like nothing happens.

CarVac commented 6 years ago

Make sure you're either using the "import in place" option, or make sure to fill in a "destination directory".

I need to clarify import instructions...

Benitoite commented 6 years ago

importing in place one dng. importing appears to complete, but filmulate tab shows empty. twiddling a control results in a loop:

file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/Edit.qml:112:17: QML Image: Failed to get image from provider: image://filmy/q023728
FilmImageProvider::requestImage Here?
FilmImageProvider::requestImage id: q023729
imagePipeline.cpp: Opening 
load start:5.1e-05
processImage: Could not read input file!
Request time: 0.000177 seconds
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/Edit.qml:112:17: QML Image: Failed to get image from provider: image://filmy/q023729
FilmImageProvider::requestImage Here?
FilmImageProvider::requestImage id: q023730
imagePipeline.cpp: Opening 
load start:2.6e-05
processImage: Could not read input file!
Request time: 0.000293 seconds
file:///Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/Resources/qml/filmulator-gui/Edit.qml:112:17: QML Image: Failed to get image from provider: image://filmy/q023730
FilmImageProvider::requestImage Here?
FilmImageProvider::requestImage id: q023731
imagePipeline.cpp: Opening 
load start:1.4e-05
processImage: Could not read input file!
Request time: 0.000256 seconds
QThread: Destroyed while thread is still running
Abort trap: 6

edit; I wonder if going to Qt5.10 messed it up. I have to set 5.11.1 up.

CarVac commented 6 years ago

You need to enqueue your file, and then double-click on it in the queue to select it for editing, before the sliders do anything.

Enqueuing can be done by the import process, or by double-clicking on an image from the Organize tab.

Benitoite commented 6 years ago

screen shot 2018-09-13 at 2 20 00 pm At this point the only thing I see come up is a brown stripe on the left hand side of what I assume is the preview pane. It is not double-clickable.

Benitoite commented 6 years ago

Ps. I've the app now launchable by double-clicking the icon. This works by calling a launcher script exec:


#!/usr/bin/env bash

cd "$(dirname "$0")" || exit 1

cwd="$(pwd)"
export LD_LIBRARY_PATH=../../Frameworks
export APPDIR=../..
exec "${cwd}/filmulator"
CarVac commented 6 years ago

What were the steps you used to build it?

Do you think you could make a script or instructions?

As for your issues:

Is there nothing in the queue on the bottom? Was the bottom-most switch (Enqueue imported photos) activated on the Import tab?

Based on the state of your Organize tab, it looks like no images actually were imported. The upper pane, with the brown stripe, eventually becomes a histogram of the photos you've taken on each day, but it's showing today alone, and you have no photos taken today.

Benitoite commented 6 years ago

It does look like no images imported. I did get messages like this when switching to Organize:

importWorker replace location: /Users/tune/Desktop/_8237002-8237005.dng
importWorker replace STsearchID: 29b57c76c74518ab9e859fbfa4786bad0001

The build steps are fairly straightforward to get a running binary, once the code was adapted to my system (as in the above big unified diff).

Making the bundle is more complicated...

CarVac commented 6 years ago

What's the output if you import a file with "import in place" selected, and "update file locations" turned off?

Benitoite commented 6 years ago

No output on the console for that op.

Benitoite commented 6 years ago

Updated to dev branch using Qt5.11.1 Doing that now gives this fatal crash msg in the console:

importWorker no replace, doesn't exist
Bus error: 10
CarVac commented 6 years ago

What camera is this for?

Can you post the raw somewhere?

Can you try it with a different camera's raw?

Benitoite commented 6 years ago

screen shot 2018-09-14 at 8 34 35 am

Canon T3i CR2

Same issue with several other camera's raws in my Downloads folder.

CarVac commented 6 years ago

If you have it "update file locations" it will ignore photos that are not in the database currently.

Turn that switch off.

Benitoite commented 6 years ago

That results in the fatal error seen above: https://github.com/CarVac/filmulator-gui/issues/71#issuecomment-421179339


Thread 11 Crashed:: QThread
0   filmulator                      0x00000001094d34f8 createNewProfile(QString, QString, QDateTime, QDateTime, Exiv2::ExifData, Exiv2::XmpData) + 56
1   filmulator                      0x00000001094ccd90 ImportWorker::importFile(QFileInfo, int, int, QString, QString, QString, QDateTime, bool, bool, bool) + 5168
2   filmulator                      0x00000001094ec8d2 ImportWorker::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 514
3   org.qt-project.QtCore           0x000000010a6dd964 QObject::event(QEvent*) + 788
4   org.qt-project.QtWidgets        0x000000010af9cf12 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 306
5   org.qt-project.QtWidgets        0x000000010af9e2ed QApplication::notify(QObject*, QEvent*) + 573
6   org.qt-project.QtCore           0x000000010a6b454f QCoreApplication::notifyInternal2(QObject*, QEvent*) + 159
7   org.qt-project.QtCore           0x000000010a6b5722 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 850
8   org.qt-project.QtCore           0x000000010a70a5b9 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 73
9   org.qt-project.QtCore           0x000000010a6b00a2 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 418
10  org.qt-project.QtCore           0x000000010a4fa101 QThread::exec() + 113
11  org.qt-project.QtCore           0x000000010a503657 QThreadPrivate::start(void*) + 359
12  libsystem_pthread.dylib         0x00007fffa303493b _pthread_body + 180
13  libsystem_pthread.dylib         0x00007fffa3034887 _pthread_start + 286
14  libsystem_pthread.dylib         0x00007fffa303408d thread_start + 13
CarVac commented 6 years ago

I'll have to do some investigation on what might cause a bus error. It seems it's something like a segfault.

CarVac commented 6 years ago

You may want to add some couts somewhere after this line to figure out where the error is occurring:

https://github.com/CarVac/filmulator-gui/blob/1150b31dea14a3c62f42e14c92e42903a3cc9c03/filmulator-gui/database/importWorker.cpp#L118

Actually, you need to look in database/sqlInsertion.cpp in the createNewProfile method.

Maybe there's an issue with writing to the database... I'm not sure why it wouldn't fail upon starting the program though.

Benitoite commented 6 years ago

I added some:

diff --git a/filmulator-gui/database/importWorker.cpp b/filmulator-gui/database/importWorker.cpp
index da12e46..a0a5d49 100644
--- a/filmulator-gui/database/importWorker.cpp
+++ b/filmulator-gui/database/importWorker.cpp
@@ -118,24 +118,33 @@ void ImportWorker::importFile(const QFileInfo infoIn,
     //And we're not updating locations
     //  (if we are updating locations, we don't want it to add new things to the db)
     bool changedST = false;
+    cout << "point C" << endl;
     if (dbRecordedPath == "" && !replaceLocation)
     {
+        cout << "point B" << endl;
         cout << "importWorker no replace, doesn't exist" << endl;
         //Record the file location in the database.
         if (!importInPlace)
         {
             //Copy the file into our main directory. We assume it's not in here yet.
+            cout << "point A" << endl;
             QFile::copy(infoIn.absoluteFilePath(), outputPathName);
+            cout << "point 1" << endl;
             fileInsert(hashString, outputPathName, exifData);
+            cout << "point 2" << endl;
         }
         else
         {
+            cout << "point 3" << endl;
             //If it's being imported in place, then we don't copy the file.
             fileInsert(hashString, infoIn.absoluteFilePath(), exifData);
+            cout << "point 4" << endl;
         }

+        cout << "point 5" << endl;
         //Now create a profile and a search table entry, and a thumbnail.
         QString STsearchID;
+        cout << "point 6" << endl;
         STsearchID = createNewProfile(hashString,
                                       filename,
                                       exifUtcTime(exifData, cameraTZ),
@@ -143,41 +152,61 @@ void ImportWorker::importFile(const QFileInfo infoIn,
                                       exifData,
                                       xmpData);

+        cout << "point 7" << endl;
         //Request that we enqueue the image.
         cout << "importFile SearchID: " << STsearchID.toStdString() << endl;
+        cout << "point 8" << endl;
         if (QString("") != STsearchID)
         {
+            cout << "point 9" << endl;
             emit enqueueThis(STsearchID);
+            cout << "point 10" << endl;
         }
         //It might be ignored downstream, but that's not our problem here.

         //Tell the views we need updating.
+        cout << "point 11" << endl;
         changedST = true;
+        cout << "point 12" << endl;
     }
     else if (dbRecordedPath != "")//it's already in the database, so just move the file.
     {
+        cout << "point 14" << endl;
         //See if the file is in its old location, and copy if not.
         //DON'T do this if we're updating the location.
         if (!QFile::exists(dbRecordedPath) && !importInPlace && !replaceLocation)
         {
+            cout << "point 15" << endl;
             QFile::copy(infoIn.absoluteFilePath(), outputPathName);
+            cout << "point 16" << endl;
         }

+        cout << "point 17" << endl;
         //If we want to update the location of the file.
         if (replaceLocation)
         {
+            cout << "point 18" << endl;
             fileInsert(hashString, infoIn.absoluteFilePath(), exifData);
+            cout << "point 19" << endl;
             cout << "importWorker replace location: " << infoIn.absoluteFilePath().toStdString() << endl;

+            cout << "point 20" << endl;
             QString STsearchID = hashString.append(QString("%1").arg(1, 4, 10, QLatin1Char('0')));
+            cout << "point 21" << endl;
             cout << "importWorker replace STsearchID: " << STsearchID.toStdString() << endl;

+            cout << "point 22" << endl;
             if (QString("") != STsearchID)
             {
+                cout << "point 23" << endl;
                 emit enqueueThis(STsearchID);
+                cout << "point 24" << endl;
             }
+            cout << "point 25" << endl;
         }
+        cout << "point 26" << endl;
     }
+    cout << "point 27" << endl;
     //else do nothing.

     //Tell the ImportModel whether we did anything to the SearchTable

Got to the point:

QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
QSqlQuery::value: not positioned on a valid record
point C
point 27
QSqlQuery::value: not positioned on a valid record
point C
point 27
QSqlQuery::value: not positioned on a valid record
point C
point B
importWorker no replace, doesn't exist
point 3
point 4
point 5
point 6
Segmentation fault: 11

This points to the call listed at the top of the crashed stack as reported above in https://github.com/CarVac/filmulator-gui/issues/71#issuecomment-421411969 https://github.com/CarVac/filmulator-gui/blob/c221682013f0e45a9e0f59a0adbb2f53fa4fdebb/filmulator-gui/database/importWorker.cpp#L139-L144

Benitoite commented 6 years ago

Explanation of the run above. Two import tries with Update File Locations on, and one crashed try with it off.

CarVac commented 6 years ago

Yeah, it's definitely occurring inside createNewProfile, which is in database/sqlInsertion.

Can you try instrumenting that and observing where it fails?

Benitoite commented 6 years ago

Running the function with cout’s

diff --git a/filmulator-gui/database/sqlInsertion.cpp b/filmulator-gui/database/sqlInsertion.cpp
index 1b00c76..a2ac947 100644
--- a/filmulator-gui/database/sqlInsertion.cpp
+++ b/filmulator-gui/database/sqlInsertion.cpp
@@ -46,20 +46,33 @@ QString createNewProfile(const QString fileHash,
                          Exiv2::ExifData exifData,
                          Exiv2::XmpData xmpData)
 {
+    cout << "Insertion point 1" << endl;
     //Each thread needs a unique database connection
     QSqlDatabase db = getDB();
+    cout << "Insertion point 2" << endl;
     QSqlQuery query(db);
+    cout << "Insertion point 3" << endl;
     //Retrieve the usage count from the file table, and increment it by one.
     query.prepare("SELECT FTusageIncrement FROM FileTable WHERE (FTfileID = ?);");
+    cout << "Insertion point 4" << endl;
     query.bindValue(0, fileHash);
+    cout << "Insertion point 5" << endl;
     query.exec();
+    cout << "Insertion point 6" << endl;
     query.next();
+    cout << "Insertion point 7" << endl;
     int increment = query.value(0).toInt();
+    cout << "Insertion point 8" << endl;
     increment++;
+    cout << "Insertion point 9" << endl;
     query.prepare("UPDATE FileTable SET FTusageIncrement = ? WHERE FTfileID = ?;");
+    cout << "Insertion point 10" << endl;
     query.bindValue(0, increment);
+    cout << "Insertion point 11" << endl;
     query.bindValue(1, fileHash);
+    cout << "Insertion point 12" << endl;
     query.exec();
+    cout << "Insertion point 13" << endl;

     //Create a new search table entry
     query.prepare("INSERT INTO SearchTable ("
@@ -79,41 +92,59 @@ QString createNewProfile(const QString fileHash,
                   "values (?,?,?,?,?,?,?,?,?,?,?,?,?);");
                          //0 1 2 3 4 5 6 7 8 9 101112

+    cout << "Insertion point 14" << endl;
     //searchID (filehash with the increment appended)
     QString searchID = fileHash;
+    cout << "Insertion point 15" << endl;
     searchID.append(QString("%1").arg(increment, 4, 10, QLatin1Char('0')));
+    cout << "Insertion point 16" << endl;
     query.bindValue(0, searchID);
+    cout << "Insertion point 17" << endl;
     //captureTime (unix time)
     query.bindValue(1, captureTime.toTime_t());
+    cout << "Insertion point 18" << endl;
     //name (of instance)
     query.bindValue(2, "");
+    cout << "Insertion point 19" << endl;
     //filename
     query.bindValue(3, fileName);
+    cout << "Insertion point 20" << endl;
     //sourceHash
     query.bindValue(4, fileHash);
+    cout << "Insertion point 21" << endl;
     //rating
     //TODO: write function to get rating
     query.bindValue(5, exifRating(exifData, xmpData));
+    cout << "Insertion point 22" << endl;

     //latitude
     //TODO: figure something out here to either grab from the exif or get user input.
     query.bindValue(6, 0);
+    cout << "Insertion point 23" << endl;
     //longitude
     query.bindValue(7, 0);
+    cout << "Insertion point 24" << endl;
     QDateTime now = QDateTime::currentDateTime();
+    cout << "Insertion point 25" << endl;
     //importTime (unix time)
     query.bindValue(8, now.toTime_t());
+    cout << "Insertion point 26" << endl;
     //lastProcessedTime (unix time)
     //It's the same as above, since we're making a new one.
     query.bindValue(9, now.toTime_t());
+    cout << "Insertion point 27" << endl;
     //importStartTime (unix time): lets us group together import batches.
     query.bindValue(10, importStartTime.toTime_t());
+    cout << "Insertion point 28" << endl;
     //thumbWritten
     query.bindValue(11, 0);
+    cout << "Insertion point 29" << endl;
     //bigThumbWritten (the preview)
     query.bindValue(12, 0);
+    cout << "Insertion point 30" << endl;

     query.exec();
+    cout << "Insertion point 31" << endl;

     //Now we make a new profile.
@@ -125,39 +156,52 @@ QString createNewProfile(const QString fileHash,
     //Now we generate a thumbnail.

     ParameterManager paramManager;
+    cout << "Insertion point 32" << endl;
     paramManager.selectImage(searchID);

+    cout << "Insertion point 33" << endl;
     //Next, we prepare a dummy exif object because we don't care about the thumbnail's exif.
     Exiv2::ExifData exif;

+    cout << "Insertion point 34" << endl;
     //Next, we create a dummy interface.
     Interface dummyInterface;
+    cout << "Insertion point 35" << endl;

     //Create a pipeline of the appropriate type.
     ImagePipeline pipeline = ImagePipeline(NoCache, NoHisto, LowQuality);
-
+cout << "Insertion point 36" << endl;
     //Process an image.
     matrix<unsigned short> image = pipeline.processImage(&paramManager, &dummyInterface, exif);
-
+cout << "Insertion point 37" << endl;
     //Write the thumbnail.
     ThumbWriteWorker worker;
+    cout << "Insertion point 38" << endl;
     worker.setImage(image, exif);
+    cout << "Insertion point 39" << endl;
     bool writeError = worker.writeThumb(searchID);
+    cout << "Insertion point 40" << endl;
     //imwrite_jpeg(image, outputFilename.toStdString(), exif, 90);

     //Because it might take some time to prepare the thumbnail,
     // set the import time to be equal to the last processed time.
     query.prepare("update SearchTable set STimportTime = STlastProcessedTime WHERE STsearchID = ?;");
+    cout << "Insertion point 41" << endl;
     query.bindValue(0, searchID);
+    cout << "Insertion point 42" << endl;
     query.exec();
+    cout << "Insertion point 43" << endl;

     //Return STsearchID, only if the thumb was written successfully.
     if(!writeError)
     {
+        cout << "Insertion point 44" << endl;
         return searchID;
     }
     else
     {
+        cout << "Insertion point 45" << endl;
         return QString("");
     }
+    cout << "Insertion point 46" << endl;
 }

But it outputs nothing, as there is a crash when the code is called?

importWorker no replace, doesn't exist
point 3
point 4
point 5
point 6
Segmentation fault: 11
CarVac commented 6 years ago

One hint seems to be that it might be running out of stack space; that's what Segmentation fault: 11 means.

Maybe you can try changing the exiv2 arguments to be passed in as references?

Maybe allocate the database on the heap instead of the stack.

By the way, I'm going to be off the grid this weekend starting tonight, so don't be worried if I don't respond for a few days.

CarVac commented 6 years ago

Alternatively we can make the Qthread request a larger stack.

Benitoite commented 6 years ago

Maybe something is going on with exiv2... the heap is larger- if I remember correctly from c class twenty-some odd years ago... Enjoy your stay in the woods... ⚙️ 🏙 🚗 vs. 🌴 🏖 🍹

CarVac commented 6 years ago

Can you try the new macstack branch?

https://github.com/CarVac/filmulator-gui/tree/macstack

I increased the import worker thread stack size to what's apparently the default on Linux.

Benitoite commented 6 years ago

Wondering if my libraw v18.5 is too old... I've been procrastinating upgrading it for reasons. As you can see... progress has been made. Thanks for that.

Thread 7 Crashed:: QThread
0   libsystem_platform.dylib        0x00007fffa302eca3 _platform_bzero$VARIANT$Base + 51
1   libraw_r.16.dylib               0x000000010e89cdd0 LibRaw::LibRaw(unsigned int) + 176 (libraw_cxx.cpp:388)
2   filmulator                      0x000000010e127e5a whiteBalanceMults(float, float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float&, float&, float&) + 74
3   filmulator                      0x000000010e128adc whiteBalance(matrix<float>&, matrix<float>&, float, float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 76
4   filmulator                      0x000000010e120b77 ImagePipeline::processImage(ParameterManager*, Interface*, Exiv2::ExifData&) + 5399
5   filmulator                      0x000000010e13c4b5 createNewProfile(QString, QString, QDateTime, QDateTime, Exiv2::ExifData, Exiv2::XmpData) + 6325
6   filmulator                      0x000000010e134072 ImportWorker::importFile(QFileInfo, int, int, QString, QString, QString, QDateTime, bool, bool, bool) + 8178
7   filmulator                      0x000000010e1561a2 ImportWorker::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 514
8   org.qt-project.QtCore           0x000000010f3e0964 QObject::event(QEvent*) + 788
9   org.qt-project.QtWidgets        0x000000010fca0f12 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 306
10  org.qt-project.QtWidgets        0x000000010fca22ed QApplication::notify(QObject*, QEvent*) + 573
11  org.qt-project.QtCore           0x000000010f3b754f QCoreApplication::notifyInternal2(QObject*, QEvent*) + 159
12  org.qt-project.QtCore           0x000000010f3b8722 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 850
13  org.qt-project.QtCore           0x000000010f40d5b9 QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 73
14  org.qt-project.QtCore           0x000000010f3b30a2 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 418
15  org.qt-project.QtCore           0x000000010f1fd101 QThread::exec() + 113
16  org.qt-project.QtCore           0x000000010f206657 QThreadPrivate::start(void*) + 359
17  libsystem_pthread.dylib         0x00007fffa303493b _pthread_body + 180
18  libsystem_pthread.dylib         0x00007fffa3034887 _pthread_start + 286
19  libsystem_pthread.dylib         0x00007fffa303408d thread_start + 13
CarVac commented 6 years ago

Version 0.18.x is the newest version usable until you get to the librtprocess branch, which is still under heavy development and hasn't quite reached feature parity.

Benitoite commented 6 years ago

LibRaw 18.13 seems to work... next error maybe another stack overflow:

point C
point B
importWorker no replace, doesn't exist
point 3
point 4
point 5
point 6
Insertion point 1
Insertion point 2
Insertion point 3
Insertion point 4
Insertion point 5
Insertion point 6
Insertion point 7
Insertion point 8
Insertion point 9
Insertion point 10
Insertion point 11
Insertion point 12
Insertion point 13
Insertion point 14
Insertion point 15
Insertion point 16
Insertion point 17
Insertion point 18
Insertion point 19
Insertion point 20
Insertion point 21
Insertion point 22
Insertion point 23
Insertion point 24
Insertion point 25
Insertion point 26
Insertion point 27
Insertion point 28
Insertion point 29
Insertion point 30
Insertion point 31
Insertion point 32
Insertion point 33
Insertion point 34
Insertion point 35
Insertion point 36
imagePipeline.cpp: Opening /Users/tune/Desktop/film18/IMG_3586.CR2
load start:1.8e-05
load time: 5.64705
ImagePipeline::processImage: Demosaic complete.
scale start:5.64711
scale end: 0.944925
Bus error: 10

Program exits, no system crash report.

CarVac commented 6 years ago

You can safely remove your earlier debug couts...

And now, could you put them in starting at this line?

https://github.com/CarVac/filmulator-gui/blob/macstack/filmulator-gui/core/imagePipeline.cpp#L262

Between lines 262 and 300...

Benitoite commented 6 years ago

couts added:

diff --git a/filmulator-gui/core/imagePipeline.cpp b/filmulator-gui/core/imagePipeline.cpp
index 41929c7..4022a9d 100644
--- a/filmulator-gui/core/imagePipeline.cpp
+++ b/filmulator-gui/core/imagePipeline.cpp
@@ -259,44 +259,57 @@ matrix<unsigned short> ImagePipeline::processImage(ParameterManager * paramManag
                 input_image.set_size(0,0);
             }
         }
-
+        cout << "point 1" << endl;
         valid = paramManager->markDemosaicComplete();
+        cout << "point 2" << endl;
         updateProgress(valid, 0.0f);
+        cout << "point 3" << endl;
         [[fallthrough]];
     }
     case partprefilmulation: [[fallthrough]];
     case demosaic://Do pre-filmulation work.
     {
+        cout << "point 4" << endl;
         AbortStatus abort;
+        cout << "point 5" << endl;
         std::tie(valid, abort, prefilmParam) = paramManager->claimPrefilmParams();
+        cout << "point 6" << endl;
         if (abort == AbortStatus::restart)
         {
+            cout << "point 7" << endl;
             return emptyMatrix();
         }
-
+cout << "point 8" << endl;
         //Here we apply the exposure compensation and white balance.
         matrix<float> exposureImage = scaled_image * pow(2, prefilmParam.exposureComp);
+        cout << "point 9" << endl;
         whiteBalance(exposureImage,
                      pre_film_image,
                      prefilmParam.temperature,
                      prefilmParam.tint,
                      prefilmParam.fullFilename);
-
+cout << "point 10" << endl;
         if (NoCache == cache)
         {
+            cout << "point 11" << endl;
             scaled_image.set_size( 0, 0 );
+            cout << "point 12" << endl;
             cacheEmpty = true;
+            cout << "point 13" << endl;
         }
         else
         {
+            cout << "point 14" << endl;
             cacheEmpty = false;
         }
+        cout << "point 15" << endl;
         if (WithHisto == histo)
         {
             //Histogram work
+            cout << "point 16" << endl;
             histoInterface->updateHistPreFilm(pre_film_image, 65535);
         }
-
+cout << "point 17" << endl;
         cout << "ImagePipeline::processImage: Prefilmulation complete." << endl;

         valid = paramManager->markPrefilmComplete();

And the run...

imagePipeline.cpp: Opening /Users/tune/Desktop/100CANON/IMG_4789.CR2
load start:3.2e-05
load time: 5.68816
ImagePipeline::processImage: Demosaic complete.
scale start:5.68824
scale end: 0.778579
point 1
point 2
point 3
point 4
point 5
point 6
point 8
point 9
Bus error: 10
CarVac commented 6 years ago

Alright, so now (as I somewhat suspected) the issue is inside whiteBalance or more likely whiteBalanceMults.

Could you instrument those?

Thanks.

Benitoite commented 6 years ago

Taking a look at whiteBalanceMults():

diff --git a/filmulator-gui/core/whiteBalance.cpp b/filmulator-gui/core/whiteBalance.cpp
index 20c69c5..2be8987 100644
--- a/filmulator-gui/core/whiteBalance.cpp
+++ b/filmulator-gui/core/whiteBalance.cpp
@@ -1,6 +1,7 @@
 #include "filmSim.hpp"
 #include <utility>
 #include <iostream>
+#include <array>

 using std::cout;
 using std::endl;
@@ -122,16 +123,22 @@ void whiteBalanceMults(float temperature, float tint, std::string inputFilename,
     //
     //The following values are our baseline estimate of what this temperature
     // and tint is.
+    cout << "wbm point 1" << endl;
     float BASE_TEMP = 6594.9982;
+    cout << "wbm point 2" << endl;
     float BASE_TINT = 0.9864318;
+    cout << "wbm point 3" << endl;

     float rBaseMult, gBaseMult, bBaseMult;
+    cout << "wbm point 4" << endl;
     //Grab the existing white balance data from the raw file.
     LibRaw imageProcessor;
+    cout << "wbm point 5" << endl;
 #define COLOR imageProcessor.imgdata.color
 #define PARAM imageProcessor.imgdata.params

     const char *cstr = inputFilename.c_str();
+    cout << "wbm point 6" << endl;
     if (0 == imageProcessor.open_file(cstr))
     {
         //Set the white balance arguments based on what libraw did.
@@ -141,26 +148,37 @@ void whiteBalanceMults(float temperature, float tint, std::string inputFilename,

         //Grab the xyz2cam matrix.
 //        float xyzToCam[3][3];
+        cout << "wbm point 7" << endl;
         float camToRgb[3][3];
 //        cout << "white_balance: camToRgb" << endl;//===========================
         for (int i = 0; i < 3; i++)
         {
+            cout << "wbm point 8" << endl;
             for (int j = 0; j < 3; j++)
             {
+                cout << "wbm point 9" << endl;
 //                xyzToCam[i][j] = COLOR.cam_xyz[i][j];
                 camToRgb[i][j] = COLOR.rgb_cam[i][j];
+                cout << "wbm point 10" << endl;
 //                cout << COLOR.rgb_cam[i][j] << " ";//===========================
             }
 //            cout << endl;//===========================
         }
         //Now we divide the daylight multipliers by the camera multipliers.
         float rrBaseMult = COLOR.pre_mul[0] / COLOR.cam_mul[0];
+        cout << "wbm point 11" << endl;
         float grBaseMult = COLOR.pre_mul[1] / COLOR.cam_mul[1];
+        cout << "wbm point 12" << endl;
         float brBaseMult = COLOR.pre_mul[2] / COLOR.cam_mul[2];
+        cout << "wbm point 13" << endl;
         float rawMultMin = min(min(rrBaseMult, grBaseMult), brBaseMult);
+        cout << "wbm point 14" << endl;
         rrBaseMult /= rawMultMin;
+        cout << "wbm point 15" << endl;
         grBaseMult /= rawMultMin;
+        cout << "wbm point 16" << endl;
         brBaseMult /= rawMultMin;
+        cout << "wbm point 17" << endl;
 //        cout << "white_balance raw pre_muls" << endl;//===========================
 //        cout << rrBaseMult << " ";//===========================
 //        cout << grBaseMult << " ";//===========================
@@ -169,6 +187,7 @@ void whiteBalanceMults(float temperature, float tint, std::string inputFilename,
         matrixVectorMult(rrBaseMult, grBaseMult, brBaseMult,
                           rBaseMult,  gBaseMult,  bBaseMult,
                           camToRgb);
+        cout << "wbm point 18" << endl;
 //        cout << "white_balance sRGB base_mults" << endl;//===========================
 //        cout << rBaseMult << " ";//===========================
 //        cout << gBaseMult << " ";//===========================
@@ -176,21 +195,33 @@ void whiteBalanceMults(float temperature, float tint, std::string inputFilename,
         if ((1.0f == camToRgb[0][0] && 1.0f == camToRgb[1][1] && 1.0f == camToRgb[2][2])
              || (1.0f == COLOR.pre_mul[0] && 1.0f == COLOR.pre_mul[1] && 1.0f == COLOR.pre_mul[2]))
         {
+            cout << "wbm point 19" << endl;
 //            cout << "Unity camera matrix or base multipliers. BORK" << endl;
             rBaseMult = 1;
+            cout << "wbm point 20" << endl;
             gBaseMult = 1;
+            cout << "wbm point 21" << endl;
             bBaseMult = 1;
+            cout << "wbm point 22" << endl;
             BASE_TEMP = 5200;
+            cout << "wbm point 23" << endl;
             BASE_TINT = 1;
+            cout << "wbm point 24" << endl;
         }
     }
     else //it couldn't read the file, or it wasn't raw. Either way, fallback to 1
     {
+        cout << "wbm point 25" << endl;
         rBaseMult = 1;
+        cout << "wbm point 26" << endl;
         gBaseMult = 1;
+        cout << "wbm point 27" << endl;
         bBaseMult = 1;
+        cout << "wbm point 28" << endl;
         BASE_TEMP = 5200;
+        cout << "wbm point 29" << endl;
         BASE_TINT = 1;
+        cout << "wbm point 30" << endl;
     }
     //The result of this is the BaseMultipliers in sRGB, which we use later.

@@ -198,47 +229,71 @@ void whiteBalanceMults(float temperature, float tint, std::string inputFilename,
     //Here we compute the ratio of the desired to the reference (kinda daylight) illuminant.
     //Value of the desired illuminant in XYZ coordinates.
     float XIllum, YIllum, ZIllum;
+    cout << "wbm point 31" << endl;
     //Value of the base illuminant in XYZ coordinates.
     float XBase, YBase, ZBase;
+    cout << "wbm point 32" << endl;

     //Now we compute the coordinates.
     temp_to_XYZ(temperature, XIllum, YIllum, ZIllum);
+    cout << "wbm point 33" << endl;
     temp_to_XYZ(BASE_TEMP, XBase, YBase, ZBase);
+    cout << "wbm point 34" << endl;

     //Next, we convert them to sRGB.
+    cout << "wbm point 35" << endl;
     float rIllum, gIllum, bIllum;
+    cout << "wbm point 36" << endl;
     float rBase, gBase, bBase;
+    cout << "wbm point 37" << endl;
     XYZ_to_sRGB(XIllum, YIllum, ZIllum,
                 rIllum, gIllum, bIllum);
+    cout << "wbm point 38" << endl;
     XYZ_to_sRGB(XBase, YBase, ZBase,
                 rBase, gBase, bBase);
+    cout << "wbm point 39" << endl;

     //Calculate the multipliers needed to convert from one illuminant to the base.
     gIllum /= tint;
+    cout << "wbm point 40" << endl;
     gBase /= BASE_TINT;
+    cout << "wbm point 41" << endl;
     rMult = rBase / rIllum;
+    cout << "wbm point 42" << endl;
     gMult = gBase / gIllum;
+    cout << "wbm point 43" << endl;
     bMult = bBase / bIllum;
+    cout << "wbm point 44" << endl;

     //cout << "white_balance: non-offset multipliers" << endl;//===========================
     //cout << rMult << endl << gMult << endl << bMult << endl;//===========================

     //Clip negative values.
     rMult = max(rMult, 0.0f);
+    cout << "wbm point 45" << endl;
     gMult = max(gMult, 0.0f);
+    cout << "wbm point 46" << endl;
     bMult = max(bMult, 0.0f);
+    cout << "wbm point 47" << endl;

     //Multiply our desired WB by the base offsets to compensate for
     // libraw already having applied them.
     rMult *= rBaseMult;
+    cout << "wbm point 48" << endl;
     gMult *= gBaseMult;
+    cout << "wbm point 49" << endl;
     bMult *= bBaseMult;
+    cout << "wbm point 50" << endl;

     //Normalize so that no component shrinks ever. (It should never go to below zero.)
     float multMin = min(min(rMult, gMult), bMult)+0.00001;
+    cout << "wbm point 51" << endl;
     rMult /= multMin;
+    cout << "wbm point 52" << endl;
     gMult /= multMin;
+    cout << "wbm point 53" << endl;
     bMult /= multMin;
+    cout << "wbm point 54" << endl;
 }

 //Computes the Eulerian distance from the WB coefficients to (1,1,1). Also adds the temp to it.

Then the run:

imagePipeline.cpp: Opening /Volumes/terrabite/canon2/blublu/IMG_0971.CR2
load start:4.3e-05
load time: 5.71174
ImagePipeline::processImage: Demosaic complete.
scale start:5.71184
scale end: 0.875441
point 1
point 2
point 3
point 4
point 5
point 6
point 8
point 9
wbm point 1
wbm point 2
wbm point 3
wbm point 4
Bus error: 10
CarVac commented 6 years ago

Looks like I'll have to pass in the parameters as arguments...

Benitoite commented 6 years ago

Do you mean the COLOR and PARAMS defines? https://github.com/CarVac/filmulator-gui/blob/5b9a5797a057d46f799bfb0e84066346050e1ab1/filmulator-gui/core/whiteBalance.cpp#L129-L132

CarVac commented 6 years ago

Currently it's failing when I'm putting a new LibRaw object on the stack.

If I just feed it the data it needs in the function arguments, retrieved earlier, it won't need to use LibRaw again.

Benitoite commented 6 years ago

Making the bundle is more complicated...

This subset of the bundling instructions starts with a pre-existing bundle named Filmulator.app make is going to put the final result of the compilation, filmulator-gui, into filmulator-gui.app. So what I'm doing is just moving the piece that comes from the compilation into another pre-loaded bundle. This way, the bundle can include the executable bash script seen above. and doesn't require any change to Contents/Info.plist sudo because modifying apps and accessing third-party compilation tools typically requires authentication with macOS security settings. And finally macdeployqt is not sniffing out some of my/opt/localdependencies.

sudo ~/Qt/5.11.1/clang_64/bin/qmake /Users/tune/filmulator-gui/filmulator-gui/filmulator-gui.pro && sudo make -j4
sudo mv ~/filmulator-gui/filmulator-gui/filmulator-gui.app/Contents/MacOS/filmulator-gui ~/filmulator-gui/filmulator-gui/Filmulator.app/Contents/MacOS/filmulator
sudo ~/Qt/5.11.1/clang_64/bin/macdeployqt ~/filmulator-gui/filmulator-gui/Filmulator.app -no-strip -verbose=3
sudo install_name_tool -change /opt/local/lib/libraw_r.19.dylib @rpath/libraw_r.19.dylib /Users/tune/filmulator-gui/filmulator-gui/Filmulator.app/Contents/MacOS/filmulator
sudo install_name_tool -change /opt/local/lib/libtiff.5.dylib @rpath/libtiff.5.dylib ~/filmulator-gui/filmulator-gui/Filmulator.app/Contents/MacOS/filmulator
sudo install_name_tool -change /opt/local/lib/libjpeg.9.dylib @rpath/libjpeg.9.dylib ~/filmulator-gui/filmulator-gui/Filmulator.app/Contents/MacOS/filmulator
sudo install_name_tool -add_rpath ../Frameworks ~/filmulator-gui/filmulator-gui/Filmulator.app/Contents/MacOS/filmulator
CarVac commented 6 years ago

I've just rebased the macstack branch off of the librtprocess branch, which no longer uses LibRaw for demosaicing, instead using a new library with code moved from RawTherapee to be shared among open-source raw processing software.

https://github.com/CarVac/librtprocess

If you have any trouble building now, just let me know...

Benitoite commented 6 years ago
importWorker no replace, doesn't exist
camToRGB: 1.87946 -1.03258 0.153119 
camToRGB: -0.219785 1.71527 -0.495482 
camToRGB: 0.00691171 -0.514973 1.50806 
data_maximum: 0
maximum: 13584
fmaximum: 0
fnorm: 0
imagePipeline.cpp: Opening /canon/bigdip/IMG_6427.CR2
load start:0.896914
load time: 1.84833
ImagePipeline::processImage: Demosaic complete.
scale start:2.7453
scale end: 0.921006
Bus error: 10

I have compiled the macstack branch and obtain a bus error / app exits without system crash.

Benitoite commented 6 years ago

Maybe because I have yet to build LibRaw.19.

Benitoite commented 6 years ago
diff --git a/filmulator-gui/core/whiteBalance.cpp b/filmulator-gui/core/whiteBalance.cpp
index 549b271..4fd8869 100644
--- a/filmulator-gui/core/whiteBalance.cpp
+++ b/filmulator-gui/core/whiteBalance.cpp
@@ -131,11 +131,13 @@ void whiteBalancePostMults(float temperature, float tint, std::string inputFilen
     // and tint is.
     float BASE_TEMP = 6594.9982f;
     float BASE_TINT = 0.9864318f;
-
+    cout << "wbm point 1" << endl;
     float rBaseMult, gBaseMult, bBaseMult;
     //Grab the existing white balance data from the raw file.
     LibRaw imageProcessor;
+    cout << "wbm point 2" << endl;
 #define COLOR imageProcessor.imgdata.color
+    cout << "wbm point 3" << endl;
 #define PARAM imageProcessor.imgdata.params

     const char *cstr = inputFilename.c_str();

Seems to be quitting in the same place...

imagePipeline.cpp: Opening /canon/bird4/IMG_6512.CR2
load start:0.960068
load time: 1.97996
ImagePipeline::processImage: Demosaic complete.
scale start:2.94009
scale end: 1.32474
wbm point 1
Bus error: 10
Benitoite commented 6 years ago

Upgrading to libraw.19 gives the same error.