New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 828012 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

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
 
Labels: Needs-Milestone

Comment 2 by l...@chromium.org, Apr 3 2018

Components: -Platform>DevTools Platform>Extensions Blink>JavaScript>WebAssembly
Cc: krajshree@chromium.org
Labels: Triaged-ET Needs-Feedback
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...!!
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!



Project Member

Comment 5 by sheriffbot@chromium.org, Apr 9 2018

Labels: -Needs-Feedback
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
Cc: nattestad@chromium.org hablich@chromium.org
Owner: bradnelson@chromium.org
Status: Assigned (was: Unconfirmed)
Brad, do you have any pointers how this could work?

Comment 7 by titzer@chromium.org, Jan 16 (6 days ago)

Owner: ----
Status: Unconfirmed (was: Assigned)
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.

Comment 8 by hablich@chromium.org, Yesterday (28 hours ago)

Status: Available (was: Unconfirmed)

Sign in to add a comment