# Skia Graphite + Emscripten 4.x WebGPU Compatibility Issues
## Environment
- Skia: main branch (commit 487a994)
- Emscripten: 4.0.7 (bundled with Skia)
- Build config: `skia_enable_graphite=true`, `skia_use_dawn=true`, `skia_use_webgpu=true` for WASM target
## Problem Summary
When building Skia with Graphite for WASM, there are multiple WebGPU API mismatches between Skia's Dawn-based Graphite code and Emscripten's `webgpu.h` headers. The APIs have diverged as the WebGPU spec stabilized.
## Issue 1: Dawn/Tint CMake build missing `tint::Bindings` type
When Dawn builds for WASM via CMake, it disables all backend writers:
```
-DTINT_BUILD_SPV_WRITER=0
-DTINT_BUILD_MSL_WRITER=0
-DTINT_BUILD_HLSL_WRITER=0
-DTINT_BUILD_GLSL_WRITER=0
```
But `tint::Bindings` and `tint::ExternalTexture` (defined in `src/tint/api/common/bindings.h`) are only included via backend writer headers. Dawn native code (`TintUtils.h`) expects these types but they're not available.
**Fix**: Add `#include "src/tint/api/common/bindings.h"` to `include/tint/tint.h`
## Issue 2: WebGPU type renames
Skia's Graphite code uses old WebGPU type names that don't exist in Emscripten 4.x:
| Skia expects | Emscripten 4.x has |
|--------------|-------------------|
| `wgpu::ImageCopyBuffer` | `wgpu::TexelCopyBufferInfo` |
| `wgpu::ImageCopyTexture` | `wgpu::TexelCopyTextureInfo` |
| `wgpu::ShaderModuleWGSLDescriptor` | `wgpu::ShaderSourceWGSL` |
| `wgpu::RenderPassTimestampWrites` | `wgpu::PassTimestampWrites` |
| `wgpu::ComputePassTimestampWrites` | `wgpu::PassTimestampWrites` |
| `wgpu::VertexStepMode::VertexBufferNotUsed` | (removed) |
## Issue 3: Inverted `#ifdef` logic
In `DawnGraphiteUtils.cpp` and `DawnResourceProvider.cpp`, the compatibility code is backwards:
```cpp
#if defined(__EMSCRIPTEN__)
wgpu::ShaderModuleWGSLDescriptor wgslDesc; // OLD name - doesn't exist in Emscripten 4.x!
#else
wgpu::ShaderSourceWGSL wgslDesc; // NEW name
#endif
```
Emscripten 4.x uses the NEW names, not the old ones.
## Issue 4: `OnSubmittedWorkDone` API change
Old API (what Skia uses):
```cpp
queue.OnSubmittedWorkDone(callback, userdata);
```
New API (Emscripten 4.x):
```cpp
queue.OnSubmittedWorkDone(CallbackMode, callback, userdata);
```
## Files affected
- `src/gpu/graphite/dawn/DawnCommandBuffer.cpp`
- `src/gpu/graphite/dawn/DawnGraphiteUtils.cpp`
- `src/gpu/graphite/dawn/DawnResourceProvider.cpp`
- `src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp`
- `src/gpu/graphite/dawn/DawnQueueManager.cpp`
- `third_party/externals/dawn/include/tint/tint.h`
## Reproduction
```bash
# In Skia repo with Emscripten 4.0.7
gn gen out/wasm --args='target_os="wasm" skia_enable_graphite=true skia_use_dawn=true skia_use_webgpu=true skia_enable_ganesh=false'
ninja -C out/wasm
```
## Notes
- CanvasKit currently uses Ganesh, not Graphite, for WASM
- The Emscripten WebGPU headers follow the finalized WebGPU spec
- Dawn's native headers may still use older names for compatibility