You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to import WebAssembly modules bigger than 4KB #6475
@kiurchv do you get this error on Microsoft Edge 16-17(insider)? If so I'll also want to see our Chakra team and platform team fall in line here given the tagged issues discussion.
We have no plans of removing the size limit from Chrome. Using WebAssembly.{Instance,Module} is a bad practice, and hurts the user experience especially for large modules. Use the WebAssembly.instantiateStreaming pattern instead.
Reacted by Rocco Musolino
Reacted by Christopher Jeffrey (JJ), Marin Petrunić, Ikenna Okafor, Photopea, Oleg Gun, Shronk, Duc Mai, T6, Mateusz, Dustin Van Tate Testa and 6 more
@mathiasbynens Imposing arbitrary limits on APIs is a bad practice. Super disappointed in Chrome's direction on this. It's fine to encourage async use but to offer a sync API and then make it broken is super wonky. As discussed in #6433 there are other ways to discourage API without delivering a broken one.
@sokra From the #6433 (comment) it looks like there's not supposed to be a 4kB limit in workers. Have you found that to be the case and is that something currently being leveraged by webpack?
Update:
It looks like Chrome 66, due out in a few days, will remove the 4kB limit in workers.
Reacted by Tectract, Steve Huguenin, TJ Johnson, Duc Mai, Mateusz, Null, SparkyTD and Colin Heinrichs
@jasondavies did you try it on a worker or on the main thread? If you did it on a worker could you please give me a repro? new WebAssembly.Module() works for me without limitations on a worker.
BTW, after reading through the other issues (and it appears I misread the comments above), I realise that the 4KB limit still applies on the main thread on Chrome 66, and there are likely no plans to change this. In other words, sorry for the noise!
It seems like switching to instantiateStreaming would close this issue.
Is there a known workaround for this? At the moment it seems like this pretty much renders webpack + wasm unusable. What does the timeline for a fix look like?
Reacted by Cameron Davison, Ivan Fedorov, Thijs Triemstra, Jonas and Rocco Musolino
@mathiasbynens Just a note, but instantiateStreaming only works when the response carries the MIME type of application/wasm, which, depending on the hoster of the WASM file, isn't always the case. For example, GitHub servers have no way of setting the MIME type. In such cases, you have to either use the fetch() version or the synchronous version. So please don't "force" people to use the instantiateStreaming API because there might be valid reasons for not using it.
Activity
sokra commentedon Feb 13, 2018
@bmeurer Who can I beg to remove this error from Chrome? (only from WASM.Instance, not from WASM.Module)
see also #6433
bmeurer commentedon Feb 13, 2018
Redirecting to @mstarzinger from the WebAssembly team.
TheLarkInn commentedon Feb 15, 2018
@kiurchv do you get this error on Microsoft Edge 16-17(insider)? If so I'll also want to see our Chakra team and platform team fall in line here given the tagged issues discussion.
mathiasbynens commentedon Apr 13, 2018
We have no plans of removing the size limit from Chrome. Using
WebAssembly.{Instance,Module}is a bad practice, and hurts the user experience especially for large modules. Use theWebAssembly.instantiateStreamingpattern instead.jdalton commentedon Apr 13, 2018
@mathiasbynens Imposing arbitrary limits on APIs is a bad practice. Super disappointed in Chrome's direction on this. It's fine to encourage async use but to offer a sync API and then make it broken is super wonky. As discussed in #6433 there are other ways to discourage API without delivering a broken one.
@sokra From the #6433 (comment) it looks like there's not supposed to be a 4kB limit in workers. Have you found that to be the case and is that something currently being leveraged by webpack?
Update:
It looks like Chrome 66, due out in a few days, will remove the 4kB limit in workers.
mathiasbynens commentedon Apr 16, 2018
The 4 KB limit never applied in workers, only on the main thread.
jdalton commentedon Apr 16, 2018
Yap, @gahaas corrected the note.
jasondavies commentedon Apr 19, 2018
Looks like this is still an issue on Chrome Version 66.0.3359.117 (Official Build) (64-bit) macOS 10.13.4?
gahaas commentedon Apr 19, 2018
@jasondavies did you try it on a worker or on the main thread? If you did it on a worker could you please give me a repro?
new WebAssembly.Module()works for me without limitations on a worker.jasondavies commentedon Apr 19, 2018
Main thread.
jasondavies commentedon Apr 19, 2018
BTW, after reading through the other issues (and it appears I misread the comments above), I realise that the 4KB limit still applies on the main thread on Chrome 66, and there are likely no plans to change this. In other words, sorry for the noise!
It seems like switching to instantiateStreaming would close this issue.
moritzuehling commentedon Apr 27, 2018
Is there a known workaround for this? At the moment it seems like this pretty much renders webpack + wasm unusable. What does the timeline for a fix look like?
Eruant commentedon May 1, 2018
Looks like there are alternatives now:
https://developers.google.com/web/updates/2018/04/loading-wasm
xtuc commentedon May 1, 2018
yes @Eruant Webpack is going to use
instantiateStreamingin the future to bypass this limitation.sokra commentedon May 13, 2018
fixed
fschutt commentedon Sep 30, 2018
@mathiasbynens Just a note, but
instantiateStreamingonly works when the response carries the MIME type ofapplication/wasm, which, depending on the hoster of the WASM file, isn't always the case. For example, GitHub servers have no way of setting the MIME type. In such cases, you have to either use the fetch() version or the synchronous version. So please don't "force" people to use theinstantiateStreamingAPI because there might be valid reasons for not using it.xtuc commentedon Sep 30, 2018
@fschutt we're adding a fallback here #7983
mathiasbynens commentedon Oct 1, 2018
@fschutt Yeah, our guidance includes that note: https://developers.google.com/web/updates/2018/04/loading-wasm (look for "Note: The server must be configured to serve [...]")
jolestar commentedon Apr 23, 2019
Create a URL object by Buffer, then use instantiateStreaming async method to load wasm.
https://stackoverflow.com/a/55813693/334103
Pauan commentedon Apr 23, 2019
@jolestar Don't forget to call
URL.revokeObjectURLafterwards: