Skip to content

feat: add native Dawn debug toggle configuration & Expo Config Plugin#1

Draft
halby24 wants to merge 5 commits intomainfrom
feat/dawn-toggles
Draft

feat: add native Dawn debug toggle configuration & Expo Config Plugin#1
halby24 wants to merge 5 commits intomainfrom
feat/dawn-toggles

Conversation

@halby24
Copy link
Owner

@halby24 halby24 commented Mar 8, 2026

Summary

  • Dawn debug toggles (enableToggles / disableToggles) をネイティブ初期化パスへ移動
  • Android: AndroidManifest.xml<meta-data> エントリで設定
  • iOS: Info.plist のキーで設定
  • Expo managed/bare workflow 向け Config Plugin を追加(app.jsonplugins フィールドから設定可能)

Changes

Native (Android / iOS)

  • RNWebGPUManager に enable/disable toggle リストをプラグイン
  • Android: com.webgpu.enable_toggles / com.webgpu.disable_toggles meta-data を読み取り(カンマ区切り、空エントリは無視)
  • iOS: RNWebGPUEnableToggles / RNWebGPUDisableToggles Info.plist キーを読み取り
  • Dawn instance 生成時およびアダプタリクエスト時にトグルチェーンを適用

Expo Config Plugin

  • packages/webgpu/plugin/src/app.plugin.ts 追加
  • yarn workspace react-native-wgpu build:pluginapp.plugin.js を生成
  • package.jsonexpo.plugin フィールドと build:plugin スクリプトを追加

Usage

RN CLI (manual)

iOS – Info.plist:

<key>RNWebGPUEnableToggles</key>
<array>
  <string>allow_unsafe_apis</string>
</array>
<key>RNWebGPUDisableToggles</key>
<array>
  <string>disallow_spirv</string>
</array>

Android – AndroidManifest.xml:

<meta-data android:name="com.webgpu.enable_toggles" android:value="allow_unsafe_apis" />
<meta-data android:name="com.webgpu.disable_toggles" android:value="disallow_spirv" />

Expo (app.json)

{
  "expo": {
    "plugins": [
      ["react-native-wgpu", {
        "enableToggles": ["allow_unsafe_apis"],
        "disableToggles": ["disallow_spirv"]
      }]
    ]
  }
}

Notes

  • JS 側の requestDevice() / installWebGPU() トグル API は廃止し、ネイティブ設定に一本化
  • トグルは WebGPU 初期化前に確定するため、ランタイムでの変更は不可

Test plan

  • yarn --cwd packages/webgpu tsc
  • yarn workspace react-native-wgpu build:pluginapp.plugin.js が生成されること
  • iOS: Info.plist からトグルが読み取られること
  • Android: AndroidManifest.xml からトグルが読み取られること
  • Expo: npx expo prebuild 後にネイティブファイルへの挿入を確認
  • dump_shaders など観測可能なトグルで動作確認

@halby24 halby24 force-pushed the feat/dawn-toggles branch from d04cfae to ee70196 Compare March 8, 2026 07:57
halby24 and others added 2 commits March 8, 2026 16:59
Allow enabling/disabling Dawn debug toggles (e.g. dump_shaders,
use_user_defined_labels_in_backend) from JS via requestDevice().
Added as a non-standard extension field to GPUDeviceDescriptor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add dawnToggles option tests to Device.spec.ts
  (covers enable/disable/both/empty cases)
- Fix Dawn API naming in GPUAdapter.cpp:
  enabledTogglesCount → enabledToggleCount
  disabledTogglesCount → disabledToggleCount

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@halby24 halby24 force-pushed the feat/dawn-toggles branch from ee70196 to 1a06e19 Compare March 8, 2026 07:59
…tions

Dawn toggles are now specified at the Instance level via installWebGPU(),
matching node-webgpu's create() design. This avoids polluting the standard
GPUDeviceDescriptor type with a non-standard Dawn-specific field.

- Add RNWebGPUInstallOptions / DawnTogglesDescriptor types (exported)
- Export installWebGPU(options?) from the package entry point
- Remove declare global extension of GPUDeviceDescriptor
- Remove GPUDawnTogglesDescriptor.h and dawnToggles from GPUDeviceDescriptor
- Pass toggles through install() → RNWebGPUManager → GPU constructor
- Apply DawnTogglesDescriptor to both CreateInstance and RequestAdapter
- Remove dawnToggles handling from GPUAdapter::requestDevice()
- Update iOS/Android native install() to accept and parse options
- Web entry point exports a no-op installWebGPU() that ignores toggles

BREAKING CHANGE: requestDevice({ dawnToggles }) is no longer supported.
Use installWebGPU({ dawnToggles }) instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@halby24 halby24 changed the title feat: expose Dawn debug toggles via requestDevice() dawnToggles option refactor: move dawnToggles from requestDevice() to installWebGPU() options Mar 8, 2026
@halby24 halby24 changed the title refactor: move dawnToggles from requestDevice() to installWebGPU() options feat: expose Dawn debug toggles via installWebGPU() options Mar 8, 2026
@halby24 halby24 changed the title feat: expose Dawn debug toggles via installWebGPU() options refactor: move Dawn debug toggles to native config Mar 9, 2026
@halby24 halby24 changed the title refactor: move Dawn debug toggles to native config feat: add native Dawn debug toggle configuration Mar 9, 2026
Expo managed/bare workflow ユーザーが app.json の plugins フィールドから
enableToggles / disableToggles を設定できる Config Plugin を追加。
plugin/src/app.plugin.ts → app.plugin.js にコンパイルして配布。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@halby24 halby24 changed the title feat: add native Dawn debug toggle configuration feat: add native Dawn debug toggle configuration & Expo Config Plugin Mar 10, 2026
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

Successfully merging this pull request may close these issues.

1 participant