Skip to content

Hundreds of webgpu compilation errors with mediapipe sources... #24253

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
Honya2000 opened this issue May 5, 2025 · 12 comments
Closed

Hundreds of webgpu compilation errors with mediapipe sources... #24253

Honya2000 opened this issue May 5, 2025 · 12 comments
Assignees

Comments

@Honya2000
Copy link

Hello,
I'm trying to compile latest mediapipe for WASM and compiler throws lot of errors during compiling of WebGPU related code:
/mediapipe/gpu/webgpu/webgpu_service.cc:79:60: error: member reference base type 'const char *' is not a structure or union
79 | adapter_info_.device.length = strlen(adapter_info_.device.data);
| ~~~~~~~~~~~~~~~~~~~~^~~~~
/mediapipe/gpu/webgpu/webgpu_service.cc:80:23: error: member reference base type 'const char *' is not a structure or union
80 | adapter_info_.vendor.data = GetAdapterVendor();

/mediapipe/gpu/webgpu/webgpu_utils.cc:30:17: error: no member named 'capabilities' in 'wgpu::InstanceDescriptor'
30 | instance_desc.capabilities.timedWaitAnyEnable = true;
| ~~~~~~~~~~~~~ ^
/mediapipe/gpu/webgpu/webgpu_utils.cc:93:53: error: no member named 'WaitAny' in 'wgpu::Instance'
93 | wgpu::WaitStatus wait_status = kWebGpuInstance->WaitAny(
| ~~~~~~~~~~~~~~~~~^
/mediapipe/gpu/webgpu/webgpu_utils.cc:159:58: error: no type named 'StringView' in namespace 'wgpu'
159 | wgpu::ComputePipeline pipeline, wgpu::StringView message) {
| ~~~~~~^
/mediapipe/gpu/webgpu/webgpu_utils.cc:157:19: error: cannot initialize a parameter of type 'CreateComputePipelineAsyncCallback' (aka 'void (*)(WGPUCreatePipelineAsyncStatus, WGPUComputePipelineImpl *, const char *, void )') with an rvalue of type 'wgpu::CallbackMode'
157 | descriptor, wgpu::CallbackMode::WaitAnyOnly,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\emsdk\upstream\emscripten\cache\sysroot/include\webgpu/webgpu_cpp.h:945:122: note: passing argument to parameter 'callback' here
945 | void CreateComputePipelineAsync(ComputePipelineDescriptor const * descriptor, CreateComputePipelineAsyncCallback callback, void * userdata) const;
| ^
/mediapipe/gpu/webgpu/webgpu_utils.cc:187:57: error: no type named 'StringView' in namespace 'wgpu'
187 | wgpu::RenderPipeline pipeline, wgpu::StringView message) {
| ~~~~~~^
/mediapipe/gpu/webgpu/webgpu_utils.cc:185:19: error: cannot initialize a parameter of type 'CreateRenderPipelineAsyncCallback' (aka 'void (
)(WGPUCreatePipelineAsyncStatus, WGPURenderPipelineImpl *, const char *, void *)') with an rvalue of type 'wgpu::CallbackMode'
185 | descriptor, wgpu::CallbackMode::WaitAnyOnly,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\emscripten\cache\sysroot/include\webgpu/webgpu_cpp.h:950:119: note: passing argument to parameter 'callback' here
950 | void CreateRenderPipelineAsync(RenderPipelineDescriptor const * descriptor, CreateRenderPipelineAsyncCallback callback, void * userdata) const;
| ^
/mediapipe/gpu/webgpu/webgpu_utils.cc:273:9: error: no type named 'TexelCopyTextureInfo' in namespace 'wgpu'
273 | wgpu::TexelCopyTextureInfo destination = {.texture = texture};
| ~~~~~~^
/mediapipe/gpu/webgpu/webgpu_utils.cc:274:9: error: no type named 'TexelCopyBufferLayout' in namespace 'wgpu'
274 | wgpu::TexelCopyBufferLayout texel_copy_buffer_layout = {
| ~~~~~~^
/mediapipe/gpu/webgpu/webgpu_utils.cc:319:9: error: no type named 'TexelCopyTextureInfo' in namespace 'wgpu'
319 | wgpu::TexelCopyTextureInfo copy_src{.texture = texture};
| ~~~~~~^
/mediapipe/gpu/webgpu/webgpu_utils.cc:320:9: error: no type named 'TexelCopyBufferInfo' in namespace 'wgpu'
320 | wgpu::TexelCopyBufferInfo copy_dst{.layout = {.bytesPerRow = bytes_per_row},

Seems like it throws errors on any function in wgpu Scope. I'm using -s USE_WEBGPU=1 for cmake setup.
Included all possible emscripten wgpu related headers:
#include <emscripten.h>
#include <emscripten/em_js.h>
#include <webgpu/webgpu_cpp.h>
#include <emscripten/html5_webgpu.h>

Not sure what is wrong.

P.S. The code is compilable in windows using dawn.

@Honya2000
Copy link
Author

I made the code compilable.
But it looks very hacky and not clean.

I had to use lot of ifdefs because emscripten webgpu headers are quite outdated.

Device limits, features, pipeline creation, textures uploading / copying... This is just part of API which is not compatible in latest emscripten and latest dawn headers.

@kainino0x
Copy link
Collaborator

kainino0x commented May 5, 2025

MediaPipe uses emdawnwebgpu, a newer fork of the bindings, not the bindings that are built into Emscripten (the ones you get if you use -sUSE_WEBGPU=1). Apologies you ran into this before we put out the deprecation warning, it was unfortunate timing.
emdawnwebgpu releases can be found here (instructions in the zip): https://github.com/google/dawn/releases
and the issue about the built-in bindings is #23432.

@kainino0x
Copy link
Collaborator

If there is MediaPipe build documentation or build files you were using that did the wrong thing, can you file a bug with MediaPipe and @ me on it?

@Honya2000
Copy link
Author

i'm using custom build system using cmake.
But the issue is not related to custom settings. As i mentioned i included proper webgpu headers.

Will try to use emdawnwebgpu. Thank you for the help.

@Honya2000
Copy link
Author

Unfortunately i coudn't make emdawn port working.
A soon as i add this line in cmake:
--use-port=c:/Projects/emsdk/emdawn/emdawnwebgpu.port.py
for both compiler and linker - cmake generator completely stops working, throwing errors on any cpp test step, like:

-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Failed
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20 - Failed

@kainino0x
Copy link
Collaborator

That might be https://crbug.com/415850603
I completely forgot to test on Windows. Please star that bug to subscribe to updates.

@kainino0x
Copy link
Collaborator

Never mind, that's not it, this is a different issue. It may be because MediaPipe hasn't been tested with --use-port because its own build files set the flags explicitly instead. Could you please file a MediaPipe bug with repro instructions and cc me?

@Honya2000
Copy link
Author

It's not related to mediapipe build system. As i mentioned i'm using custom build system with lot of projects. And mediapipe is one of them.
But my cmake is fine, it is working properly on any platform (android, macos, ios, wasm, windows, linux) until i add this line to CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS:
--use-port=c:/Projects/emsdk/emdawn/emdawnwebgpu.port.py

With this line added cmake just failing to compile any c++ test code. And throwing fatal error at the beginning of setup (abseil-cpp project).

P.S. tried latest port version from 7th of Mai - the same errors.

@Honya2000
Copy link
Author

Probably the issue in emscripten cmake tools (like Emscripten.cmake).
Because with cmake i cannot access emcc directly, and use emsscripten cmake toolchain to generate ninja project.

@Honya2000
Copy link
Author

I analyzed cmake error logs and found this line:

      File "C:\\Projects\\emsdk\\upstream\\emscripten\\tools\\link.py", line 1879, in phase_calculate_system_libraries
        extra_files_to_link += ports.get_libs(settings)
      File "C:\\Projects\\emsdk\\upstream\\emscripten\\tools\\ports\\__init__.py", line 559, in get_libs
        port.linker_setup(Ports, settings)
      File "c:/Projects/emsdk/emdawn/emdawnwebgpu.port.py", line 146, in linker_setup\x0d
        raise Exception('emdawnwebgpu may not be used with -sUSE_WEBGPU=1')\x0d
    Exception: emdawnwebgpu may not be used with -sUSE_WEBGPU=1\x0d
    ninja: build stopped: subcommand failed.

So i removed -s USE_WEBGPU and abseil cmake setup succeed, but it failed in another place:

-- Cross-compiling to test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX -- failed to compile
-- Cross-compiling to test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Cross-compiling to test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
CMake Error at third_party/benchmark/CMakeLists.txt:316 (message):
Failed to determine the source files for the regular expression backend

And it looks like beanchmark project is failing any check step.

Will investigate the logs...

@Honya2000
Copy link
Author

Ok, i had to remove port line from linker cmake flags (CMAKE_EXE_LINKER_FLAGS), otherwise it complains:

    em++: error: port path [`c:/Projects/emsdk/emdawn/emdawnwebgpu.port.py`] is invalid: duplicate port name `emdawnwebgpu.port`\x0d
    ninja: build stopped: subcommand failed.

Now cmake is succesfully generated ninja project. Hope it will be linkable in the end of compilation...

@kainino0x
Copy link
Collaborator

Glad you've solved the issues so far! Please feel free to post again here or file a Dawn bug if you encounter more issues. It's useful to have these errors written down somewhere so search engines pick them up for people who have issues in the future.

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

2 participants