vugu / vugu

Vugu: A modern UI library for Go+WebAssembly (experimental)
https://www.vugu.org
MIT License
4.8k stars 175 forks source link

Fix "ValueOf: invalid value" panics in syscall/js when using vugu/js #205

Open Dadido3 opened 2 years ago

Dadido3 commented 2 years ago

This is a straight forward fix for the problem that syscall/js doesn't know about vugu/js value.

bradleypeabody commented 2 years ago

Thanks for this. Is there a test case that you can add to the test suite in wasm-test-suite, so I can see what problem is being solved with this fix?

Dadido3 commented 2 years ago

I haven't got the wasm-test-suite to run without errors here. Any tests always fail with panic: context deadline exceeded on the line must(chromedp.Run(ctx, actions...)). The docker container is running, maybe there is something wrong with my chromium installation.

Anyways, the problem that this pull request fixes can be simple reproduced by this code:

import js "github.com/vugu/vugu/js"

func main() {
    img := js.Global().Get("Image").New()
    img.Set("src", js.ValueOf("someURL")) // js.ValueOf() isn't really needed here, but it shows the problem.
}

If i get the wasm-test-suite working the next few days, i'll write a test for it.

Dadido3 commented 2 years ago

Finally got the tests to run in a linux container, and i added a test for the fix. Hope this covers the problem well enough. What's not covered by this test is:

But the fix works similar for these functions.

I've also figured out why the tests didn't run under windows, i'll make another pull request for that fix.

sorenisanerd commented 2 years ago

The tinygo test should work when #219 is merged.