Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2, windows] Fix WebView2 minimum runtime version check #1456

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package edge

import (
"golang.org/x/sys/windows"
"unsafe"

"golang.org/x/sys/windows"
)

// ICoreWebviewSettings is the merged settings class
Expand All @@ -27,17 +28,17 @@ type _ICoreWebViewSettingsVtbl struct {
PutIsZoomControlEnabled ComProc
GetIsBuiltInErrorPageEnabled ComProc
PutIsBuiltInErrorPageEnabled ComProc
GetUserAgent ComProc
GetUserAgent ComProc // ICoreWebView2Settings2: SDK 1.0.864.35
PutUserAgent ComProc
GetAreBrowserAcceleratorKeysEnabled ComProc
GetAreBrowserAcceleratorKeysEnabled ComProc // ICoreWebView2Settings3: SDK 1.0.864.35
PutAreBrowserAcceleratorKeysEnabled ComProc
GetIsPasswordAutosaveEnabled ComProc
GetIsPasswordAutosaveEnabled ComProc // ICoreWebView2Settings4: SDK 1.0.902.49
PutIsPasswordAutosaveEnabled ComProc
GetIsGeneralAutofillEnabled ComProc
PutIsGeneralAutofillEnabled ComProc
GetIsPinchZoomEnabled ComProc
GetIsPinchZoomEnabled ComProc // ICoreWebView2Settings5: SDK 1.0.902.49
PutIsPinchZoomEnabled ComProc
GetIsSwipeNavigationEnabled ComProc
GetIsSwipeNavigationEnabled ComProc // ICoreWebView2Settings6: SDK 1.0.992.28
PutIsSwipeNavigationEnabled ComProc
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ const (
)

// CompareBrowserVersions will compare the 2 given versions and return:
// -1 = v1 < v2
// 0 = v1 == v2
// 1 = v1 > v2
// Less than zero: v1 < v2
// zero: v1 == v2
// Greater than zero: v1 > v2
func CompareBrowserVersions(v1 string, v2 string) (int, error) {

_v1, err := windows.UTF16PtrFromString(v1)
if err != nil {
return 0, err
Expand All @@ -43,16 +42,16 @@ func CompareBrowserVersions(v1 string, v2 string) (int, error) {
return 0, err
}

var result int
var result int32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

_, _, err = memCompareBrowserVersions.Call(
uint64(uintptr(unsafe.Pointer(_v1))),
uint64(uintptr(unsafe.Pointer(_v2))),
uint64(uintptr(unsafe.Pointer(&result))))

if err != windows.ERROR_SUCCESS {
return result, err
return 0, err
}
return result, nil
return int(result), nil
}

// GetInstalledVersion returns the installed version of the webview2 runtime.
Expand Down
4 changes: 2 additions & 2 deletions v2/internal/wv2installer/wv2installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/wailsapp/wails/v2/pkg/options/windows"
)

const MinimumRuntimeVersion string = "91.0.992.28"
const MinimumRuntimeVersion string = "94.0.992.31" // Webview2 SDK 1.0.992.28

type installationStatus int

Expand All @@ -35,7 +35,7 @@ func Process(appoptions *options.App) (string, error) {
if err != nil {
return "", err
}
updateRequired := compareResult == -1
updateRequired := compareResult < 0
// Installed and does not require updating
if !updateRequired {
return installedVersion, nil
Expand Down