tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

Unimplemented reflect.Value MethodByName()

Open kefniark opened this issue 1 year ago • 2 comments

Description

Earlier today, I was trying to build one of the ebitengine example with tinygo (nothing complicated, the sample from their getting started).

go get github.com/hajimehoshi/ebiten/v2
go run -tags=example github.com/hajimehoshi/ebiten/v2/examples/rotate

The default generated wasm binary size is quite big ~9MB, and Tinygo seem to do a better job for that. So I gave a try and the tinygo wasm build works fine, the size seems also quite promising ~2MB already 4x smaller. Sadly I'm running into some reflection issue with the generated wasm file:

panic: unimplemented: (reflect.Value).MethodByName()
yourgame.tiny.wasm:0x211b Uncaught (in promise) RuntimeError: unreachable
    at runtime._panic (yourgame.tiny.wasm:0x211b)
    at (*text/template.state).evalField (yourgame.tiny.wasm:0xf11b2)
    at (*text/template.state).evalFieldChain (yourgame.tiny.wasm:0xeec1a)
    at (*text/template.state).evalFieldNode (yourgame.tiny.wasm:0xeea29)
    at (*text/template.state).evalPipeline (yourgame.tiny.wasm:0xef459)
    at (*text/template.state).walkIfOrWith (yourgame.tiny.wasm:0xf80e3)
    at (*text/template.state).walk (yourgame.tiny.wasm:0xf7106)
    at (*text/template.state).walk (yourgame.tiny.wasm:0xf71a1)
    at github.com/hajimehoshi/ebiten/v2/internal/builtinshader.Shader (yourgame.tiny.wasm:0xf8b00)
    at byn$mgfn-shared$github.com/hajimehoshi/ebiten/v2/internal/restorable.init#1$1 (yourgame.tiny.wasm:0x143a0e)

Versions

  • Ebitengine 2.5.6
  • Go 1.20
  • Tinygo 1.28.1

kefniark avatar Aug 11 '23 05:08 kefniark

Unfortunately we don't support method names in reflect at the moment.

aykevl avatar Aug 11 '23 16:08 aykevl

It would be amazing if this worked because the wasm size is incredible smaller with tinygo which is vital for browser games. The wasm size generated by regular go is too big, even when brotlied.

butaca avatar Apr 16 '24 01:04 butaca