wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.59k stars 1.24k forks source link

WebView2 process crash on WV2 version before 118 #3913

Closed SuperDumbTM closed 4 hours ago

SuperDumbTM commented 1 week ago

Description

A wails application will crash with WebView2 version prior to 118.0.2088.76 on Windows.

An error message The WebView2 process crashed and the application needs to be restarted will show up when the GUI window is being "refocused" (mouse click on somewhere else and then click the app's window).

image

I have tested some of the versions between 100.0.1185.44 to 118.0.2088.76 and 131.0.2903.63 (latest). It seems the crash disappear at version 118.0.2088.76, so I suspect 117.0.2045.60 is the upper bound.

To Reproduce

  1. Run wails init -n webview-test.
  2. Modify main.go to use custom WebView2 executable (example code in below).
  3. Run wails build to build the executable for the application.
  4. Create a bin folder in the same folder with the app's executable and copy the custom WebView2 executable into it.
  5. Open the app and click somewhere else (anything but the app's window) and the click the app's window.

You may find different versions of WebView2 binaries in this repo: https://github.com/westinyang/WebView2RuntimeArchive

Example main.go:

package main

import (
    "embed"
    "os"
    "path/filepath"

    "github.com/wailsapp/wails/v2"
    "github.com/wailsapp/wails/v2/pkg/options"
    "github.com/wailsapp/wails/v2/pkg/options/assetserver"
    "github.com/wailsapp/wails/v2/pkg/options/windows"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {
    // Create an instance of the app structure
    app := NewApp()

    // WebView2 binary lookup
    var pathWV2 string
    if pathExe, err := os.Executable(); err != nil {
        panic(err)
    } else {
        pathWV2 = filepath.Join(filepath.Dir(pathExe), "bin")
        if _, err := os.Stat(pathWV2); err != nil {
            pathWV2 = ""
        }
    }

    // Create application with options
    err := wails.Run(&options.App{
        Title:  "WebView Debug",
        Width:  1024,
        Height: 768,
        AssetServer: &assetserver.Options{
            Assets: assets,
        },
        BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
        OnStartup:        app.startup,
        Bind: []interface{}{
            app,
        },
        Windows: &windows.Options{
            WebviewBrowserPath: pathWV2,
        },
    })

    if err != nil {
        println("Error:", err.Error())
    }
}

Expected behaviour

No crash

Screenshots

No response

Attempted Fixes

No response

System Details

# Wails
Version | v2.9.2

# Dependencies
┌───────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version       |
| WebView2   | N/A          | Installed | 131.0.2903.63 |
| Nodejs     | N/A          | Installed | 20.15.0       |
| npm        | N/A          | Installed | 10.7.0        |
| *upx       | N/A          | Installed | upx 4.2.4     |
| *nsis      | N/A          | Available |               |
└─────────────── * - Optional Dependency ───────────────┘

Additional context

No response

leaanthony commented 6 days ago

Thanks for taking the time to open this and doing the testing 🙏 We do need a better way of tracking runtime version compatibility. I'm wondering if there's a way to automate this....

This would be better tracked in https://github.com/wailsapp/go-webview2

xiexul commented 6 days ago

Me too!!!😭 027853DB-84DD-4768-A722-130B13FD55E1 image

SuperDumbTM commented 6 days ago

Thanks for taking the time to open this and doing the testing 🙏 We do need a better way of tracking runtime version compatibility. I'm wondering if there's a way to automate this....

This would be better tracked in https://github.com/wailsapp/go-webview2

I have opened an issue over there and shared some thoughts on automating a test against this error.