Skip to content

Commit 7a659b6

Browse files
authored
[webgpu] polyfill device.AdapterInfo for Safari v26.0 (#26488)
### Description polyfill `device.AdapterInfo` for Safari v26.0 ### Motivation and Context Fixes #26480
1 parent b6122c6 commit 7a659b6

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

cmake/external/onnxruntime_external_deps.cmake

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,18 @@ if (onnxruntime_USE_WEBGPU)
751751
# Some build warnings are not allowed to be disabled in project level.
752752
${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/dawn/dawn_binskim.patch &&
753753

754-
# Android devices doesn't seem to allow fp16 in uniforms so the WebGPU EP has to manually handle passing an fp32
755-
# in the uniform and converting to fp16 before using.
756-
${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/dawn/uniform_and_storage_buffer_16_bit_access.patch)
754+
# The uniform_and_storage_buffer_16_bit_access.patch contains the following changes:
755+
#
756+
# - (private) Android devices don't seem to allow fp16 in uniforms so the WebGPU EP has to manually handle passing an fp32
757+
# in the uniform and converting to fp16 before using.
758+
${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/dawn/uniform_and_storage_buffer_16_bit_access.patch &&
759+
760+
# The safari_polyfill.patch contains the following changes:
761+
#
762+
# - (private) Fix compatibility issues with Safari. Contains the following changes:
763+
# - Polyfill for `device.AdapterInfo` (returns `undefined` in Safari v26.0)
764+
#
765+
${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/dawn/safari_polyfill.patch)
757766

758767
onnxruntime_fetchcontent_declare(
759768
dawn
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js b/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
2+
index a3ce6dc732..7119eae424 100644
3+
--- a/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
4+
+++ b/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
5+
@@ -903,6 +903,12 @@ var LibraryWebGPU = {
6+
stackRestore(sp);
7+
};
8+
9+
+ // Polyfill `device.AdapterInfo` if not present (Safari v26.0).
10+
+ // See https://bugs.webkit.org/show_bug.cgi?id=301878
11+
+ if (!('adapterInfo' in device)) {
12+
+ device.adapterInfo = adapter.info;
13+
+ }
14+
+
15+
_emwgpuOnRequestDeviceCompleted(futureId, {{{ gpu.RequestDeviceStatus.Success }}},
16+
{{{ gpu.passAsPointer('devicePtr') }}}, {{{ gpu.NULLPTR }}});
17+
}, (ex) => {

0 commit comments

Comments
 (0)