-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Closed
Copy link
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancearch-wasmWebAssembly issuesWebAssembly issues
Milestone
Description
I am very excited that Go ships now with Webassembly support. I ran wasm code generated by Go 1.11 on Chrome and Firefox on desktops (MacOS and Linux) and on Chrome, Firefox and Safari on iOS devices. Running Go generated wasm code on Android devices failed though.
Minimal example
- Go code
GOOS=js GOARCH=wasm go build -o test.wasm wasm.go
package main
import (
"fmt"
)
func main() {
fmt.Println("hello")
}
index.html
wasm_exec.js
fromgo/misc/wasm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<script src="wasm_exec.js"></script>
<script>
(async function() {
const wasmFile = "test.wasm"
let run
const go = new Go()
try {
const { instance } = await WebAssembly.instantiateStreaming(fetch(wasmFile), go.importObject)
document.querySelector('#info').innerHTML = "ready"
run = go.run(instance)
} catch (err) {
document.querySelector('#info').innerHTML = err
console.log(err)
}
})()
</script>
<div id="info"></div>
</body>
</html>
- files are served via Nginx using adjusted
mime.types
Expected behavior
- page displays "ready" after the wasm file has been loaded and the console shows "hello"
- this works on Desktops and iOS devices
Actual behavior
- on Android devices the above code fails with "RangeError: WebAssembly Instantiation: Out of memory: wasm memory" (Chrome) and "out of memory" (Firefox)
- tested on Chrome for Android (68.0.3440.91) and Firefox for Android (61.0.2). Several devices from different manufacturers were tested
inkeliz, pkieltyka, Zitrone44, ajruckman, hajimehoshi and 2 more
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancearch-wasmWebAssembly issuesWebAssembly issues