Access violation occurred when attempting to initialize dawn.

115 views
Skip to first unread message

Block Micro

unread,
Jan 26, 2024, 5:38:16 AM1/26/24
to Dawn Graphics
The code is rather simple:
static void initDawn() {
  wgpu::InstanceDescriptor desc = {};
  desc.nextInChain = nullptr;
  instance = wgpu::CreateInstance(&desc);
}
int main() {
  ::initGLFW();
  ::initDawn();
}

However, it crashes with an access violation error. Here's the backtrace and exception message. Any idea?

{34C2138A-180E-4214-814C-BB18C0F47B4C}.png

Block Micro

unread,
Jan 26, 2024, 5:44:57 AM1/26/24
to Dawn Graphics
other information:
the program is also linked with skia-m120 statically, with only graphite-dawn enabled.
 I used MSVC and linked with MSVCRT Release version statically

Block Micro

unread,
Jan 26, 2024, 5:45:27 AM1/26/24
to Dawn Graphics
{6A43496B-DD88-4688-9801-28769A35A492}.png{E2ED4C20-2925-47f8-AE6F-0113B127FE89}.png

在2024年1月26日星期五 UTC+8 18:38:16<Block Micro> 写道:

Corentin Wallez

unread,
Jan 26, 2024, 8:50:21 AM1/26/24
to Block Micro, Dawn Graphics
This is most likely caused by using libdawn_proc as the WebGPU implementation and not initializing the static proc table. Try linking against libwebgpu_dawn instead.

Dawn has multiple implementations of the WebGPU header's functions:
  • An implementation that does validation and calls the GPU driver. (libdawn_native, accessed directly with libwebgpu_dawn, which is what you should use)
  • A client-server implementation for use in Web browsers.
  • A couple implementations that allow switching between the two above by storing the pointers to all the functions in a static variable and calling them (libdawn_proc). Of course if the static table is not initialized, it will be filled with zeroes, and cause a segfault. I'm 99% sure it is what happens here.
So the problem here is not in the code, but in the build files that should link to a different target. I'm not sure what you are using, but in general a CMakeLists.txt like this one should work: https://github.com/beaufortfrancois/webgpu-cross-platform-app/blob/main/CMakeLists.txt

Hope this helps,

Cheers,

Corentin

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/787a0069-2121-4c4c-888d-b326b7ffd423n%40googlegroups.com.

Block Micro

unread,
Jan 26, 2024, 9:37:35 AM1/26/24
to Dawn Graphics
Yes, I'm using CMake and my CMakeList.txt is literally the same as the example.

target_link_libraries(demo PUBLIC skia opengl32 glfw3 vulkan-1 webgpu_dawn webgpu_cpp webgpu_glfw)

Corentin Wallez

unread,
Jan 26, 2024, 9:39:03 AM1/26/24
to Block Micro, Dawn Graphics
Then I'm not sure, it might be worth trying the demo I linked, and if it works, dig more into what could be different.

Block Micro

unread,
Jan 26, 2024, 1:01:42 PM1/26/24
to Dawn Graphics
Hmm, after some investigation, I found that it's true that I'm using  libdawn_proc instead of  libdawn_native, but how..?

Block Micro

unread,
Jan 26, 2024, 1:42:15 PM1/26/24
to Dawn Graphics
I finally figured it out... It's skia. Skia has a copy of dawn static lib in skia.lib, so I got two skia and ran into the issue.

Felix Don

unread,
Jan 28, 2025, 4:11:11 AMJan 28
to Dawn Graphics
Hi there,
I'm also facing the same issue.
Can you elaborate more on the solution you found?

Felix Don

unread,
Jan 29, 2025, 5:10:21 AMJan 29
to Dawn Graphics
ok found the solution,
Just replace the order of compilation
Screenshot 2025-01-29 at 9.12.16.png
Reply all
Reply to author
Forward
0 new messages