Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candle2 crashes on start #61

Open
GShabanov opened this issue May 5, 2024 · 10 comments
Open

Candle2 crashes on start #61

GShabanov opened this issue May 5, 2024 · 10 comments

Comments

@GShabanov
Copy link

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
Copy link
Author

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
Copy link
Owner

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

@GShabanov
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link
Author

GShabanov commented May 8, 2024

And I finally found the reason! You won't believe what it is.
The default dimensions for the main form are
1646
932
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
847

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

@Schildkroet
Copy link
Owner

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
Copy link
Author

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants