phma / wolkenbase

LAS point cloud processing program
GNU General Public License v3.0
3 stars 1 forks source link

Wish: Support of LAZ (compressed LAS)? #1

Open neteler opened 1 year ago

neteler commented 1 year ago

It would be great if cloudbase could read LAZ directly - we have tons of LAZ files, but neither LAS nor the space to decompress them.

phma commented 1 year ago

I've thought about this. Since Wolkenbase reads LAS files in chunks, jumping around, I think the way to do this is to decompress a file, read the LAS file, then delete the LAS file. This means that at most as many decompressed files would be on disk at once as the program is running worker threads, which by default is the number of CPU threads.

If I add code to CMakeLists.txt to look for liblaszip, can you add code to decompress a LAZ file for the time it takes to read it? LasHeader::openRead would need to be modified to detect a LAZ file, and methods added to decompress it and delete the decompressed file.

neteler commented 1 year ago

I'm not really a CPP programmer but I'll ask around to find someone.

phma commented 1 year ago

I may find time to do it myself, but if you find someone, that's good too.

phma commented 1 year ago

I just got wolkentest to write some LAZ files.

phma commented 1 year ago

What should the program do if it's built without LASzip and you open a LAZ file? They won't appear in the directory listing if built without LASzip, but you could rename a LAZ file to LAS.

neteler commented 1 year ago

I'd simply exit with error: "file unreadable". If a user renames the file extension to something unsupported it may simply fail with an error message (I hope I understood what you meant).

phma commented 1 year ago

The user will interpret that as the program crashing. Not good.

Right now, if I try to open LAZ files, when I start the process, it spews out (to the console, not a popup window) lots of "Point out of range" messages followed by "Error reading file", but it doesn't exit. It's trying to read compressed data as if they were uncompressed, and when it reads a point past the end of file, it says "Error reading file". If you opened more files than there are threads, the thread would then try to read another LAZ file, with the same result. It sets a flag that the file is compressed, but doesn't do anything with that bit yet.

I just tried opening some files that aren't LAS or LAZ. When I opened them, it said "Reading file..." but didn't put any rectangles on the screen, because they have no LAS header. When I did "Save as is", it said "Keeping zeros" on some and "Dropping zeros" on others, but read in no points and didn't bother writing the output file because it had no points to write.

phma commented 1 year ago

It now reads LAZ files, but as I haven't changed the GUI, you have to select "All files" in the open dialog to see them. I haven't made it write LAZ files, except in the test program, as I'll have to change GUI code to do so. I'm going on a trip today and will hopefully get to that next week.

neteler commented 1 year ago

What should the program do if it's built without LASzip and you open a LAZ file? They won't appear in the directory listing if built without LASzip, but you could rename a LAZ file to LAS.

Just a remark on this: There is a mime-type application/vnd.las but I did not find any for LAZ.

neteler commented 1 year ago

It now reads LAZ files,

This is super cool!

but as I haven't changed the GUI, you have to select "All files" in the open dialog to see them.

I have compiled it on Fedora 36 but the "open" dialog button actually doesn't open a window. I have QT5.15.6 running here.

My test data are these (official federal state data): https://www.opengeodata.nrw.de/produkte/geobasis/hm/3dm_l_las/3dm_l_las/

phma commented 1 year ago

When I do File|Open on the menu, it brings up a dialog box, and I can select files. If I then hit the Open button on the dialog box, the main window shows a rectangle, the bounding box, for each LAS or LAZ file I selected. What happens when you run it?

Sorry for the late response. I was at a campmeeting for Sukkot, and even if I had brought my laptop, which I didn't, connection was flaky.

neteler commented 1 year ago

When I do File|Open on the menu, it brings up a dialog box, and I can select files.

Not sure what happened but after a clean recompile "my" GUI behaves and the dialog is there so that I can open LAZ files.

Mhh, on a new run it stops again to open the dialog. There is no message in the terminal (from where I open wolkenbase), and ps aux also doesn't show anything. This time recompile didn't help. Unfortunately I have no idea how to debug this.

If I then hit the Open button on the dialog box, the main window shows a rectangle, the bounding box, for each LAS or LAZ file I selected. What happens when you run it?

I saw the LAZ files shown (I tried two). Then I ran the classifier via menu on it (nice ball moving around :-) )

Sorry for the late response. I was at a campmeeting for Sukkot, and even if I had brought my laptop, which I didn't, connection was flaky.

That's totally fine, I can wait without problems. Just wished to contribute more, but at least testing I can do.

phma commented 1 year ago

Can you explain step by step how to reproduce the bug? I don't know what you mean by "stops to open the dialog".

neteler commented 1 year ago

Earlier today I could open the File > Open dialog, now not any longer (no idea what has changed - no reboot, I just continued to work).

So I recorded a screencast:

wolkenbase_open_file_bug

phma commented 1 year ago

To debug that, run "gdb -p pidof wolkenbase" in another window. (Those are backticks. The preview renders them as monospaced, but you have to type backticks.) Then set a breakpoint at MainWindow::openFile and see what happens. If it doesn't break, check if openAction is triggered (I'm not sure how to do this).

neteler commented 1 year ago

Not sure how much this is useful (yes, it did break):

(gdb) b MainWindow::openFile
Breakpoint 1 at 0x42cfee
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/mneteler/bin/wolkenbase 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe60f6640 (LWP 772443)]
...
[New Thread 0x7fffa5cfd640 (LWP 772465)]

Thread 1 "wolkenbase" hit Breakpoint 1, 0x000000000042cfee in MainWindow::openFile() ()
(gdb) s
Single stepping until exit from function _ZN10MainWindow8openFileEv,
which has no line number information.
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffc3e0) at /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:515
Downloading 0.02 MB source file /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h
515           basic_string()                                                                                                                                    
(gdb) s
517       : _M_dataplus(_M_local_data())
(gdb) s
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_local_data (this=<optimized out>)
    at /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/new_allocator.h:83
Downloading 0.01 MB source file /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/new_allocator.h
83            __new_allocator(const __new_allocator&) _GLIBCXX_USE_NOEXCEPT { }                                                                                 
(gdb) s
517       : _M_dataplus(_M_local_data())
(gdb) s
0x00007ffff674ad00 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_local_data (this=<optimized out>)
    at /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:241
241     return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
(gdb) s
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffc3e0) at /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:520
520     _M_set_length(0);
(gdb) s
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=0, this=0x7fffffffc3e0)
    at /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.h:268
268     traits_type::assign(_M_data()[__n], _CharT());
(gdb) s
std::char_traits<char>::assign (__c2=<optimized out>, __c1=@0x7fffffffc3f0: 1 '\001')
    at /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/char_traits.h:354
Downloading 0.03 MB source file /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/char_traits.h
354             __c1 = __c2;                                                                                                                                    
(gdb) s
0x000000000042d01f in MainWindow::openFile() ()
(gdb) s
Single stepping until exit from function _ZN10MainWindow8openFileEv,
which has no line number information.
operator new (sz=48) at ../../../../libstdc++-v3/libsupc++/new_op.cc:43
Downloading 0.00 MB source file /usr/src/debug/gcc-12.2.1-2.fc36.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/libsupc++/../../../../libstdc++-v3/libsupc++/new_op.cc
43  {
(gdb) c
Continuing.

Thread 1 "wolkenbase" hit Breakpoint 1, 0x000000000042cfee in MainWindow::openFile() ()

At this point the non-opening of the submenu window happens.

(gdb) c
Continuing.
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 4146, resource id: 73400326, major code: 42 (SetInputFocus), minor code: 0
qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch), sequence: 4150, resource id: 73400326, major code: 42 (SetInputFocus), minor code: 0

Thread 1 "wolkenbase" hit Breakpoint 1, 0x000000000042cfee in MainWindow::openFile() ()

Seems to be a loop?

phma commented 1 year ago

Try n instead of s. There's no need to step into the string library, unless something's wrong with the string library.

Here's my debug run:

(gdb) break MainWindow::openFile
Breakpoint 1 at 0x4343ce: file /home/phma/src/wolkenbase/mainwindow.cpp, line 188.
(gdb) cont
Continuing.

Thread 1 "wolkenbase" hit Breakpoint 1, MainWindow::openFile (this=0x7fffae2da498)
    at /home/phma/src/wolkenbase/mainwindow.cpp:188
188       QStringList files;
(gdb) n
190       string fileName;
(gdb) 
191       ThreadAction ta;
(gdb) 
192       fileDialog=new QFileDialog(this);
(gdb) 
193       fileDialog->setWindowTitle(tr("Open LAS File"));
(gdb) 
194       fileDialog->setFileMode(QFileDialog::ExistingFiles);
(gdb) 
195       fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
(gdb) 
196       fileDialog->selectFile("");
(gdb) 
197       fileDialog->setNameFilter(tr("(*.las);;(*)"));
(gdb) 
198       dialogResult=fileDialog->exec();
(gdb) print fileDialog
$1 = (QFileDialog *) 0xca5f80
(gdb) print *fileDialog
$2 = {<QDialog> = {<QWidget> = {<QObject> = {
        _vptr$QObject = 0x7ff297e3bb20 <vtable for QFileDialog+16>, 
        static staticMetaObject = {d = {superdata = 0x0, stringdata = 0x7ff2970b73e0, 
            data = 0x7ff2970b72c0, static_metacall = 0x7ff296f40870, 
            relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0x9f3360}, 
        static staticQtMetaObject = {d = {superdata = 0x0, stringdata = 0x7ff2970ba300, 
            data = 0x7ff2970b7500, static_metacall = 0x0, relatedMetaObjects = 0x0, 
            extradata = 0x0}}}, <QPaintDevice> = {
        _vptr$QPaintDevice = 0x7ff297e3bcf8 <vtable for QFileDialog+488>, painters = 0, 
        reserved = 0x0}, static staticMetaObject = {d = {
          superdata = 0x7ff2971be980 <QObject::staticMetaObject>, 
          stringdata = 0x7ff297cd0500, data = 0x7ff297ccfe20, 
          static_metacall = 0x7ff297965f70, relatedMetaObjects = 0x0, 
          extradata = 0x0}}, data = 0x9f3490}, static staticMetaObject = {d = {
        superdata = 0x7ff297e26c20 <QWidget::staticMetaObject>, 
        stringdata = 0x7ff297cffbc0, data = 0x7ff297cffa60, 
        static_metacall = 0x7ff297b29910, relatedMetaObjects = 0x0, extradata = 0x0}}}, 
  static staticMetaObject = {d = {
      superdata = 0x7ff297e3a8c0 <QDialog::staticMetaObject>, 
      stringdata = 0x7ff297d01160, data = 0x7ff297d00b40, 
      static_metacall = 0x7ff297b3d0b0, relatedMetaObjects = 0x0, extradata = 0x0}}}
(gdb) n
199       if (dialogResult)
(gdb) print dialogResult
$3 = 1

At this point I continued, and it showed a rectangle on the screen for the file I opened.

neteler commented 1 year ago

New attempt:

(gdb) b MainWindow::openFile
Breakpoint 1 at 0x42cfee
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/mneteler/bin/wolkenbase 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe60f6640 (LWP 789834)]
...
[New Thread 0x7fffadcfd640 (LWP 789849)]

Thread 1 "wolkenbase" hit Breakpoint 1, 0x000000000042cfee in MainWindow::openFile() ()
(gdb) n
Single stepping until exit from function _ZN10MainWindow8openFileEv,
which has no line number information.
0x000000000040e1ad in MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ()
(gdb) n
Single stepping until exit from function _ZN10MainWindow18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv,
which has no line number information.
doActivate<false> (sender=0x7f2d30, signal_index=4, argv=0x7fffffffc740) at kernel/qobject.cpp:3951
Downloading 0.04 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/corelib/kernel/qobject.cpp
3951            } while ((c = c->nextConnectionList.loadRelaxed()) != nullptr && c->id <= highestConnectionId);                                                 
(gdb) n
3953        } while (list != &signalVector->at(-1) &&
(gdb) n
3852            QObjectPrivate::Connection *c = list->first.loadRelaxed();
(gdb) n
3953        } while (list != &signalVector->at(-1) &&
(gdb) n
3957            if (connections->currentConnectionId.loadRelaxed() == 0)
(gdb) n
3961            sp->connections.loadRelaxed()->cleanOrphanedConnections(sender);
(gdb) n
QAction::activate (this=0x7f2d30, event=<optimized out>) at kernel/qaction.cpp:1162
nDownloading 0.01 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/widgets/kernel/qaction.cpp
1162        } else if(event == Hover) {
(gdb) n
QMenuPrivate::activateCausedStack (this=this@entry=0x88d880, causedStack=..., action=action@entry=0x7f2d30, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1386
Downloading 0.03 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/widgets/widgets/qmenu.cpp
1386        for(int i = 0; i < causedStack.size(); ++i) {                                                                                                       
(gdb) n
1387            QPointer<QWidget> widget = causedStack.at(i);
(gdb) n
1388            if (!widget)
(gdb) n
1391            if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
(gdb) n
1399            } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
(gdb) n
1400                if (action_e == QAction::Trigger) {
(gdb) n
1401                    emit qmenubar->triggered(action);
(gdb) n
1408        }
(gdb) n
1409    }
(gdb) n
QMenuPrivate::activateAction (this=0x88d880, action=0x7f2d30, action_e=QAction::Trigger, self=<optimized out>) at widgets/qmenu.cpp:1475
1475            actionAboutToTrigger = nullptr;
(gdb) n
1477    }
(gdb) n
QApplicationPrivate::notify_helper (this=this@entry=0x531e40, receiver=receiver@entry=0x8b4cf0, e=e@entry=0x7fffffffcd20) at kernel/qapplication.cpp:3639
Downloading 0.04 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/widgets/kernel/qapplication.cpp
3639        QCoreApplicationPrivate::setEventSpontaneous(e, false);                                                                                             
(gdb) n
3640        return consumed;
(gdb) n
QApplication::notify (this=<optimized out>, receiver=0x8b4cf0, e=<optimized out>) at kernel/qapplication.cpp:3084
3084                    eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
(gdb) n
3085                    if (res && eventAccepted)
(gdb) n
3093                mouse->setAccepted(eventAccepted);
(gdb) n
Downloading 0.00 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/widgets/../../include/QtCore/../../src/corelib/kernel/qcoreevent.h
301     inline Type type() const { return static_cast<Type>(t); }
(gdb) n
3115                d->hoverGlobalPos = mouse->globalPos();
(gdb) n
Downloading 0.00 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/widgets/../../include/QtCore/../../src/corelib/tools/qpoint.h
124 Q_DECL_CONSTEXPR inline QPoint::QPoint(int xpos, int ypos) : xp(xpos), yp(ypos) {}
(gdb) n
QCoreApplication::notifyInternal2 (receiver=0x8b4cf0, event=0x7fffffffcd20) at kernel/qcoreapplication.cpp:1065
Downloading 0.03 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/corelib/kernel/qcoreapplication.cpp
1065    }                                                                                                                                                       
(gdb) n
QApplicationPrivate::sendMouseEvent (receiver=0x8b4cf0, event=event@entry=0x7fffffffcd20, alienWidget=<optimized out>, nativeWidget=0x8b4cf0, buttonDown=buttonDown@entry=0x7ffff7f0c330 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2624
2624        if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease
(gdb) n
2637        } else if (!wasLeaveAfterRelease) {
(gdb) n
2638            if (activePopupWidget) {
(gdb) n
2639                if (!QWidget::mouseGrabber())
(gdb) n
2640                    lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : nullptr);
(gdb) n
2647    }
(gdb) n
QWidgetWindow::handleMouseEvent (this=0xe8d470, event=0x7fffffffcfd0) at kernel/qwidgetwindow.cpp:581
Downloading 0.01 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/widgets/kernel/qwidgetwindow.cpp
581                 qt_last_mouse_receiver = receiver;
(gdb) n
583         } else {
(gdb) n
596         if (QApplication::activePopupWidget() != activePopupWidget
(gdb) n
629         } else if (event->type() == contextMenuTrigger
(gdb) n
646         if (releaseAfter) {
(gdb) n
647             qt_button_down = nullptr;
(gdb) n
652     }
(gdb) n
nQWidgetWindow::event (this=0xe8d470, event=0x7fffffffcfd0) at kernel/qwidgetwindow.cpp:301
301         return true;
(gdb) n
nQApplicationPrivate::notify_helper (this=<optimized out>, receiver=0xe8d470, e=0x7fffffffcfd0) at kernel/qapplication.cpp:3639
3639        QCoreApplicationPrivate::setEventSpontaneous(e, false);
(gdb) n
3640        return consumed;
(gdb) n
nQCoreApplication::notifyInternal2 (receiver=0xe8d470, event=0x7fffffffcfd0) at kernel/qcoreapplication.cpp:1065
1065    }
(gdb) n
QGuiApplicationPrivate::processMouseEvent (e=0x8158d0) at kernel/qguiapplication.cpp:2279
Downloading 0.04 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/gui/kernel/qguiapplication.cpp
n2279       e->eventAccepted = ev.isAccepted();                                                                                                                 
(gdb) n
Downloading 0.00 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/gui/../../include/QtGui/5.15.6/QtGui/qpa/../../../../../src/gui/kernel/qwindowsysteminterface_p.h
117         bool synthetic() const  { return flags & Synthetic; }
(gdb) n
QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1175
Downloading 0.01 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/gui/kernel/qwindowsysteminterface.cpp
1175            if (event->type != QWindowSystemInterfacePrivate::FlushEvents)
(gdb) n
1176                QWindowSystemInterfacePrivate::eventAccepted.storeRelaxed(event->eventAccepted);
(gdb) n
1178            delete event;
(gdb) n
1156        while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
(gdb) n
1181        return (nevents > 0);
(gdb) n
xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:106
Downloading 0.00 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp
106     return true;
(gdb) n
g_main_dispatch (context=0x7fffe0005010) at ../glib/gmain.c:3418
Downloading 0.17 MB source file /usr/src/debug/glib2-2.72.3-1.fc36.x86_64/redhat-linux-build/../glib/gmain.c
n3418             TRACE (GLIB_MAIN_AFTER_DISPATCH (g_source_get_name (source), source,                                                                          
(gdb) n
3421              g_trace_mark (begin_time_nsec, G_TRACE_CURRENT_TIME - begin_time_nsec,
(gdb) n
90    return (ts.tv_sec * SYSPROF_NSEC_PER_SEC) + ts.tv_nsec;
(gdb) n
3421              g_trace_mark (begin_time_nsec, G_TRACE_CURRENT_TIME - begin_time_nsec,
(gdb) n
3427              current->source = prev_source;
(gdb) n
3430          if (cb_funcs)
(gdb) n
3433          LOCK_CONTEXT (context);
(gdb) n
3435          if (!was_in_call)
(gdb) n
3436            source->flags &= ~G_HOOK_FLAG_IN_CALL;
(gdb) n
3438          if (SOURCE_BLOCKED (source) && !SOURCE_DESTROYED (source))
(gdb) n
3444          if (need_destroy && !SOURCE_DESTROYED (source))
(gdb) n
3451          g_source_unref_internal (source, context, TRUE);
(gdb) n
3364      for (i = 0; i < context->pending_dispatches->len; i++)
(gdb) n
3454      g_ptr_array_set_size (context->pending_dispatches, 0);
(gdb) n
g_main_context_dispatch (context=0x7fffe0005010) at ../glib/gmain.c:4138
4138      TRACE (GLIB_MAIN_CONTEXT_AFTER_DISPATCH (context));
(gdb) n
4140      UNLOCK_CONTEXT (context);
(gdb) n
g_mutex_unlock (mutex=0x7fffe0005010) at ../glib/gthread-posix.c:1522
Downloading 0.04 MB source file /usr/src/debug/glib2-2.72.3-1.fc36.x86_64/redhat-linux-build/../glib/gthread-posix.c
1522    {                                                                                                                                                       
(gdb) n
1525      prev = exchange_release (&mutex->i[0], 0);
(gdb) n
1528      if G_UNLIKELY (prev != 1)
(gdb) n
g_main_context_iterate.constprop.0 (context=context@entry=0x7fffe0005010, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4213
4213      g_main_context_release (context);
(gdb) n
4215      g_trace_mark (begin_time_nsec, G_TRACE_CURRENT_TIME - begin_time_nsec,
(gdb) n
4213      g_main_context_release (context);
(gdb) n
4215      g_trace_mark (begin_time_nsec, G_TRACE_CURRENT_TIME - begin_time_nsec,
(gdb) n
4159      begin_time_nsec = G_TRACE_CURRENT_TIME;
(gdb) n
4215      g_trace_mark (begin_time_nsec, G_TRACE_CURRENT_TIME - begin_time_nsec,
(gdb) n
4219      LOCK_CONTEXT (context);
(gdb) n
4222    }
(gdb) n
g_main_context_iteration (context=0x7fffe0005010, may_block=<optimized out>) at ../glib/gmain.c:4277
4277      UNLOCK_CONTEXT (context);
(gdb) n
4279      return retval;
(gdb) n
QEventDispatcherGlib::processEvents (this=0x686540, flags=...) at kernel/qeventdispatcher_glib.cpp:424
Downloading 0.00 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/corelib/kernel/qeventdispatcher_glib.cpp
n424        while (!result && canWait)
(gdb) n
427     d->timerSource->processEventsFlags = savedFlags;
(gdb) n
429     if (canWait)
(gdb) n
430         emit awake();
(gdb) n
432     return result;
(gdb) n
QEventLoop::exec (this=this@entry=0x7fffffffd360, flags=..., flags@entry=...) at kernel/qeventloop.cpp:231
Downloading 0.00 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/corelib/kernel/qeventloop.cpp
231     while (!d->exit.loadAcquire())
(gdb) n
Downloading 0.01 MB source file /usr/src/debug/qt5-qtbase-5.15.6-1.fc36.x86_64/src/corelib/../../include/QtCore/../../src/corelib/global/qflags.h
69          Q_DECL_CONSTEXPR inline operator uint() const noexcept { return uint(i); }                                                                          
(gdb) n
231     while (!d->exit.loadAcquire())
(gdb) n
69      Q_DECL_CONSTEXPR inline operator uint() const noexcept { return uint(i); }
(gdb) n
231     while (!d->exit.loadAcquire())
(gdb) n
69      Q_DECL_CONSTEXPR inline operator uint() const noexcept { return uint(i); }
(gdb) n
231     while (!d->exit.loadAcquire())
(gdb) n
69      Q_DECL_CONSTEXPR inline operator uint() const noexcept { return uint(i); }
(gdb) n
231     while (!d->exit.loadAcquire())
(gdb) 

At this point it "ate" my keyboard and I had to kill the process remotely... weird!

I guess I still need to debug differently?

phma commented 1 year ago

Don't run the program from the debugger when you've attached to a running process. Continue it.

Run the binary compiled for debugging (-DCMAKE_BUILD_TYPE=Debug), not the one compiled for release or installation. The debug binary should be in ~/build/wolkenbase/cdbg/, ~/build/wolkenbase/gdbg/, or ~/build/wolkenbase/dbg/, depending on which version of ~/bin/build you're using. (I have different versions on different computers, either for historical reasons or because clang doesn't work on illumos or whatever.)

I haven't had the debugger eat my keyboard, but I have had it hang when the program I was debugging crashed, and I had to kill it from another Konsole window.

neteler commented 1 year ago

Here again my debugging results:

(gdb) b MainWindow::openFile
Breakpoint 1 at 0x42d1b5: file /home/mneteler/software/wolkenbase/mainwindow.cpp, line 188.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) c
Continuing.

Thread 1 "wolkenbase" hit Breakpoint 1, MainWindow::openFile (this=0x7ffe587e0690) at /home/mneteler/software/wolkenbase/mainwindow.cpp:188
188   QStringList files;
(gdb) n
190   string fileName;
(gdb) n
191   ThreadAction ta;
(gdb) n
192   fileDialog=new QFileDialog(this);
(gdb) n
193   fileDialog->setWindowTitle(tr("Open LAS File"));
(gdb) n
194   fileDialog->setFileMode(QFileDialog::ExistingFiles);
(gdb) n
195   fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
(gdb) n
196   fileDialog->selectFile("");
(gdb) n
197   fileDialog->setNameFilter(tr("(*.las);;(*)"));
(gdb) n
198   dialogResult=fileDialog->exec();
(gdb) print fileDialog
$1 = (QFileDialog *) 0x253f930
(gdb) print *fileDialog
$2 = {<QDialog> = {<QWidget> = {<QObject> = {_vptr.QObject = 0x7fe4284eab20 <vtable for QFileDialog+16>, 
        static staticMetaObject = {d = {superdata = {direct = 0x0}, 
            stringdata = 0x7fe42745fa40 <qt_meta_stringdata_QObject>, data = 0x7fe42745f920 <qt_meta_data_QObject>, 
            static_metacall = 0x7fe4272d8e40 <QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0x1e69690}, static staticQtMetaObject = {d = {superdata = {
              direct = 0x0}, stringdata = 0x7fe4274629e0 <qt_meta_stringdata_Qt>, 
            data = 0x7fe42745fb60 <qt_meta_data_Qt>, static_metacall = 0x0, relatedMetaObjects = 0x0, 
            extradata = 0x0}}}, <QPaintDevice> = {_vptr.QPaintDevice = 0x7fe4284eacf8 <vtable for QFileDialog+488>, 
        painters = 0, reserved = 0x0}, static staticMetaObject = {d = {superdata = {
            direct = 0x7fe427564400 <QObject::staticMetaObject>}, 
          stringdata = 0x7fe428371540 <qt_meta_stringdata_QWidget>, data = 0x7fe428370e60 <qt_meta_data_QWidget>, 
          static_metacall = 0x7fe427ff0050 <QWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
          relatedMetaObjects = 0x0, extradata = 0x0}}, data = 0x1e697b0}, static staticMetaObject = {d = {
        superdata = {direct = 0x7fe4284d5840 <QWidget::staticMetaObject>}, 
        stringdata = 0x7fe4283a3a80 <qt_meta_stringdata_QDialog>, data = 0x7fe4283a3920 <qt_meta_data_QDialog>, 
        static_metacall = 0x7fe4281c0350 <QDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
        relatedMetaObjects = 0x0, extradata = 0x0}}}, static staticMetaObject = {d = {superdata = {
        direct = 0x7fe4284e98c0 <QDialog::staticMetaObject>}, 
      stringdata = 0x7fe4283a5160 <qt_meta_stringdata_QFileDialog>, 
      data = 0x7fe4283a4b40 <qt_meta_data_QFileDialog>, 
      static_metacall = 0x7fe4281d59a0 <QFileDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
      relatedMetaObjects = 0x0, extradata = 0x0}}}
(gdb) n
199   if (dialogResult)
(gdb) print fileDialog
$3 = (QFileDialog *) 0x253f930
(gdb) print fileResult
No symbol "fileResult" in current context.
(gdb) print dialogResult
$4 = 0
neteler commented 1 year ago

Probably this is relevant?

https://doc.qt.io/qt-5/qdialog.html#exec Unlike exec(), [open](https://doc.qt.io/qt-5/qdialog.html#open)() is asynchronous, and does not spin an additional event loop.

phma commented 1 year ago

I just got it to write a LAZ file when saving a file as is. The compression is not as good as the original LAZ; I'm pretty sure it's because I set the scale as fine as possible. I can fix this, but it'll take some math. Could you test it?

neteler commented 1 year ago

Sound great and would love to test. Unfortunately I am still stuck at the non-opening of the dialog (see qdialog related comment above). An option might be to implement support of opening LAS/LAZ file from command line to get the data into wolkenbase.