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

wasm_exec.html (+.js): LinkError: WebAssembly.instantiate(): #34424

Closed
prospero78 opened this issue Sep 20, 2019 · 16 comments
Closed

wasm_exec.html (+.js): LinkError: WebAssembly.instantiate(): #34424

prospero78 opened this issue Sep 20, 2019 · 16 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@prospero78
Copy link

What version of Go are you using (go version)?

$ go version
1.13

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
GOOS=js
GOARH=wasm
$ go env

What did you do?

What did you expect to see?

Error in execute in brouser bin code on wasm

What did you see instead?

LinkError: WebAssembly.instantiate(): Import #18 module="go" function="syscall/js.copyBytesToJS" error: function import requires a callable
(anonymous) @ wasm_exec.html:36
Promise.catch (async)
(anonymous) @ wasm_exec.html:35

@agnivade
Copy link
Contributor

You are likely using a different wasm_exec.js than your Go version. Please check that. And if you still see this issue, please mention the exact steps to reproduce this issue. Thanks.

@agnivade agnivade added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 20, 2019
@prospero78
Copy link
Author

prospero78 commented Sep 20, 2019

Version of golang and scripts -- best fresh. Its not different. Im repeat on my computer examples for WebAssembly (in this wiki on github). This message of errors -- in Chrome-console .
https://github.com/golang/go/wiki/WebAssembly
When im look this error in browser -- then im get from source on github wasm_exec.js.
It's not fix this trouble.

@agnivade
Copy link
Contributor

Please mention the exact steps that you did. If you have exactly followed https://github.com/golang/go/wiki/WebAssembly#getting-started, there shouldn't be any errors.

@agnivade agnivade added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 20, 2019
@prospero78
Copy link
Author

prospero78 commented Sep 20, 2019

Im now repeat all step in examples.
checked go version (1.13) = true
Settings OS enviroument = true
Compile for WASM = true
Starting simple http-server = true
Coping again wasm_wxec.js from %PATH%\misc\wasm to dir projects = true
In Chrome-console repeat look error:

Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #18 module="go" function="syscall/js.copyBytesToJS" error: function import requires a callable

Files for run examples:

13.09.2019 12:53 - 87 - build.bat
20.09.2019 14:52 - 279 - index.html
20.09.2019 10:04 - 163 - main.go
20.09.2019 14:54 - 2 263 787 - main.wasm
13.09.2019 14:3 - 7 372 800 - server.exe
13.09.2019 13:10 - 373 - server.zip
20.09.2019 10:07 - 1 301 - wasm_exec.html
03.09.2019 17:07 - 14 747 - wasm_exec.js
13.09.2019 12:52 - 73 - _start.bat

If im go to page http://localhost:8000/wasm_exec.html -- get in console this error:

LinkError: WebAssembly.instantiate(): Import #18 module="go" function="syscall/js.copyBytesToJS" error: function import requires a callable
(anonymous) @ wasm_exec.html:36
Promise.catch (async)
(anonymous) @ wasm_exec.html:35

It's error raise not in bin-wasm. It's raised in JavaScript module -- not find true parametrs for call.

if im go to page http://localhost:8000/ -- get in console this error:

(index):1 Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #18 module="go" function="syscall/js.copyBytesToJS" error: function import requires a callable
Promise.then (async)
(anonymous) @ (index):8

If in this situation make good work of head -- naturaly -- this same error.

@agnivade
Copy link
Contributor

Hi @prospero78 , perhaps there is a language barrier here due to which I am unable to explain what is required here. We need the exact commands that you executed on your system. So that we understand what exactly you did.

For example-

Compile for WASM = true

What is the exact command you ran ? Where is the source code ?

Coping again wasm_wxec.js from %PATH%\misc\wasm to dir projects = true

Again, what is the copy command you ran ? What is the value of %PATH% ? Note that %PATH% should be same as $(go env GOROOT). Is that correct ?

You mention projects directory, so that means we need to create it. Please also mention that.

Please also fill the output of go env in the original issue template.

We are looking for something like - the Go source file you compiled, the command you used to compile, the command used to copy the wasm_exec.js. Preferably, it should just be a list of shell commands we can copy paste and reproduce the issue. Hope that is clear now.

@agnivade agnivade added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 21, 2019
@prospero78
Copy link
Author

prospero78 commented Sep 23, 2019

I do not think that there is a language barrier here. Rather, it is a semantic barrier. If this barrier exists at all.

What is the exact command you ran ? Where is the source code ?

set GOOS=js set GOARCH=wasm go build -o main.wasm

The source code is in the same directory as the compilation commands.

Again, what is the copy command you ran ? What is the value of %PATH% ? Note that %PATH% should be same as $(go env GOROOT). Is that correct ?

% PATH% - I installed it correctly (points to all directories used in the work). Strictly speaking, this was the equivalent correct example of my path (just too lazy to write all the paths completely).
All variables are set absolutely correctly (otherwise I would not be able to compile the source code for golang in WASM)

You mention projects directory, so that means we need to create it. Please also mention that.

My project directory is not located in the %GOPATH%\SRC directory, but in my case it does not matter.

Please also fill the output of go env in the original issue template.

No problems.

d:\coding\prospero78su_test\waTest00>go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=d:\coding\golang_home\bin
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=d:\coding\golang_home
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\coding\golang
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\coding\golang\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=d:\temp\go-build540987206=/tmp/go-build -gno-record-gcc-switches

We are looking for something like - the Go source file you compiled, the command you used to compile, the command used to copy the wasm_exec.js. Preferably, it should just be a list of shell commands we can copy paste and reproduce the issue. Hope that is clear now.

I copied wasm_exec.js via TotalCommander (with replacing an existing file, the file size is the same), so the copy command does not matter.

I'm not new to golang, I'm doing everything right (at least my programmer skills allow me to work for money in a startup). The problem is not compilation, the problem wasm wasex_exec.js malfunctioning

I'll try two options today:

  1. Run golang on the system path.
  2. Do the same in the Linux virtual machine.

@agnivade
Copy link
Contributor

Ok, may I ask you to just attach your Go source file and the wasm_exec.js you are using ? We can reproduce the issue on our side and see what's going wrong.

@prospero78
Copy link
Author

prospero78 commented Sep 23, 2019

No problems.
https://yadi.sk/d/Q_RKU8WqHVF37g
https://yadi.sk/d/J1rGFld67Q96iQ
https://yadi.sk/d/ds_Pi3gu5N4kNA

Im now run this code in %GOPATH%\src -- this no have effects. This same error with /index.html (examples from wiki) and /wasm_exec.html (+wasm_exec.js from source golang).

@agnivade
Copy link
Contributor

This works fine for me @prospero78.

Im now run this code in %GOPATH%\src -- this no have effects. This same error with /index.html (examples from wiki) and /wasm_exec.html (+wasm_exec.js from source golang).

I do not understand this clearly. Are you saying this code works if you keep it in $GOPATH/src, but it does not work if you use wasm_exec.js from the Go source ?

@prospero78
Copy link
Author

I apologize for the misleading answer.
This code does not work in the case of a specific path, nor in the case of a path specified in the environment.

@agnivade
Copy link
Contributor

Ok, I don't know how else to proceed here. It works for me inside or outside GOPATH. The error is very specific to an incorrect wasm_exec.js, so I don't know how a different path can lead to this. Others can investigate further.

@checkmatesolo
Copy link

checkmatesolo commented Sep 23, 2019 via email

@prospero78
Copy link
Author

prospero78 commented Sep 23, 2019

Thank you all for the discussion, until there is no solution to this problem.
And thanks for the link to the video with detailed instructions.
I ask you to leave this question open.
(* In the message above - was it really a living person? *)

@agnivade
Copy link
Contributor

Just a small note that you might get better and quicker help in a Go forum like The golang-nuts mailing list or Gophers Slack. More people will see your issue and help you out. This issue tracker is mainly for bugs and feature proposals.

I will leave this open because it is not yet clear to me whether it is a bug or not.

@poerlang
Copy link

https://github.com/moketao/show_a_wasm_link_err

visit index.wasmgo.err.html, get some err:

Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #20 module="go" function="syscall/js.copyBytesToGo" error: function import requires a callable Promise.then (async) (anonymous) @ loader.js:1

visit index.wasmgo.ok.html, all is well.

@prospero78
Copy link
Author

prospero78 commented Jan 13, 2020

I figured out what the problem was: when moving from version 1.13.1 to a newer one, the shuffling library changed. For proper operation it was necessary to remove everything and install from the very beginning (as during the first installation). After that, everything starts to work. The topic can be closed.

@golang golang locked and limited conversation to collaborators Jan 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants