Skip to content

Commit 489604f

Browse files
committed
chore(🤖): emulator experiment for Dawn host-visible memory mapping
Throwaway workflow on this branch only: builds the x86_64 APK once, then boots API 34, API 35, API 30 on the canary emulator, and API 30 with -feature -GLDirectMem, probing each with the ABuffer demo before the full suite. Not meant to be merged.
1 parent bf01560 commit 489604f

1 file changed

Lines changed: 214 additions & 0 deletions

File tree

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# Throwaway experiment: which emulator configuration lets Dawn map host-visible
2+
# memory on a GitHub-hosted runner? On the API 30 default x86_64 image with the
3+
# stable emulator (37.2.12) the guest Vulkan driver fails to mmap its 16 MB
4+
# host-visible block (goldfish-address-space errno 1) and the app SIGSEGVs on
5+
# the first mappedAtCreation buffer. Build the x86_64 APK once, then boot each
6+
# variant and probe with the ABuffer demo (its first eval creates such a
7+
# buffer) before spending time on the whole suite.
8+
name: Android emulator experiment
9+
on:
10+
push:
11+
branches:
12+
- android-emulator-experiment
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: android-emulator-experiment-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build-apk:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 45
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Free disk space
28+
uses: jlumbroso/free-disk-space@ceedf095f4ec1a097402bc6bd80831f2e1a6fde6 # v2.0.0
29+
with:
30+
tool-cache: false
31+
android: false
32+
dotnet: true
33+
haskell: true
34+
large-packages: true
35+
docker-images: true
36+
swap-storage: false
37+
38+
- name: Setup
39+
uses: ./.github/actions/setup
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Install JDK
44+
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
45+
with:
46+
distribution: 'zulu'
47+
java-version: '17'
48+
49+
- name: Install NDK
50+
uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 # v1.5.0
51+
id: setup-ndk
52+
with:
53+
ndk-version: r27d
54+
55+
- name: Set ANDROID_NDK
56+
run: echo "ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}" >> "$GITHUB_ENV"
57+
58+
- name: Setup Android SDK
59+
uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
60+
with:
61+
packages: platform-tools
62+
63+
- name: Finalize Android SDK
64+
run: |
65+
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses > /dev/null
66+
echo "sdk.dir=$ANDROID_HOME" > apps/example/android/local.properties
67+
68+
- name: Cache Gradle
69+
uses: actions/cache@v4
70+
with:
71+
path: |
72+
~/.gradle/wrapper
73+
~/.gradle/caches
74+
key: ${{ runner.os }}-gradle-${{ hashFiles('apps/example/android/gradle/wrapper/gradle-wrapper.properties', 'yarn.lock') }}
75+
restore-keys: |
76+
${{ runner.os }}-gradle-
77+
78+
- name: Build example for Android
79+
working-directory: apps/example/android
80+
env:
81+
ORG_GRADLE_PROJECT_reactNativeArchitectures: x86_64
82+
run: ./gradlew assembleDebug --warning-mode all --stacktrace
83+
84+
- name: Upload APK
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: experiment-apk
88+
path: apps/example/android/app/build/outputs/apk/debug/app-debug.apk
89+
if-no-files-found: error
90+
91+
emulator:
92+
needs: build-apk
93+
runs-on: ubuntu-latest
94+
timeout-minutes: 45
95+
name: ${{ matrix.name }}
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
include:
100+
# Newer guest images talk to the host through virtio-gpu instead of
101+
# the goldfish address-space device that fails on API 30.
102+
- name: api34-default-stable
103+
api-level: 34
104+
target: default
105+
channel: stable
106+
extra-options: ""
107+
- name: api35-default-stable
108+
api-level: 35
109+
target: default
110+
channel: stable
111+
extra-options: ""
112+
# Same guest image as CI, newest emulator binary.
113+
- name: api30-default-canary
114+
api-level: 30
115+
target: default
116+
channel: canary
117+
extra-options: ""
118+
# Same guest image and emulator as CI, direct host memory mapping off.
119+
- name: api30-default-no-directmem
120+
api-level: 30
121+
target: default
122+
channel: stable
123+
extra-options: "-feature -GLDirectMem"
124+
steps:
125+
- name: Checkout
126+
uses: actions/checkout@v4
127+
128+
- name: Free disk space
129+
uses: jlumbroso/free-disk-space@ceedf095f4ec1a097402bc6bd80831f2e1a6fde6 # v2.0.0
130+
with:
131+
tool-cache: false
132+
android: false
133+
dotnet: true
134+
haskell: true
135+
large-packages: true
136+
docker-images: true
137+
swap-storage: false
138+
139+
- name: Setup
140+
uses: ./.github/actions/setup
141+
with:
142+
github_token: ${{ secrets.GITHUB_TOKEN }}
143+
144+
- name: Setup Android SDK
145+
uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4.0.4
146+
with:
147+
packages: platform-tools
148+
149+
- name: Enable KVM group perms
150+
run: |
151+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
152+
sudo udevadm control --reload-rules
153+
sudo udevadm trigger --name-match=kvm
154+
155+
- name: Download APK
156+
uses: actions/download-artifact@v4
157+
with:
158+
name: experiment-apk
159+
path: apps/example/android/app/build/outputs/apk/debug
160+
161+
- name: Start Package Manager
162+
working-directory: apps/example
163+
run: |
164+
CI=true yarn start &
165+
(sleep 10 && curl -sf --retry 12 --retry-connrefused --retry-delay 5 -o /dev/null "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false") &
166+
167+
# Probe first: ABuffer's first eval creates a mappedAtCreation buffer, so
168+
# it either passes in seconds or reproduces the crash within one eval
169+
# timeout. The full suite only runs once the probe passed.
170+
- name: Probe mapping, then run e2e tests
171+
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
172+
with:
173+
api-level: ${{ matrix.api-level }}
174+
target: ${{ matrix.target }}
175+
channel: ${{ matrix.channel }}
176+
arch: x86_64
177+
profile: Nexus 5X
178+
force-avd-creation: true
179+
emulator-options: -no-snapshot-save -no-window -gpu swangle_indirect -noaudio -no-boot-anim ${{ matrix.extra-options }}
180+
disable-animations: true
181+
script: |
182+
adb reverse tcp:8081 tcp:8081
183+
nohup adb logcat > logcat.txt 2>&1 &
184+
adb install -r apps/example/android/app/build/outputs/apk/debug/app-debug.apk
185+
adb shell monkey -p com.microsoft.reacttestapp 1
186+
cd packages/webgpu && yarn test -i ABuffer
187+
cd packages/webgpu && yarn test
188+
189+
- name: Summarize
190+
if: always()
191+
run: |
192+
{
193+
echo "## ${{ matrix.name }}"
194+
echo '```'
195+
grep -hoE "Android emulator version [^ ]+|system-images;[^ \"']+" "$RUNNER_TEMP"/*.log 2>/dev/null | sort -u || true
196+
grep -hE "goldfish-address-space: mmap|Fatal signal|host memory map failed" logcat.txt | head -5 || true
197+
echo '```'
198+
} >> "$GITHUB_STEP_SUMMARY"
199+
200+
- name: Upload logcat
201+
if: always()
202+
uses: actions/upload-artifact@v4
203+
with:
204+
name: logcat-${{ matrix.name }}
205+
path: logcat.txt
206+
if-no-files-found: ignore
207+
208+
- name: Upload test snapshots
209+
if: always()
210+
uses: actions/upload-artifact@v4
211+
with:
212+
name: snapshots-${{ matrix.name }}
213+
path: packages/webgpu/src/__tests__/snapshots/
214+
if-no-files-found: ignore

0 commit comments

Comments
 (0)