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
68 changes: 57 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,21 @@ jobs:
xcrun simctl shutdown "$IOS_SIMULATOR_UDID" || true
fi

# Decides whether build-spm-ios runs. That job only proves that
# Decides whether the SwiftPM and native macOS builds run. SwiftPM proves that
# packages/webgpu/Package.swift resolves and compiles, so a pull request
# pays for it only when its diff touches what can change the outcome: the
# manifest and the autolinking config, the Apple and C++ sources it
# compiles, the scripts behind the Dawn check, the dependencies that pin
# react-native-webgpu-dawn, the example that links it, or CI itself. Pushes
# to main, the merge queue and manual runs build unconditionally, so a
# change this list misses still shows up on main.
spm-changes:
# to main, the merge queue and manual runs always build SwiftPM. macOS builds
# on main, manual runs and relevant PRs; shared JavaScript is checked by
# bundle-macos on every PR.
changes:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
run: ${{ steps.diff.outputs.run }}
spm: ${{ steps.diff.outputs.spm }}
macos: ${{ steps.diff.outputs.macos }}
steps:
- name: Checkout
if: github.event_name == 'pull_request'
Expand All @@ -225,24 +227,68 @@ jobs:
BASE: ${{ github.event.pull_request.base.sha }}
run: |
if [ "$EVENT" != "pull_request" ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
echo "spm=true" >> "$GITHUB_OUTPUT"
echo "macos=true" >> "$GITHUB_OUTPUT"
exit 0
fi
git fetch --depth=1 origin "$BASE"
changed=$(git diff --name-only "$BASE" HEAD)
run=false
spm=false
macos=false
while IFS= read -r file; do
case "$file" in
packages/webgpu/Package.swift|packages/webgpu/package.json|packages/webgpu/react-native.config.js|\
packages/webgpu/apple/*|packages/webgpu/cpp/*|packages/webgpu/scripts/*|\
spm-example/*|package.json|yarn.lock|\
.github/workflows/ci.yml|.github/actions/setup/*)
echo "$file"
run=true
spm=true
;;
esac
case "$file" in
apps/example-macos/*|packages/webgpu/*.podspec|packages/webgpu/package.json|\
packages/webgpu/react-native.config.js|packages/webgpu/apple/*|packages/webgpu/cpp/*|\
packages/webgpu/scripts/*|package.json|yarn.lock|.yarn/patches/*|turbo.json|\
.github/workflows/ci.yml|.github/actions/setup/*)
echo "macos: $file"
macos=true
;;
esac
done <<< "$changed"
echo "run=$run" >> "$GITHUB_OUTPUT"
echo "spm=$spm" >> "$GITHUB_OUTPUT"
echo "macos=$macos" >> "$GITHUB_OUTPUT"

# Bundle shared sources on every PR without reserving a Mac. Native builds
# alone do not exercise Metro or the desktop Worklets/Babel configuration.
bundle-macos:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Bundle macOS example
run: yarn workspace example-macos bundle:macos

# Match Skia's macOS check: shared JS is bundled above; relevant native,
# dependency or runner changes also build the CocoaPods app on a hosted Mac.
build-test-macos:
needs: changes
if: needs.changes.outputs.macos == 'true' && (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main'))
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build macOS example
run: yarn turbo run build:macos --concurrency 1

# The SwiftPM example gets its own job on a GitHub-hosted Mac. It needs no
# Metro, simulator or CocoaPods, so nothing ties it to the self-hosted
Expand All @@ -251,8 +297,8 @@ jobs:
# It used to be a step of `build`: a hung xcodebuild there blocked the iOS
# e2e result and held the self-hosted runner, which has no slack for that.
build-spm-ios:
needs: spm-changes
if: needs.spm-changes.outputs.run == 'true'
needs: changes
if: needs.changes.outputs.spm == 'true'
runs-on: macos-latest
# Cold run: yarn install, Dawn download, RN artifacts, then one xcodebuild.
timeout-minutes: 25
Expand Down
75 changes: 0 additions & 75 deletions .yarn/patches/@react-navigation-stack-npm-6.4.1-52dad4e278.patch

This file was deleted.

56 changes: 56 additions & 0 deletions .yarn/patches/@react-navigation-stack-npm-7.6.0-012930f287.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/lib/module/views/Stack/Card.js b/lib/module/views/Stack/Card.js
index b51719f0a28301ea0fe69da565e573403c25ea70..9157ab58c8094849dc812e5740743988f48606bf 100644
--- a/lib/module/views/Stack/Card.js
+++ b/lib/module/views/Stack/Card.js
@@ -2,7 +2,7 @@

import Color from 'color';
import * as React from 'react';
-import { Animated, InteractionManager, Platform, StyleSheet, View } from 'react-native';
+import { Animated, Platform, StyleSheet, View } from 'react-native';
import { CardAnimationContext } from "../../utils/CardAnimationContext.js";
import { getDistanceForDirection } from "../../utils/getDistanceForDirection.js";
import { getInvertedMultiplier } from "../../utils/getInvertedMultiplier.js";
@@ -178,12 +178,12 @@ export class Card extends React.Component {
};
handleStartInteraction = () => {
if (this.interactionHandle === undefined) {
- this.interactionHandle = InteractionManager.createInteractionHandle();
+ // InteractionManager was removed in React Native 0.88 and throws on access.
+ this.interactionHandle = 0;
}
};
handleEndInteraction = () => {
if (this.interactionHandle !== undefined) {
- InteractionManager.clearInteractionHandle(this.interactionHandle);
this.interactionHandle = undefined;
}
};
diff --git a/src/views/Stack/Card.tsx b/src/views/Stack/Card.tsx
index a90c6bca599ca9fa5808d9eaf1ee4c60e123df25..e1ed202fa3a332bd0c4eaea1bd2e10069984602f 100755
--- a/src/views/Stack/Card.tsx
+++ b/src/views/Stack/Card.tsx
@@ -3,7 +3,6 @@ import Color from 'color';
import * as React from 'react';
import {
Animated,
- InteractionManager,
Platform,
type StyleProp,
StyleSheet,
@@ -283,13 +282,13 @@ export class Card extends React.Component<Props> {

private handleStartInteraction = () => {
if (this.interactionHandle === undefined) {
- this.interactionHandle = InteractionManager.createInteractionHandle();
+ // InteractionManager was removed in React Native 0.88 and throws on access.
+ this.interactionHandle = 0;
}
};

private handleEndInteraction = () => {
if (this.interactionHandle !== undefined) {
- InteractionManager.clearInteractionHandle(this.interactionHandle);
this.interactionHandle = undefined;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
diff --git a/scripts/codegen/generate-artifacts-executor/index.js b/scripts/codegen/generate-artifacts-executor/index.js
index ec7ad6028727f0932c50b9b3be05317398d9fc2d..ba5777efd2acb3f23597a916857b1dc6937dfdf0 100644
--- a/scripts/codegen/generate-artifacts-executor/index.js
+++ b/scripts/codegen/generate-artifacts-executor/index.js
@@ -27,7 +27,10 @@ const {
generateRCTThirdPartyComponents,
} = require('./generateRCTThirdPartyComponents');
const {generateReactCodegenPodspec} = require('./generateReactCodegenPodspec');
-const {generateSchemaInfos} = require('./generateSchemaInfos');
+const {
+ extractSupportedApplePlatforms,
+ generateSchemaInfos,
+} = require('./generateSchemaInfos');
const {
generateUnstableModulesRequiringMainQueueSetupProvider,
} = require('./generateUnstableModulesRequiringMainQueueSetupProvider');
@@ -119,9 +122,26 @@ function execute(
reactNativeConfig,
platform,
);
- const libraries = codegenEnabledLibraries.filter(
- ({name}) => !disabledLibraries.includes(name),
- );
+ const libraries = codegenEnabledLibraries.filter(({name, libraryPath}) => {
+ if (disabledLibraries.includes(name)) {
+ return false;
+ }
+ if (platform !== 'ios') {
+ return true;
+ }
+ // Only macOS apps use react-native-macos here: skip the libraries
+ // whose podspec declares Apple platforms but not macOS. Their pods
+ // aren't installed, and their specs may need a newer codegen.
+ const applePlatforms = extractSupportedApplePlatforms(
+ name,
+ libraryPath,
+ );
+ return (
+ applePlatforms == null ||
+ applePlatforms.macos ||
+ !Object.values(applePlatforms).some(Boolean)
+ );
+ });

const outputPath = computeOutputPath(
projectRoot,
diff --git a/scripts/codegen/generate-artifacts-executor/utils.js b/scripts/codegen/generate-artifacts-executor/utils.js
index 7aefca2f12f8358a22c2ed5f64a585dec778c431..973e3f40b20578a30ce374cc83e9fd94906f2772 100644
--- a/scripts/codegen/generate-artifacts-executor/utils.js
+++ b/scripts/codegen/generate-artifacts-executor/utils.js
@@ -241,6 +241,12 @@ function findExternalLibraries(
);
// Handle third-party libraries
return Object.keys(dependencies).flatMap(dependency => {
+ // Core specs come from react-native-macos. Skip the react-native peer
+ // dependency so fresh discovery does not collect FBReactNativeSpec twice
+ // or merge mobile-only core metadata into the macOS providers.
+ if (dependency === 'react-native' && REACT_NATIVE !== 'react-native') {
+ return [];
+ }
let configFilePath = '';
try {
configFilePath = require.resolve(path.join(dependency, 'package.json'), {
diff --git a/Libraries/Network/RCTFileRequestHandler.mm b/Libraries/Network/RCTFileRequestHandler.mm
--- a/Libraries/Network/RCTFileRequestHandler.mm
+++ b/Libraries/Network/RCTFileRequestHandler.mm
@@ -41,7 +41,9 @@ RCT_EXPORT_MODULE()

- (BOOL)canHandleRequest:(NSURLRequest *)request
{
- return [request.URL.scheme caseInsensitiveCompare:@"file"] == NSOrderedSame && !RCTIsBundleAssetURL(request.URL);
+ // Bridgeless networking does not register RCTImageLoader as a request handler.
+ // Read bundled PNG/JPEG files as bytes too, so fetch(asset.uri) can resolve.
+ return [request.URL.scheme caseInsensitiveCompare:@"file"] == NSOrderedSame;
}

- (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequestDelegate>)delegate
10 changes: 10 additions & 0 deletions apps/example-macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Generated project, pods and bundles.
*.xcworkspace/
.xcode.env
Pods/
ReactTestApp-Resources.podspec.json
build/
node_modules/
!dist/
dist/*
!dist/.gitignore
43 changes: 43 additions & 0 deletions apps/example-macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# macOS example

The runner reuses `../example/src/App.tsx` and the shared gallery. Its RN macOS
0.83 dependencies stay separate from the mobile RN 0.88 app. React 19.2,
Reanimated 4.6 and Worklets 0.12 match the desktop renderer; Metro and Babel
resolve shared imports to that same dependency graph.

## Build and run

From the repository root:

```sh
yarn install
yarn workspace example-macos bundle:macos
yarn workspace example-macos pod:install:macos
yarn workspace example-macos build:macos
```

The app targets macOS 14. Dawn comes from `react-native-webgpu-dawn`; nothing
is built from Dawn sources. For development, run these in separate terminals:

```sh
yarn workspace example-macos start
yarn workspace example-macos macos
```

The shared gallery already uses a JavaScript navigation stack. Screens stays on
4.19 for its desktop View fallback. The camera integration remains mobile-only;
its native Nitro dependencies are not installed in this workspace. Gallery rows
use React Native's `TouchableOpacity`, matching Skia's example. Gesture Handler
buttons stopped accepting mouse clicks after returning from a demo on macOS;
white rows also set black text so dark appearance cannot hide their labels.

The RN macOS patch keeps Codegen on the desktop native modules and lets its
file request handler read bundled images. Without the latter, bridgeless
`fetch(asset.uri)` has no handler for PNG/JPEG assets, leaving the gallery
waiting for its textures.

## CI

Every PR bundles the macOS gallery on Linux. Changes to the desktop runner,
native sources or dependency configuration also build the macOS app on a hosted
Mac, matching Skia's platform-specific CI checks.
18 changes: 18 additions & 0 deletions apps/example-macos/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Example",
"displayName": "WebGPU macOS Example",
"singleApp": "example-app",
"components": [
{
"appKey": "Example",
"displayName": "Example",
"slug": "example-app"
}
],
"resources": {
"macos": ["dist/assets", "dist/main.macos.jsbundle"]
},
"macos": {
"metalAPIValidation": false
}
}
Loading
Loading