kleisauke / wasm-vips

libvips for the browser and Node.js, compiled to WebAssembly with Emscripten.
https://kleisauke.github.io/wasm-vips/
MIT License
463 stars 25 forks source link

SIMD support is musted? #33

Open hurryhuang1007 opened 1 year ago

hurryhuang1007 commented 1 year ago

This repo is awesome! At this stage it looks like simd support is necessary, is it possible to build no simd version for lower version browsers (those that don't support simd)?

kleisauke commented 1 year ago

Hello, the pre-built binaries currently requires an engine that supports Wasm SIMD. However, you can still build binaries without this feature, by passing the --disable-simd build parameter.

Assuming you have Docker installed (or another OCI-compliant container runtime, such as Podman) and using a Unix-like environment (otherwise $(pwd) does not work), you can use the build command available in package.json. https://github.com/kleisauke/wasm-vips/blob/9f6cc94a2a2d116cc6c75aaedc7f57793d74eb00/package.json#L40

For example:

$ npm run build -- --disable-simd

There's a possibility that I can provide pre-built binaries that does not use SIMD as a fallback (e.g., for compatibility with Safari, which at the time of writing does not support that). However, I don't know if that makes sense, given that Wasm SIMD is standardized, and is likely to become a mandatory feature in Wasm 2.0.

FWIW, I'm also planning to make use of the standardized reference types feature, which is enabled by default on V8-based engines after commit https://github.com/v8/v8/commit/c96864e0181eefeaecba12340296e3f085fcfa24 (corresponds to V8 9.6, Chrome 96, Node.js 17.2.0 and Deno 1.16.0). It's a bit too early to enable that and should happen after Node 16.x reaches EOL. Fortunately, this feature is supported by Safari and should already be safe to enable on Firefox (supported since version 79, so that doesn't require increasing the minimum version).

hurryhuang1007 commented 1 year ago

Thx for your reply. I will try to build the no simd version according to the method you said.

In my region, for some reason, chrome is not popular, replaced by various custom browsers based on chromium. And these browsers don't seem to care about updating the chromium version, so we have a large number of users using outdated browsers (nearly 80% of people use the chrome86 kernel version of the browser). That's why I need the no simd version.

atjn commented 1 year ago

FYI it seems likely that Safari will support SIMD in version 16.3 sometime in February/March. At that stage, all engines support the feature 🥳