Schildkroet / Candle2

GRBL control interface in Qt.
GNU General Public License v3.0
203 stars 56 forks source link

Candle2 crashes on start #61

Open GShabanov opened 7 months ago

GShabanov commented 7 months ago

Candle crashes without opening a window on Windows 10. I found the event in the event log. It works fine on desktop but always crashes on a laptop. It will not work to install Qt on a laptop and build the application. Exception code: 0xc0000005 Error offset: 0x000000000000414c

Primary analysis in the disassembler showed the following location: .text:0000000000404120 sub_404120 proc near .text:0000000000404120 .text:0000000000404120 var_20 = dword ptr -20h .text:0000000000404120 var_1C = dword ptr -1Ch .text:0000000000404120 .text:0000000000404120 push rdi .text:0000000000404121 push rsi .text:0000000000404122 push rbx .text:0000000000404123 sub rsp, 30h .text:0000000000404127 mov rbx, cs:_ZN7QWidget4moveERK6QPoint ; QWidget::move(QPoint const&) .text:000000000040412E mov rax, [rcx+38h] .text:0000000000404132 lea rsi, [rsp+48h+var_20] .text:0000000000404137 mov rdi, rcx .text:000000000040413A mov rcx, [rax+90h] .text:0000000000404141 mov rax, [rax+130h] .text:0000000000404148 mov rdx, [rcx+28h] .text:000000000040414C mov r8, [rax+28h] <<<<<<<< .text:0000000000404150 mov eax, [r8+1Ch] .text:0000000000404154 sub eax, [r8+14h]

I found this place by the code that calls this function. Also, to narrow the search, I noticed the presence of QWidget::move

As far as I understand it is this function: void frmMain::placeVisualizerButtons() { ui->cmdIsometric->move(ui->glwVisualizer->width() - ui->cmdIsometric->width() - 8, 8); ui->cmdTop->move(ui->cmdIsometric->geometry().left() - ui->cmdTop->width() - 8, 8); ui->cmdLeft->move(ui->glwVisualizer->width() - ui->cmdLeft->width() - 8, ui->cmdIsometric->geometry().bottom() + 8); ui->cmdFront->move(ui->cmdLeft->geometry().left() - ui->cmdFront->width() - 8, ui->cmdIsometric->geometry().bottom() + 8) ; ui->cmdFit->move(ui->glwVisualizer->width() - ui->cmdFit->width() - 8, ui->cmdLeft->geometry().bottom() + 8); }

Most likely the reason is glwVisualizer, which for some reason does not want to initialize.

GShabanov commented 7 months ago

Update: I added this code and I got this messagebox. I don't know why GL doesn't want to initialize.

void frmMain::placeVisualizerButtons() { if (ui->glwVisualizer == 0) { QMessageBox msgBox; msgBox.setText("glwVisualizer failed"); msgBox.exec(); return; }

ui->cmdIsometric->move(ui->glwVisualizer->width() - ui->cmdIsometric->width() - 8, 8);
ui->cmdTop->move(ui->cmdIsometric->geometry().left() - ui->cmdTop->width() - 8, 8);
ui->cmdLeft->move(ui->glwVisualizer->width() - ui->cmdLeft->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
ui->cmdFront->move(ui->cmdLeft->geometry().left() - ui->cmdFront->width() - 8, ui->cmdIsometric->geometry().bottom() + 8);
ui->cmdFit->move(ui->glwVisualizer->width() - ui->cmdFit->width() - 8, ui->cmdLeft->geometry().bottom() + 8);

}

Schildkroet commented 7 months ago

This seems like a graphical issue. Maybe your graphics card is too old or does not support some features.

GShabanov commented 7 months ago

But regular Candle works. Moreover, I tried the previous version 2.3, it opens (shown UI) and closes immediately. So far I understand that this is somehow related to OpenGL, but so far I have no idea how to get the event trace. I don't have a problem with other OpenGl applications. Well, for example, I can run Quake3 without problems

Schildkroet commented 7 months ago

Older Releases were built with Windows7. Then with Win10. Latest release is built via github-actions (Windows Server 2022). This might have an impact. Involved QT version might also be a possible culprit.

GShabanov commented 7 months ago

I tried to assemble the original Candle, but there really is some problem. It starts, displays the UI for literally one second, and then closes. However, the version downloaded from the site works. I built it using Qt 5.15.2, it works on the desktop, but not on the laptop. It is possible that this is a problem with new versions of Qt. I'll try to read it tomorrow, maybe this problem exists for others.

chrisrowe895 commented 7 months ago

Hi, I am having similar problem on an old Acer laptop(WIN10) that I use in my workshop with older graphics. My newer Acer laptop (WIN11) runs candle2 with no problem.

GShabanov commented 6 months ago

I found the direction where to dig. Standard Qt built with the -opengl es2 switch (standard setting for Windows). I'm currently struggling with assembling Qt itself, since this process is not fast, even on a 12900 Intel, plus I'm doing this for the first time. As soon as I manage to build and check that it works with the -opengl dynamic setting (take from DLL), I will tell you whether it worked or not.

GShabanov commented 6 months ago

And I finally found the reason! You won't believe what it is. The default dimensions for the main form are

1646
 <height>932</height>

This compiles and produces the file ui_frmmain.h In order not to change the shape geometry manually, I changed the values void setupUi(QMainWindow *frmMain) { if (frmMain->objectName().isEmpty()) frmMain->setObjectName(QString::fromUtf8("frmMain")); frmMain->resize(952, 847);

and compiled it. Imagine my surprise when Сandle2 successfully opened on the laptop!

It turns out that the initialization of the constructor glwVisualizer = new GLWidget(frame); glwVisualizer->setObjectName(QString::fromUtf8("glwVisualizer"));

     verticalLayout_8->addWidget(glwVisualizer);

This leads to a crash since the physical size of my laptop screen is 1600x900. Those. The reason the GLWidget object is not created is that the main form is larger than the screen size.

Let me remind you once again that my regular Candle starts without problems. Default size of its form

952
 <height>847</height>

It would be nice to make this size automatic. I'm surprised how dumb Qt is to implement such a trap.

Schildkroet commented 6 months ago

This values come from the main window form https://github.com/Schildkroet/Candle2/blob/master/src/frmmain.ui#L9-L10

I can shrink the the x-size to <1600, but not the y-size

GShabanov commented 6 months ago

Yes, I understand, there is a dependence on the size of the gadgets. The main thing is that the reason has been found. Perhaps, especially for QGLWidget, you can initially make a small client window, i.e. inherit it not directly from frmmain, but make it another child one. For myself, I kind of solved the problem, it worked for me. Since I am a programmer myself I know what problems people encounter. I decided to figure it out and find the reason. Well, be sure to share my findings. Making corrections and improvements is yours. :)

giuliosaoncella commented 3 months ago

Hi to all. If it can help, I experienced "close at start" issue on Windows 10 system, due to a too-low-resolution of my notebook; installing Candle 2.6 in a full-HD 1920x1080px system the software starts up without problems... but one: the multilingual interface seems not working, even if the translations directory is present and populated... anyway, great software. I love it !!! cheers ;-)

GShabanov commented 3 months ago

I recompiled the source code with lower dimensions. It turned out that it was easier for me to work with my CNC from a laptop. Most likely there is a bug due to which Qt incorrectly repositions the OpenGL window size. Perhaps you should add a resize to the screen size at the very beginning since OpenGL will not create a context if the canvas size exceeds the screen size.