Xharlie
Xharlie

Reputation: 2540

Why does Chrome eventually throw "Out of memory: wasm memory" after repeatedly refreshing a page that uses WebAssembly?

I would like to believe that refreshing a browser window or tab cannot leak. Unfortunately, this does not appear to be the case when WebAssembly is concerned.

I have built a WebAssembly crate with Rust. The compiled size of the crate is approximately 360 Kb (prior to content compression) and the crate works just fine in Firefox and even on Safari on iOS. However, I am having numerous issues in Chrome, one of them being that refreshing the page that uses the .wasm eventually leads to an out-of-memory error in the Console.

The page works fine for about 35 refreshes and then throws the following:

Uncaught (in promise) RangeError: WebAssembly Instantiation: Out of memory: wasm memory

After this, the tab is useless but opening a new tab and loading the page works as expected -- again, for about the first 35 refreshes.

Is this a bug in the browser or am I doing something wrong in my code? If it is a bug, is there any way to work around it? (Not that I expect that it will manifest itself in production but anyway...)

(Presumably, the promise mentioned in the error message is the one returned by import('...'). I am using webpack and so I am affected by https://github.com/webpack/webpack/issues/6615 )

Upvotes: 4

Views: 7167

Answers (1)

Xharlie
Xharlie

Reputation: 2540

This is apparently a confirmed bug in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=935169

It only occurs when Chrome's developer tools are open.

Upvotes: 7

Related Questions