Skip to content

Panic: called glDebugMessageCallback but it was not loaded #2540

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

Closed
davidar opened this issue Mar 14, 2022 · 10 comments
Closed

Panic: called glDebugMessageCallback but it was not loaded #2540

davidar opened this issue Mar 14, 2022 · 10 comments
Labels
area: correctness We're behaving incorrectly backend: gles Issues with GLES or WebGL type: bug Something isn't working

Comments

@davidar
Copy link
Contributor

davidar commented Mar 14, 2022

Description
The examples are failing to run in recent master (on Windows). I bisected it down to 476b6a1

Repro steps
cargo run --example cube

Expected vs observed behavior
Should run normally, instead it panics with thread 'main' panicked at 'called glDebugMessageCallback but it was not loaded.'

It runs if I set explicitly set WGPU_BACKEND to vulkan or dx12, but looks like it's now defaulting to gl for some reason

Extra materials

stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:498
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\core\src\panicking.rs:116
   2: glow::gl46::go_panic_because_fn_not_loaded
             at C:\Users\d\.cargo\registry\src\git.cakeli.workers.dev-1ecc6299db9ec823\glow-0.11.1\src\gl46.rs:4232
   3: glow::gl46::call_atomic_ptr_2arg
             at C:\Users\d\.cargo\registry\src\git.cakeli.workers.dev-1ecc6299db9ec823\glow-0.11.1\src\gl46.rs:4314
   4: glow::gl46::struct_commands::GlFns::DebugMessageCallback
             at C:\Users\d\.cargo\registry\src\git.cakeli.workers.dev-1ecc6299db9ec823\glow-0.11.1\src\gl46.rs:10199
   5: glow::native::impl$2::debug_message_callback<void (*)(u32,u32,u32,u32,str)>
             at C:\Users\d\.cargo\registry\src\git.cakeli.workers.dev-1ecc6299db9ec823\glow-0.11.1\src\native.rs:2299
   6: wgpu_hal::gles::egl::impl$11::enumerate_adapters
             at .\wgpu-hal\src\gles\egl.rs:840
   7: wgpu_core::instance::impl$6::request_adapter::gather<wgpu_hal::gles::Api,core::marker::PhantomData<wgpu_core::id::Id<wgpu_core::instance::Adapter<wgpu_hal::empty::Api> > > >
             at .\wgpu-core\src\instance.rs:663
   8: wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>::request_adapter<wgpu_core::hub::IdentityManagerFactory>
             at .\wgpu-core\src\instance.rs:729
   9: wgpu::backend::direct::impl$3::instance_request_adapter
             at .\wgpu\src\backend\direct.rs:812
  10: wgpu::Instance::request_adapter
             at .\wgpu\src\lib.rs:1471
  11: wgpu::util::init::initialize_adapter_from_env_or_default::generator$0
             at .\wgpu\src\util\init.rs:79
  12: core::future::from_generator::impl$1::poll<wgpu::util::init::initialize_adapter_from_env_or_default::generator$0>
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\core\src\future\mod.rs:84
  13: cube::framework::setup::generator$0<cube::Example>
             at .\wgpu\examples\framework.rs:134
  14: core::future::from_generator::impl$1::poll<cube::framework::setup::generator$0>
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\core\src\future\mod.rs:84
  15: pollster::block_on<core::future::from_generator::GenFuture<cube::framework::setup::generator$0> >
             at C:\Users\d\.cargo\registry\src\git.cakeli.workers.dev-1ecc6299db9ec823\pollster-0.2.4\src\lib.rs:132
  16: cube::framework::run<cube::Example>
             at .\wgpu\examples\framework.rs:385
  17: cube::main
             at .\wgpu\examples\cube\main.rs:400
  18: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\core\src\ops\function.rs:227

Platform
Windows 11, NVIDIA

@focusright
Copy link

focusright commented May 24, 2022

I got the same issue in Windows, can't seem to get around it without
set WGPU_BACKEND=vulkan
in the terminal

@cwfitzgerald cwfitzgerald added this to the Release 0.13 milestone Jun 2, 2022
@cwfitzgerald cwfitzgerald added type: bug Something isn't working area: correctness We're behaving incorrectly labels Jun 2, 2022
@cwfitzgerald cwfitzgerald added the backend: gles Issues with GLES or WebGL label Jun 4, 2022
@cwfitzgerald
Copy link
Member

This feels like either a glow or gl46 issue. @grovesNL thoughts?

@cwfitzgerald cwfitzgerald removed this from the Release 0.13 milestone Jun 23, 2022
@grovesNL
Copy link
Collaborator

We should probably guard this call by GL version since it's not always available, see the table version in https://registry.khronos.org/OpenGL-Refpages/es3/html/glDebugMessageCallback.xhtml for example

@grovesNL
Copy link
Collaborator

We could also add a helper function to glow like fn supports_debug_message_callback(&self) -> bool and use that to guard this call on either side.

@num3ric
Copy link

num3ric commented Feb 6, 2023

Fresh clone on Windows 10 & NVIDIA RTX 3080 driver 527.56, can confirm this issue is still happening. (EDTI: Hello sample fails no matter what.)

@askeladd123
Copy link

askeladd123 commented Feb 7, 2023

I got the same issue in Windows, can't seem to get around it without set WGPU_BACKEND=vulkan in the terminal

If setting the environment variable $env:WGPU_BACKEND="vulkan" doesn't work, how can I run wgpu on a pc that defaults to gl?

@cwfitzgerald
Copy link
Member

The issue is we call the function on context creation, which happens unconditionally even when running on vulkan.

@cwfitzgerald
Copy link
Member

cwfitzgerald commented Feb 9, 2023

Okay so I think this is a naming problem - glDebugMessageCallback is supported on gles 3.2, but GL_KHR_debug, which is what we are gating our call with, defines glDebugMessageCallbackKHR. So an implementation that wants to be picky, could not support glDebugMessageCallback but support glDebugMessageCallbackKHR.

https://github.com/gfx-rs/wgpu/blob/master/wgpu-hal/src/gles/egl.rs#L885-L889 is where we call it, and supports_debug just checks for GL_KHR_debug.

@cpadilla
Copy link

@askeladd123 and those running into this issue following the example code from here: https://sotrh.github.io/learn-wgpu/beginner/tutorial2-surface/#render, I found you can change the backend on the wgpu instance you create in code by changing it from all() to the following:

        // The instance is a handle to our GPU
        // Backends::all => Vulkan + Metal + DX12 + Browser WebGPU
        let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
            backends: wgpu::Backends::from_bits_truncate(1 << wgpu::Backend::Vulkan as u32),
            dx12_shader_compiler: Default::default(),
        });

I was finding that setting the environment variable didn't work for me either.

@cwfitzgerald
Copy link
Member

Fixed in the glow 0.12.1 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: correctness We're behaving incorrectly backend: gles Issues with GLES or WebGL type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants