Wxdemo crashes on gl tab (macos)

I am an erlang/Elixir newbee and playing with wx:demo() on the latest macos (15.5) it crashes with the below error when selecting the open gl demo:

1> wx:demo().
ok
=CRASH REPORT==== 29-Jun-2025::09:45:34.206778 ===
  crasher:
    initial call: ex_gl:init/1
    pid: <0.93.0>
    registered_name: []
    exception exit: {{nif_not_loaded,module,gl,line,356},
                     [{erlang,nif_error,
                              [{nif_not_loaded,module,gl,line,356}],
                              [{error_info,#{module => erl_erts_errors}}]},
                      {gl,nif_stub_error,1,[{file,"gen/gl.erl"},{line,321}]},

Looking at installing open GL in my mac, it appears to be deprecated in favor of another framework called Metal.

I wonder if we could detect that NIF is not available and provide an appropriate error message in the Wx demo (rather than crashing it).

Thanks,
Francisco

Nah, it probably means if couldn’t find the erl_gl.EXTENSION file below lib/wx-VSN/priv/ dir.

Do you have something like that?

I do have the erl_gl.so in wx-2.5/priv

➜  priv pwd
/Users/fgarau/.asdf/installs/erlang/28.0.1/lib/wx-2.5/priv
➜  priv ll
total 9672
-rw-r--r--@ 1 fgarau  staff   2.6K 13 Jun 15:54 erlang-logo64.png
-rw-r--r--@ 1 fgarau  staff   1.3K 13 Jun 15:54 erlang-logo32.png
-rw-r--r--@ 1 fgarau  staff   6.1K 13 Jun 15:54 erlang-logo128.png
-rwxr-xr-x@ 1 fgarau  staff   4.1M 28 Jun 17:02 wxe_driver.so
-rwxr-xr-x@ 1 fgarau  staff   592K 28 Jun 17:02 erl_gl.so
➜  priv

Ok that is strange, then it should work out of the box.

I expect other error printouts, this looks like the code didn’t even try to load erl_gl.so.

We had a bug in the RC candidates, that manifested it self like this.

How did you build erlang/OTP?

What does grep -r CAN_BUILD_DRIVER lib/wx/* (in the src tree) say?

I didn’t build erlang – I’ve installed it with the asdf package manager

➜ asdf list
elixir
  1.10.2-otp-22
  1.18.4
 *1.18.4-otp-28
erlang
 *28.0.1
nodejs
  10.16.3
  21.6.2
 *24.3.0
➜  pwd
/Users/fgarau/.asdf/installs/erlang
➜  grep -r CAN_BUILD_DRIVER lib/wx-2.5/*
lib/wx-2.5/src/gen/gl.erl:-ifdef(CAN_BUILD_DRIVER).

Thanks but the installed package is no good for debugging :slight_smile:

It looks like the erlang code is built with,
CAN_BUILD_DRIVER=false

But you clearly have the driver in priv dir.

Hmm I don’t know asdf builds but this looks strange.

You could test by recompile the gl.erl:

cd /Users/fgarau/.asdf/installs/erlang/lib/wx-2.5/src/
erlc -DCAN_BUILD_DRIVER=true -o ../ebin gen/gl.erl 

Thanks! Now it works when gl is recompiled with any of the below commands:

erlc -DCAN_BUILD_DRIVER=true -o ../ebin gen/gl.erl
erlc -DCAN_BUILD_DRIVER=false -o ../ebin gen/gl.erl

and it crashes as before when recompiled as:

erlc -o ../ebin gen/gl.erl