wailsapp / go-webview2

The Wails fork of go-webview2
Other
36 stars 18 forks source link

Long string param will make "Overlapped I/O operation is in progress" panic of v1.0.13 #16

Closed mediawall closed 2 months ago

mediawall commented 2 months ago

type Data struct {
    Msg string `json:"msg"`
}

// Greet returns a greeting for the given name
func (a *App) Greet(d Data) string {
    return "hello"
}

Error "Overlapped I/O operation is in progress" occurs if the length of the parameter is relatively long (approximately len(msg) >= 9000).

Steps to reproduce:

Download this project myproject.zip

Run wails dev Click the Greet button Then you will see the error message on the console.

Error happens on Windows, the app works well on Linux.

leaanthony commented 2 months ago

Fixed on master: https://github.com/wailsapp/go-webview2/pull/13

lanyeeee commented 2 months ago

I found the panic occurs here: https://github.com/wailsapp/go-webview2/blob/ec818435537bbe310deee97015212770857b6a25/pkg/edge/chromium.go#L422-L428

This panic happens when the backend attempts to send the received message back to the frontend without any modification, and the message is long string.

It seems that when the data sent from the backend to the frontend via WebView is too large, the "Overlapped I/O operation is in progress" error occurs.

So, while it appears that the panic is caused by the frontend sending large data to the backend, it is actually similar to #12, where the issue is caused by the backend sending large data to the frontend(or more precisely, is caused by syscall).

Additionally, I don't quite understand why MessageReceived, after receiving the message and executing the callback function, needs to send the message back to the frontend via PostWebMessageAsString without any modification. @leaanthony @mediawall maybe you should reopen this issue.

mediawall commented 2 months ago

I can't reopen this issue, maybe only @leaanthony can do that. I think your comment is correct.