Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions .github/workflows/build-dawn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,39 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6.0.2

- name: Determine Dawn branch metadata
- name: Determine Dawn version metadata
id: dawn_meta
run: |
set -eo pipefail
branch=$(git config -f .gitmodules submodule.externals/dawn.branch)
if [ -z "$branch" ]; then
echo "Could not determine Dawn branch from .gitmodules" >&2
version=$(node -p "require('./packages/webgpu/package.json').dawn")
commit=$(node -p "require('./packages/webgpu/package.json').dawnCommit")
if [ -z "$version" ] || [ "$version" = "undefined" ]; then
echo "Could not determine Dawn version from package.json ('dawn' field)" >&2
exit 1
fi
slug=${branch//\//-}
echo "branch=$branch" >> "$GITHUB_OUTPUT"
if [ -z "$commit" ] || [ "$commit" = "undefined" ]; then
echo "Could not determine Dawn commit from package.json ('dawnCommit' field)" >&2
exit 1
fi
gitlink=$(git ls-tree HEAD externals/dawn | awk '{print $3}')
if [ "$gitlink" != "$commit" ]; then
echo "Submodule gitlink ($gitlink) does not match package.json dawnCommit ($commit)." >&2
echo "Update the externals/dawn submodule and the dawnCommit field together." >&2
exit 1
fi
slug=${version//\//-}
echo "branch=$version" >> "$GITHUB_OUTPUT"
echo "branch_slug=$slug" >> "$GITHUB_OUTPUT"

- name: Compute release metadata
id: release_meta
run: |
tag="dawn-${DAWN_BRANCH_SLUG}"
tag="dawn-${DAWN_VERSION_SLUG}"
echo "tag_name=$tag" >> "$GITHUB_OUTPUT"
echo "release_name=Dawn ${DAWN_BRANCH}" >> "$GITHUB_OUTPUT"
echo "release_name=Dawn ${DAWN_VERSION}" >> "$GITHUB_OUTPUT"
env:
DAWN_BRANCH: ${{ steps.dawn_meta.outputs.branch }}
DAWN_BRANCH_SLUG: ${{ steps.dawn_meta.outputs.branch_slug }}
DAWN_VERSION: ${{ steps.dawn_meta.outputs.branch }}
DAWN_VERSION_SLUG: ${{ steps.dawn_meta.outputs.branch_slug }}

- name: Create GitHub release
id: create_release
Expand All @@ -49,7 +60,7 @@ jobs:
with:
tag_name: ${{ steps.release_meta.outputs.tag_name }}
name: ${{ steps.release_meta.outputs.release_name }}
body: "Dawn prebuilt binaries for version ${{ steps.dawn_meta.outputs.branch }}"
body: "Dawn prebuilt binaries for ${{ steps.dawn_meta.outputs.branch }} (Dawn commit pinned in package.json dawnCommit)"
draft: false
prerelease: true
generate_release_notes: false
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "externals/dawn"]
path = externals/dawn
url = https://dawn.googlesource.com/dawn
branch = chromium/7849
branch = main
2 changes: 1 addition & 1 deletion externals/dawn
Submodule dawn updated from cbfe41 to 63f25f
25 changes: 14 additions & 11 deletions packages/webgpu/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,31 @@ The Expo config plugin lives in `plugin/src` and is compiled to `plugin/build` b

## Upgrading Dawn

The Dawn version is pinned in two places that must stay in sync:
The Dawn version tracks the one shipped by `@shopify/react-native-skia` Graphite builds: the pin is the exact Dawn commit from the Skia milestone's DEPS file (`third_party/externals/dawn` in Skia's DEPS). It is recorded in two places that must stay in sync:

- `.gitmodules` → `submodule.externals/dawn.branch` (e.g. `chromium/7849`)
- `packages/webgpu/package.json` → the `"dawn"` field (same value, e.g. `chromium/7849`)
- the `externals/dawn` submodule gitlink (the commit the submodule points at)
- `packages/webgpu/package.json` → `"dawn"` (a human-readable label, e.g. `chrome-m150`; Skia milestones mirror Chrome milestones) and `"dawnCommit"` (the exact commit hash)

`yarn install-dawn` downloads **prebuilt** binaries from a GitHub release tagged `dawn-<branch-slug>` (e.g. `dawn-chromium-7849`); the release host is configured at the top of `scripts/install-dawn.ts`. `yarn build-dawn` builds the same binaries from the submodule source instead.
The **Build Dawn** workflow verifies the gitlink matches `dawnCommit` and fails otherwise.

Steps to bump to a new Dawn version (`chromium/<N>`):
`yarn install-dawn` downloads **prebuilt** binaries from a GitHub release on this repo tagged `dawn-<version-slug>` (e.g. `dawn-chrome-m150`). `yarn build-dawn` builds the same binaries from the submodule source instead.

1. **Point the submodule at the new branch.** Update both `.gitmodules` and the `"dawn"` field in `package.json` to `chromium/<N>`, then move the submodule to the new tip:
Steps to bump to a new Dawn version (new Skia milestone `m<N>`):

1. **Find the Dawn commit** in the Skia milestone's `DEPS` file (`third_party/externals/dawn` entry).

2. **Point the submodule at that commit** and update `package.json` (`"dawn": "chrome-m<N>"`, `"dawnCommit": "<hash>"`):

```sh
git submodule set-branch --branch chromium/<N> externals/dawn
git submodule update --remote externals/dawn
cd externals/dawn && git fetch origin && git checkout <hash> && cd ../..
```

2. **Publish prebuilt binaries.** Trigger the **Build Dawn** workflow (`.github/workflows/build-dawn.yml`, `workflow_dispatch`). It reads the branch from `.gitmodules`, builds Android + Apple, and creates the `dawn-chromium-<N>` release with the headers, the Android `.so`s, and the Apple `.xcframework`. (To build locally instead, run `yarn build-dawn`; this requires the Android NDK and Xcode toolchains.)
3. **Publish prebuilt binaries.** Trigger the **Build Dawn** workflow (`.github/workflows/build-dawn.yml`, `workflow_dispatch`). It builds Android + Apple from the submodule and creates the `dawn-chrome-m<N>` release with the headers, the Android `.so`s, and the Apple `.xcframework`. (To build locally instead, run `yarn build-dawn`; this requires the Android NDK and Xcode toolchains.)

3. **Pull the new binaries** once the release exists:
4. **Pull the new binaries** once the release exists:

```sh
cd packages/webgpu && yarn install-dawn
```

4. **Verify and commit.** Build and run the example app, then commit the submodule bump together with the updated `.gitmodules` and `package.json`.
5. **Verify and commit.** Build and run the example app, then commit the submodule bump together with the updated `package.json`.
3 changes: 2 additions & 1 deletion packages/webgpu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"app.plugin.js",
"plugin/build/**"
],
"dawn": "chromium/7849",
"dawn": "chrome-m150",
"dawnCommit": "63f25feec51e9351fb25222b6d5de1af791d7c4f",
"scripts": {
"test": "NODE_OPTIONS='--experimental-require-module' jest -i",
"test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",
Expand Down
4 changes: 2 additions & 2 deletions packages/webgpu/scripts/install-dawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if (!dawnVersion) {
}

// Parse the dawn version to construct the release tag
// Format: "chromium/7472" -> "dawn-chromium-7472"
// Format: "chrome-m150" -> "dawn-chrome-m150"
const releaseTag = `dawn-${dawnVersion.replace("/", "-")}`;
const releaseUrl = `https://github.com/wcandillon/react-native-webgpu/releases/tag/${releaseTag}`;

Expand Down Expand Up @@ -171,7 +171,7 @@ const assetNames: { [key: string]: string } = {
};

for (const [index, asset] of assets.entries()) {
const assetUrl = `https://github.com/Shopify/react-native-skia/releases/download/${releaseTag}/${asset.name}`;
const assetUrl = `https://github.com/wcandillon/react-native-webgpu/releases/download/${releaseTag}/${asset.name}`;
const tarPath = join(libsDir, asset.name);
const displayName = assetNames[asset.name] || asset.name;

Expand Down
Loading