vugu / vugu

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

panic: requested instruction does not fit in the buffer #193

Open Nv7-GitHub opened 3 years ago

Nv7-GitHub commented 3 years ago

Describe the bug I noticed the new update that allows larger buffers, and I've been having the issue where inputs can only contain a limited amount of text, so I decided to try it out. Now, when I put a large amount of text in an input, instead of just giving me

Uncaught RangeError: offset is out of bounds

It actually crashes the WebAssembly program, giving the error

panic: requested instruction does not fit in the buffer

Software Versions Vugu version: v0.3.4 (just updated) Go version: 1.16.3 Browser and version: Chrome, 86

To Reproduce Put a large amount of text in an input (I was using vgform) and trigger a re-render.

Expected behavior It shouldn't crash.

Additional Notes The panic is happening inside of main_wasm.go in the lines

err = renderer.Render(buildResults)
if err != nil {
    panic(err)
}

I am using the default script, with no modifications.

bradleypeabody commented 3 years ago

@mertnacakgedigi Would you mind taking a look at this?

I'm surprised we didn't run into this while testing, but I think what's happening is now that the event buffer resizes automatically, the instruction buffer (different buffer, but similar use in the other direction - to send updates from WASM to the browser) is overflowing. It probably needs a similar fix, although the allocation will probably be on the Go side not the JS side this time.

@Nv7-GitHub Can you measure the size of the input that produced the error? 16k? 32k? That would be helpful to know for testing/debugging.

Nv7-GitHub commented 3 years ago

The input was 18,016 characters long. Thanks for the quick reply!

mertnacakgedigi commented 3 years ago

@bradleypeabody We updated the event buffer size allocating. I think this issue comes with the statically allocated instruction buffer as you mentioned. We need to check the size and reallocate it if needed. I'll have a look. @Nv7-GitHub thanks for reporting this issue.

owenwaller commented 7 months ago

It's not entirely clear if this has been fixed or not. It seems like a bug, if it is and it's still present we need to fix it before the v1.0 release.