is WebAssembly can run on chrome-extension?
Reported by
nog...@post.bgu.ac.il,
Apr 2 2018
|
|||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Steps to reproduce the problem:
1. Trying to use WebAssembly in chrome-extension
2. Can't fetch .wasm file
3. Can't access the module if loading the .js file
What is the expected behavior?
What went wrong?
fetch('simple.wasm').then(response =>
response.arrayBuffer()
).then(bytes =>
WebAssembly.instantiate(bytes, importObject)
).then(results => {
results.instance.exports.exported_func();
});
producing the error:
"Uncaught (in promise) TypeError: WebAssembly Instantiation: Import #0 module="env" error: module is not an object or function"
or
"Uncaught (in promise) TypeError: Fail ed to fetch"
Accessing the .js file:
in background.html:
<script src="index.js"></script>
and then just use the function exported:
var result = _roll_dice();
BUT, in extension I only have a background.html file. So I'm looking for a way to access the Module which was loaded in the background file. and I need to call the function from a Worker.
I've tried:
chrome.extension.getBackgroundPage() can access the Module but can't send it to the Worker:
Failed to execute 'postMessage' on 'Worker': # could not be cloned.
And if I try to stringify it first:
Uncaught TypeError: Converting circular structure to JSON
(I tried to un-circular it, didn't work...)
And I can't call chrome.extension.getBackgroundPage() from the Worker because I can't access chrome API from there.
Did this work before? N/A
Chrome version: <Copy from: 'about:version'> Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: Shockwave Flash 29.0 r0
,
Apr 3 2018
,
Apr 9 2018
nogaag@ - Thanks for filing the issue...!! Could you please provide a sample test file/url to test the issue from TE-end. This will help us in triaging the issue further. Thanks...!!
,
Apr 9 2018
Hi, thank you for your reply. These files are from "hello-world" examples. To download the .wasm file: https://github.com/mdn/webassembly-examples/raw/master/js-api-examples/simple.wasm Which is from this link: https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API To download the .js file: http://demo.tutorialzine.com/2017/06/getting-started-with-wasm/getting-started-with-wasm.zip Which is from this link: https://tutorialzine.com/2017/06/getting-started-with-web-assembly I didn't write any special code in the extension for that. In the end I need to call WebAssembly from a Worker, but for now I cannot make it to work at all. Thank you!
,
Apr 9 2018
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Apr 10 2018
Brad, do you have any pointers how this could work?
,
Jan 16
(6 days ago)
Hi, could you please retry your example now, as postMessage()ing of modules is a relatively new feature that might not have been implemented when the bug was filed.
,
Yesterday
(28 hours ago)
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by vamshi.kommuri@chromium.org
, Apr 2 2018