Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incredibly slow load times #85

Closed
not-nullptr opened this issue Nov 12, 2024 · 7 comments
Closed

incredibly slow load times #85

not-nullptr opened this issue Nov 12, 2024 · 7 comments

Comments

@not-nullptr
Copy link

hello! i'm loading wasm-vips in a web worker and using postMessage to do some file conversions. it sends a message when the Vips promise (ie what's returned from the default export function) is resolved, but this can take upwards of 15 to 20 seconds. the file is cached so no idea why its taking so long? very happy to do any troubleshooting if this is unintended

@kleisauke
Copy link
Owner

An initialization time of ~20 seconds seems unusual. Which browser was this tested on? Does disabling the dynamic modules help?:

const vips = await Vips({
  // Optimize startup time by disabling the dynamic modules
  dynamicLibraries: []
});

@not-nullptr
Copy link
Author

not-nullptr commented Nov 12, 2024

tested on firefox -- this seems to fix it, load times are now instant. thanks! (not closing this for now because 20 seconds seems like an awfully long time with dynamic modules?)

@kleisauke
Copy link
Owner

On my 8-year-old(!) laptop, initialization takes about 3 seconds in Firefox when I visit:
https://wasm-vips.kleisauke.nl/playground/?modules=jxl-heif

Do you see a successful load for vips-jxl.wasm and vips-heif.wasm in the network tab? If not, it could suggest a bundler issue.

@kleisauke
Copy link
Owner

@not-nullptr Were you able to make any progress with this?

@not-nullptr
Copy link
Author

i did make a new discovery -- memory usage is around ~1.3gb with dynamic modules disabled. that's about it though

@kleisauke
Copy link
Owner

Memory usage is expected to be around ~1GiB. See for example the following references:

# note 1: `ALLOW_MEMORY_GROWTH` may run non-wasm code slowly. See: https://github.com/WebAssembly/design/issues/1271.
# note 2: Browsers appear to limit the maximum initial memory size to 1GB, set `INITIAL_MEMORY` accordingly.

-sINITIAL_MEMORY=1GB

The changeset at master...allow-memory-growth may address this issue. However, it fails the test suite when using mimalloc as the allocator and is not performance-neutral within the benchmarks, likely due to the considerations outlined in the first referenced note.

@kleisauke
Copy link
Owner

Closing due to inactivity but please feel free to reopen with more details if further help is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants