erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.37k stars 2.95k forks source link

ERL-1449: wxWidgets Assert failure: ./src/gtk/window.cpp(2888): "m_widget" in DoSetSize() : invalid window #4453

Closed OTP-Maintainer closed 3 years ago

OTP-Maintainer commented 3 years ago

Original reporter: JIRAUSER17112 Affected version: OTP-23.2 Component: Not Specified Migrated from: https://bugs.erlang.org/browse/ERL-1449


Hello,

I have maintained the Erlang package for Arch Linux since 2012. Upgrades are usually smooth, but now I have encountered an issue where I'm currently unable to find a solution.

Part of the issue is that GTK 2 has reached its end of life, and it's desirable to compile Erlang so that it uses wxgtk3 and GTK 3.

The first issue is that {{wx-config}} from the {{wxgtk2}} and {{wxgtk3}} packages collide, so that {{wx-config}} from {{wxgtk3}} is named {{/usr/bin/wx-config-gtk3}}. This confuses the Erlang config/build process, since it expects that the {{wx-config}} executable is never named {{wx-config-gtk3}}.

I found a workaround by creating a directory, placing a symlink to {{wx-config-gtk3}} named {{wx-config}} in that directory, and adding that to the {{$PATH}} before running configure. I tried various environment variables and configure flags before ending up with this.

After this change, Erlang builds and GTK3 works. However (and now comes the real issue), when running:
{code:java}
erl{code}
And then
{code:java}
wx:demo().{code}
All the examples works great, except from the {{gl}} example. When selecting the {{gl}} example, I get this error:
{code:java}
=ERROR REPORT==== 21-Dec-2020::16:15:50.994143 ===
 wx: error
 message: wxWidgets Assert failure: ./src/gtk/window.cpp(2888): "m_widget" in DoSetSize() : invalid window{code}
I'm not entirely sure if this is even Erlang's fault, or if this is an issue in wxgtk3, or how the wxgtk3 package has been configured and installed, but it did not happen with wxgtk2.

Is this an issue in Erlang?

Any help is appreciated.

Best regards,
 Alexander F. Rødseth
OTP-Maintainer commented 3 years ago

dgud said:

I don't know, which wxWidgets version are you using? 

I have only tested wxWidgets-3.1.X with GTK-3, which mostly works.

The wxWidgets-3.0. branch gets almost no updates/fixes and no new functionality, so supporting GTK-3 might
be regarded as such. 
OTP-Maintainer commented 3 years ago

JIRAUSER17112 said:

I'm using "wgtk3" and "wgtk-common", both at version 3.0.5.1.

"gtk3" is at version 3.24.24.

Most applications will probably work fine with Erlang + wxgtk3 + OpenGL not working, but Wings3D stops working.
OTP-Maintainer commented 3 years ago

dgud said:

That is bad, I believe that wings should be correct in it's OpenGL handling.

Wayland or X?

Opengl does not work with wayland and wxwidgets.

Wings sets GDK_BACKEND=x11 though so that should work.
Or it does that in the default install script but you might not use that?
OTP-Maintainer commented 3 years ago

JIRAUSER17112 said:

I currently use Sway/Wayland, but I'll make sure to test with X11 as well (using Xfce4).
OTP-Maintainer commented 3 years ago

JIRAUSER17112 said:

Under Sway/Wayland, running `GDK_BACKEND=x11 erl` makes the GL example in `wx.demo().` work. `GDK_BACKEND=x11 wings` also works here now. I must have forgotten to run with `GDK_BACKEND=x11 erl` when testing. Thanks for the reminder.

I also applied this patch from Debian to the Erlang package when switching over to wxWidgets 3, but I'm not sure if it's really needed or not:

 
{code:java}
Description: Fix constants for wxwidgets3.0
 The values of wx constants can change between stable release series (and
 some have between 2.8 and 3.0), but erlang seems to hardcode these values.
Author: Olly Betts <olly@survex.com>
Bug-Debian: https://bugs.debian.org/766790
Forwarded: no
Last-Update: 2014-11-25
--- a/lib/wx/include/wx.hrl
+++ b/lib/wx/include/wx.hrl
@@ -767,7 +767,7 @@
 % From "checkbox.h"
 -define(wxCHK_ALLOW_3RD_STATE_FOR_USER, 8192).
 -define(wxCHK_3STATE, 4096).
--define(wxCHK_2STATE, 0).
+-define(wxCHK_2STATE, 16384).
 % From "checkbox.h": wxCheckBoxState
 -define(wxCHK_UNCHECKED, 0).
 -define(wxCHK_CHECKED, 1).
@@ -1014,10 +1014,10 @@
 -define(wxSIZE_AUTO_WIDTH, 1).
 -define(wxSETUP, 131072).
 -define(wxMORE, 65536).
--define(wxHELP, 32768).
--define(wxRESET, 16384).
--define(wxBACKWARD, 8192).
--define(wxFORWARD, 4096).
+-define(wxHELP, 4096).
+-define(wxRESET, 32768).
+-define(wxBACKWARD, 16384).
+-define(wxFORWARD, 8192).
 -define(wxICON_MASK, (16#00000100 bor 16#00000200 bor 16#00000400 bor 16#00000800)).
 -define(wxICON_ASTERISK, ?wxICON_INFORMATION).
 -define(wxICON_STOP, ?wxICON_HAND).
@@ -1049,8 +1049,8 @@
 -define(wxTC_TOP, 0).
 -define(wxTC_FIXEDWIDTH, 32).
 -define(wxTC_RIGHTJUSTIFY, 16).
--define(wxSP_WRAP, 8192).
--define(wxSP_ARROW_KEYS, 4096).
+-define(wxSP_WRAP, 32768).
+-define(wxSP_ARROW_KEYS, 16384).
 -define(wxSP_VERTICAL, ?wxVERTICAL).
 -define(wxSP_HORIZONTAL, ?wxHORIZONTAL).
 -define(wxSB_VERTICAL, ?wxVERTICAL).
@@ -1071,8 +1071,8 @@
 -define(wxCB_SIMPLE, 4).
 -define(wxLB_INT_HEIGHT, 2048).
 -define(wxLB_HSCROLL, ?wxHSCROLL).
--define(wxLB_ALWAYS_SB, 1024).
--define(wxLB_NEEDED_SB, 512).
+-define(wxLB_ALWAYS_SB, 512).
+-define(wxLB_NEEDED_SB, 0).
 -define(wxLB_OWNERDRAW, 256).
 -define(wxLB_EXTENDED, 128).
 -define(wxLB_MULTIPLE, 64).
@@ -1548,7 +1548,7 @@
 -define(wxUPDATE_UI_FROMIDLE, 2).
 % From "dialog.h"
 -define(wxDEFAULT_DIALOG_STYLE, (?wxCAPTION bor ?wxSYSTEM_MENU bor ?wxCLOSE_BOX)).
--define(wxDIALOG_NO_PARENT, 1).
+-define(wxDIALOG_NO_PARENT, 32).
 % From "dirctrlg.h"
 -define(wxDIRCTRL_DIR_ONLY, 16).
 -define(wxDIRCTRL_SELECT_FIRST, 32).
@@ -3728,7 +3728,7 @@
 -define(wxSTC_KEY_LEFT, 302).
 -define(wxSTC_KEY_UP, 301).
 -define(wxSTC_KEY_DOWN, 300).
--define(wxSTC_MODEVENTMASKALL, 8191).
+-define(wxSTC_MODEVENTMASKALL, 1048575).
 -define(wxSTC_MULTILINEUNDOREDO, 4096).
 -define(wxSTC_MOD_BEFOREDELETE, 2048).
 -define(wxSTC_MOD_BEFOREINSERT, 1024).
@@ -3810,7 +3810,7 @@
 -define(wxSTC_INDIC_TT, 2).
 -define(wxSTC_INDIC_SQUIGGLE, 1).
 -define(wxSTC_INDIC_PLAIN, 0).
--define(wxSTC_INDIC_MAX, 7).
+-define(wxSTC_INDIC_MAX, 31).
 -define(wxSTC_CASE_LOWER, 2).
 -define(wxSTC_CASE_UPPER, 1).
 -define(wxSTC_CASE_MIXED, 0).
@@ -3835,7 +3835,7 @@
 -define(wxSTC_CHARSET_BALTIC, 186).
 -define(wxSTC_CHARSET_DEFAULT, 1).
 -define(wxSTC_CHARSET_ANSI, 0).
--define(wxSTC_STYLE_MAX, 127).
+-define(wxSTC_STYLE_MAX, 255).
 -define(wxSTC_STYLE_LASTPREDEFINED, 39).
 -define(wxSTC_STYLE_CALLTIP, 38).
 -define(wxSTC_STYLE_INDENTGUIDE, 37).
@@ -3934,9 +3934,9 @@
 -define(wxTE_PROCESS_TAB, 64).
 -define(wxTE_MULTILINE, 32).
 -define(wxTE_READONLY, 16).
--define(wxTE_AUTO_SCROLL, 8).
+-define(wxTE_AUTO_SCROLL, 0).
 -define(wxTE_NO_VSCROLL, 2).
--define(wxHAS_TEXT_WINDOW_STREAM, 0).
+-define(wxHAS_TEXT_WINDOW_STREAM, 1).
 % From "textctrl.h": wxTextAttrAlignment
 -define(wxTEXT_ALIGNMENT_DEFAULT, 0).
 -define(wxTEXT_ALIGNMENT_LEFT, 1).
@@ -3986,7 +3986,7 @@
 -define(wxDEFAULT_FRAME_STYLE, (?wxSYSTEM_MENU bor ?wxRESIZE_BORDER bor ?wxMINIMIZE_BOX bor ?wxMAXIMIZE_BOX bor ?wxCLOSE_BOX bor ?wxCAPTION bor ?wxCLIP_CHILDREN)).
 -define(wxRESIZE_BORDER, 64).
 -define(wxTINY_CAPTION_VERT, 128).
--define(wxTINY_CAPTION_HORIZ, 256).
+-define(wxTINY_CAPTION_HORIZ, 128).
 -define(wxMAXIMIZE_BOX, 512).
 -define(wxMINIMIZE_BOX, 1024).
 -define(wxSYSTEM_MENU, 2048).
{code}
 

 
OTP-Maintainer commented 3 years ago

dgud said:

They might be correct, but I have never got any PR's on that.

I have reworked the handling of the constants on the master-branch.

 

If you have connections, can you ping the Arch wings maintainer that GDK_BACKEND=x11 is needed in startup script 
before erlang is started.

I'm closing this, issue then.

 

 

 
OTP-Maintainer commented 3 years ago

dgud said:

Workaround found.
OTP-Maintainer commented 3 years ago

JIRAUSER17112 said:

I am also the maintainer of the {{wings3d}} package. I really like Wings3D. :)

I might be moving off topic for this bug report, but when launching Wings3D with {{GDK_BACKEND=x11}}, I get another error, related to wxWidgets:

 
{code:java}
17:30:52: Warning: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1013,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1014,wx containers,compatible with 2.8).
2020-12-22T17:30:52.687899+01:00 error:
    wx: error
    message: not_supported in wxMenuBar:setAutoWindowMenu/1
cl_nif.c:7342: ecl_pre_load: error code = -1001
OpenCL not available: {badmatch,{error,unknown}}
Could not initialize OpenCL: env lighting limited
{code}
 
 And here's the output from the "clinfo" command on my system:

 
{code:java}
Number of platforms 1
 Platform Name NVIDIA CUDA
 Platform Vendor NVIDIA Corporation
 Platform Version OpenCL 1.2 CUDA 11.1.114
 Platform Profile FULL_PROFILE
 Platform Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_device_uuid
 Platform Extensions function suffix NV
Platform Name NVIDIA CUDA
Number of devices 1
 Device Name GeForce GTX 1650
 Device Vendor NVIDIA Corporation
 Device Vendor ID 0x10de
 Device Version OpenCL 1.2 CUDA
 Device UUID 7dce4ce6-d86e-8916-c9f2-ee8cc1d8cdda
 Driver UUID 7dce4ce6-d86e-8916-c9f2-ee8cc1d8cdda
 Valid Device LUID No
 Device LUID e600-000000000000
 Device Node Mask 0
 Driver Version 455.45.01
 Device OpenCL C Version OpenCL C 1.2 
 Device Type GPU
 Device Topology (NV) PCI-E, 01:00.0
 Device Profile FULL_PROFILE
 Device Available Yes
 Compiler Available Yes
 Linker Available Yes
 Max compute units 16
 Max clock frequency 1560MHz
 Compute Capability (NV) 7.5
 Device Partition (core)
 Max number of sub-devices 1
 Supported partition types None
 Supported affinity domains (n/a)
 Max work item dimensions 3
 Max work item sizes 1024x1024x64
 Max work group size 1024
 Preferred work group size multiple (kernel) 32
 Warp size (NV) 32
 Preferred / native vector sizes 
 char 1 / 1 
 short 1 / 1 
 int 1 / 1 
 long 1 / 1 
 half 0 / 0 (n/a)
 float 1 / 1 
 double 1 / 1 (cl_khr_fp64)
 Half-precision Floating-point support (n/a)
 Single-precision Floating-point support (core)
 Denormals Yes
 Infinity and NANs Yes
 Round to nearest Yes
 Round to zero Yes
 Round to infinity Yes
 IEEE754-2008 fused multiply-add Yes
 Support is emulated in software No
 Correctly-rounded divide and sqrt operations Yes
 Double-precision Floating-point support (cl_khr_fp64)
 Denormals Yes
 Infinity and NANs Yes
 Round to nearest Yes
 Round to zero Yes
 Round to infinity Yes
 IEEE754-2008 fused multiply-add Yes
 Support is emulated in software No
 Address bits 64, Little-Endian
 Global memory size 4104323072 (3.822GiB)
 Error Correction support No
 Max memory allocation 1026080768 (978.5MiB)
 Unified memory for Host and Device No
 Integrated memory (NV) No
 Minimum alignment for any data type 128 bytes
 Alignment of base address 4096 bits (512 bytes)
 Global Memory cache type Read/Write
 Global Memory cache size 524288 (512KiB)
 Global Memory cache line size 128 bytes
 Image support Yes
 Max number of samplers per kernel 32
 Max size for 1D images from buffer 268435456 pixels
 Max 1D or 2D image array size 2048 images
 Max 2D image size 32768x32768 pixels
 Max 3D image size 16384x16384x16384 pixels
 Max number of read image args 256
 Max number of write image args 32
 Local memory type Local
 Local memory size 49152 (48KiB)
 Registers per block (NV) 65536
 Max number of constant args 9
 Max constant buffer size 65536 (64KiB)
 Max size of kernel argument 4352 (4.25KiB)
 Queue properties 
 Out-of-order execution Yes
 Profiling Yes
 Prefer user sync for interop No
 Profiling timer resolution 1000ns
 Execution capabilities 
 Run OpenCL kernels Yes
 Run native kernels No
 Kernel execution timeout (NV) No
 Concurrent copy and kernel execution (NV) Yes
 Number of async copy engines 3
 printf() buffer size 1048576 (1024KiB)
 Built-in kernels (n/a)
 Device Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_device_uuid
NULL platform behavior
 clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) No platform
 clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) No platform
 clCreateContext(NULL, ...) [default] No platform
 clCreateContext(NULL, ...) [other] Success [NV]
 clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) No platform
 clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform
 clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) No platform
 clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
 clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) Invalid device type for platform
 clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) No platform
{code}
 This is on Linux 5.10.1 using the Nvidia 455.45.01 driver.
OTP-Maintainer commented 3 years ago

dgud said:

{code:java}
The library used 3.0 (wchar_t,compiler with C++ ABI 1013,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1014,wx containers,compatible with 2.8){code}

Looks like you have two different versions one wxWidgets-library dynamicly loaded, and another (newer) version when you compiled erlang.

{code:java}
2020-12-22T17:30:52.687899+01:00 error:
 wx: error
 message: not_supported in wxMenuBar:setAutoWindowMenu/1
{code}
Should only be called on Darwin, what is the wings-version?
I don't remember the old code, but can be that I catched the result, so that can be ignored.

I'll have to dig a bit on the OpenCL error, I have never seen that, but I don't have access to real linux these corona days, I work via wsl on windows,
So no OpenGL nor OpenCL on linux for me..

But it worked at work but that was with Ubuntu-18 with a really old minimun desktop nvidia card.

 

 

 
OTP-Maintainer commented 3 years ago

JIRAUSER17112 said:

Both the Erlang and Wings3D packages are updated now, and use gtk3. While there are some warnings/errors on the command line, Wings3D together with GDK_BACKEND=x11 appears to be working.

Thanks for the support.

Best regards andalso happy holidays.