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

Don't attempt to initialise memory views before the wasm module is initialised in the bunder target #2965

Merged
merged 1 commit into from Jun 27, 2022

Conversation

Liamolucko
Copy link
Collaborator

Fixes #2961

In the bundler target, there's a circular dependency between the bindings and the wasm module. That means that the wasm module's exports aren't available at the top level. In #2886, I didn't realise that and made the memory views be initialised at the top level, which resulted in an error from the wasm module's memory not being available yet.

This fixes that by lazily initialising the memory views like they were before #2886, except that they're reset in init (on targets that have it) to make sure they're updated if it's called multiple times (the reason I made them be immediately initialised in the first place).

In the bundler target, there's a circular dependency between the bindings and the wasm module. That means that the wasm module's exports aren't available at the top level. In rustwasm#2886, I didn't realise that and made the memory views be initialised at the top level, which resulted in an error from the wasm module's memory not being available yet.

This fixes that by lazily initialising the memory views like they were before rustwasm#2886, except that they're reset to uninitialised in `init` to make sure they're updated if it's called multiple times (the reason I made them be immediately initialised in the first place).
@hamza1311 hamza1311 merged commit 7f4663b into rustwasm:main Jun 27, 2022
@hamza1311
Copy link
Collaborator

Great, thanks for the fix!

I assume this doesn't have a hit on performance, right?

@Liamolucko Liamolucko deleted the memview-init-bundler branch June 27, 2022 21:56
@Liamolucko
Copy link
Collaborator Author

It shouldn't, since it only changes what happens at initialisation.

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

Successfully merging this pull request may close these issues.

Eagerly cached TypedArray objects cause circular dependency for bundler modes
2 participants