diff --git a/docs/src/content/docs/changelog.mdx b/docs/src/content/docs/changelog.mdx index 67f832ea4..9831f73f7 100644 --- a/docs/src/content/docs/changelog.mdx +++ b/docs/src/content/docs/changelog.mdx @@ -82,6 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add File Association support for mac by [@wimaha](https://github.com/wimaha) in [#4177](https://github.com/wailsapp/wails/pull/4177) - Add `wails3 tool version` for semantic version bumping by [@leaanthony](https://github.com/leaanthony) - Add badging support for macOS and Windows by [@popaprozac](https://github.com/popaprozac) in [#](https://github.com/wailsapp/wails/pull/4234) + ### Fixed - Fixed Windows+Linux Edit Menu issues by [@leaanthony](https://github.com/leaanthony) in [#3f78a3a](https://github.com/wailsapp/wails/commit/3f78a3a8ce7837e8b32242c8edbbed431c68c062) @@ -127,6 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed system trays not showing after taskbar restarts by [@leaanthony](https://github.com/leaanthony) based on work by @kron. - Fixed fallbackResponseWriter not implementing Flush() in [#4245](https://github.com/wailsapp/wails/pull/4245) - Fixed fallbackResponseWriter not implementing Flush() by [@superDingda] in [#4236](https://github.com/wailsapp/wails/issues/4236) +- Fixed Windows Efficiency mode startup race condition by [@leaanthony](https://github.com/leaanthony) ### Changed diff --git a/v3/go.mod b/v3/go.mod index 8d0e4935c..3684bbff2 100644 --- a/v3/go.mod +++ b/v3/go.mod @@ -18,7 +18,7 @@ require ( github.com/google/uuid v1.6.0 github.com/goreleaser/nfpm/v2 v2.41.3 github.com/jackmordaunt/icns/v2 v2.2.7 - github.com/jaypipes/ghw v0.13.0 + github.com/jaypipes/ghw v0.17.0 github.com/leaanthony/clir v1.7.0 github.com/leaanthony/go-ansi-parser v1.6.1 github.com/leaanthony/gosod v1.0.4 diff --git a/v3/go.sum b/v3/go.sum index 2c07fe6c8..1f4983e7a 100644 --- a/v3/go.sum +++ b/v3/go.sum @@ -174,8 +174,8 @@ github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/jackmordaunt/icns/v2 v2.2.7 h1:K/RbfvuzjmjVY5y4g+XENRs8ZZatwz4YnLHypa2KwQg= github.com/jackmordaunt/icns/v2 v2.2.7/go.mod h1:ovoTxGguSuoUGKMk5Nn3R7L7BgMQkylsO+bblBuI22A= -github.com/jaypipes/ghw v0.13.0 h1:log8MXuB8hzTNnSktqpXMHc0c/2k/WgjOMSUtnI1RV4= -github.com/jaypipes/ghw v0.13.0/go.mod h1:In8SsaDqlb1oTyrbmTC14uy+fbBMvp+xdqX51MidlD8= +github.com/jaypipes/ghw v0.17.0 h1:EVLJeNcy5z6GK/Lqby0EhBpynZo+ayl8iJWY0kbEUJA= +github.com/jaypipes/ghw v0.17.0/go.mod h1:In8SsaDqlb1oTyrbmTC14uy+fbBMvp+xdqX51MidlD8= github.com/jaypipes/pcidb v1.0.1 h1:WB2zh27T3nwg8AE8ei81sNRb9yWBii3JGNJtT7K9Oic= github.com/jaypipes/pcidb v1.0.1/go.mod h1:6xYUz/yYEyOkIkUt2t2J2folIuZ4Yg6uByCGFXMCeE4= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= diff --git a/v3/pkg/application/linux_cgo.go b/v3/pkg/application/linux_cgo.go index 7dbeaaf5e..369a0e815 100644 --- a/v3/pkg/application/linux_cgo.go +++ b/v3/pkg/application/linux_cgo.go @@ -1009,6 +1009,10 @@ func (w *linuxWebviewWindow) hide() { C.gtk_widget_hide(w.gtkWidget()) } +func (w *linuxWebviewWindow) windowHide() { + C.gtk_widget_hide(w.gtkWidget()) +} + func (w *linuxWebviewWindow) isFullscreen() bool { gdkWindow := C.gtk_widget_get_window(w.gtkWidget()) state := C.gdk_window_get_state(gdkWindow) @@ -1123,6 +1127,13 @@ func (w *linuxWebviewWindow) show() { //w.setPosition(w.lastX, w.lastY) } +func (w *linuxWebviewWindow) windowShow() { + if w.gtkWidget() == nil { + return + } + C.gtk_widget_show_all(w.gtkWidget()) +} + func windowIgnoreMouseEvents(window pointer, webview pointer, ignore bool) { var enable C.int if ignore { diff --git a/v3/pkg/application/linux_purego.go b/v3/pkg/application/linux_purego.go index 258eecc94..8e5a3e0dc 100644 --- a/v3/pkg/application/linux_purego.go +++ b/v3/pkg/application/linux_purego.go @@ -1206,3 +1206,18 @@ func runSaveFileDialog(dialog *SaveFileDialogStruct) (string, error) { func isOnMainThread() bool { return mainThreadId == gThreadSelf() } + +// linuxWebviewWindow show/hide methods for purego implementation +func (w *linuxWebviewWindow) windowShow() { + if w.window == 0 { + return + } + windowShow(w.window) +} + +func (w *linuxWebviewWindow) windowHide() { + if w.window == 0 { + return + } + windowHide(w.window) +} diff --git a/v3/pkg/application/webview_window_darwin.go b/v3/pkg/application/webview_window_darwin.go index 28e693a23..b57fcb095 100644 --- a/v3/pkg/application/webview_window_darwin.go +++ b/v3/pkg/application/webview_window_darwin.go @@ -903,6 +903,8 @@ func (w *macosWebviewWindow) getScreen() (*Screen, error) { } func (w *macosWebviewWindow) show() { + // macOS implementation is already robust - window container shows immediately + // This is the preferred pattern that Windows should follow C.windowShow(w.nsWindow) } diff --git a/v3/pkg/application/webview_window_linux.go b/v3/pkg/application/webview_window_linux.go index 8c50c6117..acf8a47c9 100644 --- a/v3/pkg/application/webview_window_linux.go +++ b/v3/pkg/application/webview_window_linux.go @@ -412,6 +412,18 @@ func (w *linuxWebviewWindow) setIgnoreMouseEvents(ignore bool) { w.ignoreMouse(w.ignoreMouseEvents) } +func (w *linuxWebviewWindow) show() { + // Linux implementation is robust - window shows immediately + // This is the preferred pattern that Windows should follow + w.windowShow() +} + +func (w *linuxWebviewWindow) hide() { + // Save position before hiding (consistent with CGO implementation) + w.lastX, w.lastY = w.position() + w.windowHide() +} + func (w *linuxWebviewWindow) showMenuBar() {} func (w *linuxWebviewWindow) hideMenuBar() {} func (w *linuxWebviewWindow) toggleMenuBar() {} diff --git a/v3/pkg/application/webview_window_windows.go b/v3/pkg/application/webview_window_windows.go index a49255dd5..abc0e1e43 100644 --- a/v3/pkg/application/webview_window_windows.go +++ b/v3/pkg/application/webview_window_windows.go @@ -57,6 +57,11 @@ type windowsWebviewWindow struct { chromium *edge.Chromium webviewNavigationCompleted bool + // Window visibility management - robust fallback for issue #2861 + showRequested bool // Track if show() was called before navigation completed + visibilityTimeout *time.Timer // Timeout to show window if navigation is delayed + windowShown bool // Track if window container has been shown + // resizeBorder* is the width/height of the resize border in pixels. resizeBorderWidth int32 resizeBorderHeight int32 @@ -960,14 +965,45 @@ func (w *windowsWebviewWindow) printStyle() { } func (w *windowsWebviewWindow) show() { + // Always show the window container immediately (decouple from WebView state) + // This fixes issue #2861 where efficiency mode prevents window visibility + w32.ShowWindow(w.hwnd, w32.SW_SHOW) + w.windowShown = true + w.showRequested = true + + // Show WebView if navigation has completed if w.webviewNavigationCompleted { w.chromium.Show() - w32.ShowWindow(w.hwnd, w32.SW_SHOW) + // Cancel timeout since we can show immediately + if w.visibilityTimeout != nil { + w.visibilityTimeout.Stop() + w.visibilityTimeout = nil + } + } else { + // Start timeout to show WebView if navigation is delayed (fallback for efficiency mode) + if w.visibilityTimeout == nil { + w.visibilityTimeout = time.AfterFunc(3*time.Second, func() { + // Show WebView even if navigation hasn't completed + // This prevents permanent invisibility in efficiency mode + if !w.webviewNavigationCompleted && w.chromium != nil { + w.chromium.Show() + } + w.visibilityTimeout = nil + }) + } } } func (w *windowsWebviewWindow) hide() { w32.ShowWindow(w.hwnd, w32.SW_HIDE) + w.windowShown = false + w.showRequested = false + + // Cancel any pending visibility timeout + if w.visibilityTimeout != nil { + w.visibilityTimeout.Stop() + w.visibilityTimeout = nil + } } // Get the screen for the current window @@ -990,6 +1026,10 @@ func newWindowImpl(parent *WebviewWindow) *windowsWebviewWindow { parent: parent, resizeBorderWidth: int32(w32.GetSystemMetrics(w32.SM_CXSIZEFRAME)), resizeBorderHeight: int32(w32.GetSystemMetrics(w32.SM_CYSIZEFRAME)), + // Initialize visibility tracking fields + showRequested: false, + visibilityTimeout: nil, + windowShown: false, } return result @@ -1640,6 +1680,14 @@ func (w *windowsWebviewWindow) setupChromium() { chromium.Embed(w.hwnd) + // Prevent efficiency mode by keeping WebView2 visible (fixes issue #2861) + // Microsoft recommendation: keep IsVisible = true to avoid efficiency mode + // See: https://github.com/MicrosoftEdge/WebView2Feedback/discussions/4021 + err := chromium.PutIsVisible(true) + if err != nil { + globalApplication.error("Failed to set WebView2 visibility for efficiency mode prevention: %v", err) + } + if chromium.HasCapability(edge.SwipeNavigation) { err := chromium.PutIsSwipeNavigationEnabled(opts.EnableSwipeGestures) if err != nil { @@ -1837,6 +1885,12 @@ func (w *windowsWebviewWindow) navigationCompleted(sender *edge.ICoreWebView2, a } w.webviewNavigationCompleted = true + // Cancel any pending visibility timeout since navigation completed + if w.visibilityTimeout != nil { + w.visibilityTimeout.Stop() + w.visibilityTimeout = nil + } + wasFocused := w.isFocused() // Hack to make it visible: https://github.com/MicrosoftEdge/WebView2Feedback/issues/1077#issuecomment-825375026 err := w.chromium.Hide() @@ -1850,8 +1904,13 @@ func (w *windowsWebviewWindow) navigationCompleted(sender *edge.ICoreWebView2, a if wasFocused { w.focus() } + + // Only call parent.Show() if not hidden and show was requested but window wasn't shown yet + // The new robust show() method handles window visibility independently if !w.parent.options.Hidden { - w.parent.Show() + if w.showRequested && !w.windowShown { + w.parent.Show() + } w.update() } } diff --git a/v3/tests/window-visibility-test/.gitignore b/v3/tests/window-visibility-test/.gitignore new file mode 100644 index 000000000..dc734a8b8 --- /dev/null +++ b/v3/tests/window-visibility-test/.gitignore @@ -0,0 +1,19 @@ +# Compiled binary +window-visibility-test +window-visibility-test.exe + +# Build artifacts +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binaries +*.test + +# Output of the go coverage tool +*.out + +# Go workspace file +go.work \ No newline at end of file diff --git a/v3/tests/window-visibility-test/README.md b/v3/tests/window-visibility-test/README.md new file mode 100644 index 000000000..04b4ec49e --- /dev/null +++ b/v3/tests/window-visibility-test/README.md @@ -0,0 +1,146 @@ +# Window Visibility Test - Issue #2861 + +This example demonstrates and tests the fixes implemented for [Wails v3 Issue #2861](https://github.com/wailsapp/wails/issues/2861) regarding application windows not showing on Windows 10 Pro due to efficiency mode. + +## Problem Background + +On Windows systems, the "efficiency mode" feature could prevent Wails applications from displaying windows properly. This occurred because: + +1. **WebView2 NavigationCompleted events** could be delayed or missed in efficiency mode +2. **Window visibility was gated** behind WebView2 navigation completion +3. **No fallback mechanisms** existed for delayed or failed navigation events + +## Solution Implemented + +The fix implements a **robust cross-platform window visibility pattern**: + +### Windows Improvements +- ✅ **Decouple window container from WebView state** - Windows show immediately +- ✅ **3-second timeout fallback** - Shows WebView if navigation is delayed +- ✅ **Efficiency mode prevention** - Sets WebView2 `IsVisible=true` per Microsoft guidance +- ✅ **Enhanced state tracking** - Proper visibility state management + +### Cross-Platform Consistency +- ✅ **macOS** - Already robust, documented best practices +- ✅ **Linux** - Added missing show/hide methods for both CGO and purego builds + +## Test Scenarios + +This example provides comprehensive testing for: + +### 1. **Basic Window Tests** +- **Normal Window**: Standard window creation - should appear immediately +- **Delayed Content Window**: Simulates heavy content loading (like Vue.js apps) +- **Hidden → Show Test**: Tests delayed showing after initial creation + +### 2. **Stress Tests** +- **Multiple Windows**: Creates 3 windows simultaneously +- **Rapid Creation**: Creates windows in quick succession + +### 3. **Critical Issue #2861 Test** +- **Efficiency Mode Test**: Specifically designed to reproduce and verify the fix +- Tests window container vs content loading timing +- Includes heavy content simulation + +## How to Run + +```bash +cd /path/to/wails/v3/examples/window-visibility-test +wails dev +``` + +## Testing Instructions + +### What to Look For +1. **Immediate Window Appearance** - Windows should appear within 100ms of clicking buttons +2. **Progressive Loading** - Content may load progressively, but window container visible immediately +3. **No Efficiency Mode Issues** - Windows appear even if Task Manager shows "efficiency mode" +4. **Consistent Cross-Platform Behavior** - Similar behavior on Windows, macOS, and Linux + +### How to Test +1. **Note the current time** displayed in the app +2. **Click any test button** or use menu items +3. **Immediately observe** if a window appears (should be within 100ms) +4. **Wait for content** to load and check reported timing +5. **Try multiple tests** in sequence to test robustness +6. **Test both buttons and menu items** for comprehensive coverage + +### Expected Results +- ✅ Window containers appear immediately upon button click +- ✅ Content loads progressively within 2-3 seconds +- ✅ No blank or invisible windows, even under efficiency mode +- ✅ Activity log shows sub-100ms window creation times +- ✅ All test scenarios work consistently + +## Manual Testing Checklist + +### Windows 10 Pro (Primary Target) +- [ ] Test with efficiency mode enabled in Task Manager +- [ ] Create windows while system is under load +- [ ] Test rapid window creation scenarios +- [ ] Verify WebView2 content loads after container appears +- [ ] Check activity log for sub-100ms creation times + +### Windows 11 +- [ ] Verify consistent behavior with Windows 10 Pro fixes +- [ ] Test efficiency mode scenarios +- [ ] Validate timeout fallback mechanisms + +### macOS +- [ ] Confirm existing robust behavior maintained +- [ ] Test all window creation scenarios +- [ ] Verify no regressions introduced + +### Linux +- [ ] Test both CGO and purego builds +- [ ] Verify new show/hide methods work correctly +- [ ] Test window positioning and timing + +## Technical Implementation Details + +### Window Creation Flow +``` +1. User clicks button → JavaScript calls Go backend +2. Go creates WebviewWindow → Sets properties +3. Go calls window.Show() → IMMEDIATE window container display +4. WebView2 starts navigation → Progressive content loading +5. Timeout fallback ensures WebView shows even if navigation delayed +``` + +### Key Code Changes +- **Windows**: `/v3/pkg/application/webview_window_windows.go` +- **macOS**: `/v3/pkg/application/webview_window_darwin.go` +- **Linux**: `/v3/pkg/application/webview_window_linux.go`, `linux_cgo.go`, `linux_purego.go` + +## Reporting Test Results + +When testing, please report: + +1. **Platform & OS Version** (e.g., "Windows 10 Pro 21H2", "macOS 13.1", "Ubuntu 22.04") +2. **Window Creation Timing** (from activity log) +3. **Any Delayed or Missing Windows** +4. **Efficiency Mode Status** (Windows only - check Task Manager) +5. **Content Loading Behavior** (immediate container vs progressive content) +6. **Any Error Messages** in activity log or console + +### Sample Test Report Format +``` +Platform: Windows 10 Pro 21H2 +Efficiency Mode: Enabled +Results: +- Normal Window: ✅ Appeared immediately (<50ms) +- Delayed Content: ✅ Container immediate, content loaded in 2.1s +- Multiple Windows: ✅ All 3 appeared simultaneously +- Critical Test: ✅ Window appeared immediately, content progressive +Notes: No issues observed, all windows visible immediately +``` + +## Architecture Notes + +This example demonstrates the **preferred window visibility pattern** for web-based desktop applications: + +1. **Separate Concerns**: Window container vs web content readiness +2. **Immediate Feedback**: Users see window immediately +3. **Progressive Enhancement**: Content loads and appears when ready +4. **Robust Fallbacks**: Multiple strategies for edge cases +5. **Cross-Platform Consistency**: Same behavior on all platforms diff --git a/v3/tests/window-visibility-test/TESTING_GUIDE.md b/v3/tests/window-visibility-test/TESTING_GUIDE.md new file mode 100644 index 000000000..dbb3bfd04 --- /dev/null +++ b/v3/tests/window-visibility-test/TESTING_GUIDE.md @@ -0,0 +1,159 @@ +# Testing Guide - Window Visibility Issue #2861 + +## Quick Start + +1. **Build and run the application:** + ```bash + cd v3/examples/window-visibility-test + ./build.sh + # OR + wails dev + ``` + +2. **Main testing interface:** + - The app opens with a comprehensive testing dashboard + - Contains multiple test scenarios accessible via buttons + - Also provides menu-based testing (File, Tests, Help menus) + - Real-time activity logging with precise timing + +## Critical Test Cases + +### 🎯 **Issue #2861 Reproduction Test** (Most Important) +**Button:** "Efficiency Mode Test" +**Expected:** Window container appears immediately, content loads progressively +**Watch for:** +- Window visible within 100ms of button click +- Content loading message appears initially +- Content completes loading after 2-3 seconds +- No blank or invisible windows + +### ⏳ **Delayed Content Simulation** +**Button:** "Create Delayed Content Window" +**Expected:** Tests navigation completion timing +**Watch for:** +- Window container appears immediately +- Loading spinner visible initially +- Content loads after 3-second delay +- Window remains visible throughout + +### 🔄 **Hidden → Show Robustness** +**Button:** "Hidden → Show Test" +**Expected:** Tests delayed show() calls +**Watch for:** +- Initial response in activity log +- Window appears after exactly 2 seconds +- No timing issues or failures + +## Platform-Specific Testing + +### Windows 10 Pro (Primary Target) +**Enable Efficiency Mode Testing:** +1. Open Task Manager → Processes tab +2. Find the test application process +3. Right-click → "Efficiency mode" (if available) +4. Run all test scenarios +5. Verify windows still appear immediately + +**Key Metrics:** +- Window creation: < 100ms +- Content loading: 2-3 seconds +- No invisible windows under any conditions + +### Windows 11 +**Similar to Windows 10 Pro but also test:** +- New Windows 11 efficiency features +- Multiple monitor scenarios +- High DPI scaling + +### macOS +**Focus on consistency:** +- All scenarios should work identical to Windows +- No regressions in existing robust behavior +- Test across different macOS versions if possible + +### Linux +**Test both build variants:** +```bash +# CGO build (default) +wails dev + +# Purego build +CGO_ENABLED=0 wails dev +``` +- Verify both variants behave identically +- Test across different Linux distributions + +## Success Criteria + +### ✅ **Pass Conditions** +- All windows appear within 100ms of button click +- Activity log shows consistent sub-100ms timing +- Content loads progressively without blocking window visibility +- No blank, invisible, or delayed windows under any test scenario +- Efficiency mode (Windows) does not prevent window appearance +- Menu and button testing yield identical results + +### ❌ **Fail Conditions** +- Any window takes >200ms to appear +- Blank or invisible windows under any condition +- Window visibility blocked by content loading +- Efficiency mode prevents window appearance +- Inconsistent behavior between test methods +- Platform-specific failures + +## Reporting Results + +**Please provide this information:** + +``` +Platform: [Windows 10 Pro/Windows 11/macOS/Linux distro + version] +Build Type: [CGO/Purego] (Linux only) +Efficiency Mode: [Enabled/Disabled/N/A] (Windows only) + +Test Results: +- Normal Window: [✅ Pass / ❌ Fail] - [timing in ms] +- Delayed Content: [✅ Pass / ❌ Fail] - [container timing / content timing] +- Hidden→Show: [✅ Pass / ❌ Fail] - [notes] +- Multiple Windows: [✅ Pass / ❌ Fail] - [notes] +- Efficiency Mode Test: [✅ Pass / ❌ Fail] - [critical timing results] + +Notes: +[Any additional observations, error messages, or unexpected behavior] +``` + +## Advanced Testing Scenarios + +### **Rapid Stress Testing** +1. Click "Rapid Creation Test" multiple times quickly +2. Use keyboard shortcuts to rapidly access menu items +3. Create multiple windows then close them rapidly +4. Test system under load (other applications running) + +### **Edge Case Testing** +1. Test during system startup (high load) +2. Test with multiple monitors +3. Test with different DPI scaling settings +4. Test while other WebView2 applications are running + +### **Timing Verification** +1. Use browser dev tools (F12) to check console timing +2. Compare activity log timing with system clock +3. Test on slower/older hardware if available +4. Verify timing consistency across multiple runs + +## Troubleshooting + +### **Common Issues** +- **Blank window**: Check activity log for error messages +- **Slow timing**: Verify system isn't under heavy load +- **Build failures**: Ensure Wails v3 CLI is latest version +- **Import errors**: Run `go mod tidy` in example directory + +### **Debug Information** +The application provides extensive logging: +- Browser console (F12) shows JavaScript timing +- Activity log shows backend call timing +- Go application logs show window creation details +- Check system Task Manager for process efficiency mode status + +This comprehensive testing should validate that the window visibility fixes successfully resolve issue #2861 across all supported platforms. \ No newline at end of file diff --git a/v3/tests/window-visibility-test/assets/index.html b/v3/tests/window-visibility-test/assets/index.html new file mode 100644 index 000000000..22023a5e3 --- /dev/null +++ b/v3/tests/window-visibility-test/assets/index.html @@ -0,0 +1,431 @@ + + +
+ + +Testing fixes for Wails v3 Issue #2861 - Windows 10 Pro Efficiency Mode
+These tests verify that windows appear immediately when requested, regardless of WebView content loading state.
+ +These tests push the window system to verify robustness under load and timing edge cases.
+ +This test specifically targets the Windows efficiency mode bug where WebView2 NavigationCompleted events could be delayed or missed.
+ +Monitor window creation timing and behavior. Each button click should result in immediate window visibility.
+ +This window should have appeared immediately after clicking the button.
Timestamp: " + time.Now().Format("15:04:05") + "
", + }) + + return "Normal window created" +} + +// CreateDelayedContentWindow creates a window with delayed content to test navigation timing +func (w *WindowTestService) CreateDelayedContentWindow() string { + log.Println("Creating delayed content window...") + + // Use HTML that will take time to load (simulates heavy Vue app) + delayedHTML := ` + + +This window tests navigation completion timing.
+ +Loading... (simulates heavy content)
+ +Window container should be visible immediately, even during load.
+ + ` + + w.app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ + Title: "Delayed Content Window - Test Navigation Timing", + Width: 600, + Height: 400, + X: 150, + Y: 150, + HTML: delayedHTML, + }) + + return "Delayed content window created" +} + +// CreateHiddenThenShowWindow creates a hidden window then shows it after delay +func (w *WindowTestService) CreateHiddenThenShowWindow() string { + log.Println("Creating hidden then show window...") + + window := w.app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ + Title: "Hidden Then Show Window - Test Show() Robustness", + Width: 600, + Height: 400, + X: 200, + Y: 200, + HTML: "This window was created hidden and then shown after 2 seconds.
Should test the robustness of the show() method.
Created at: " + time.Now().Format("15:04:05") + "
", + Hidden: true, // Start hidden + }) + + // Show after 2 seconds to test delayed showing + go func() { + time.Sleep(2 * time.Second) + log.Println("Showing previously hidden window...") + window.Show() + }() + + return "Hidden window created, will show in 2 seconds" +} + +// CreateMultipleWindows creates multiple windows simultaneously to test performance +func (w *WindowTestService) CreateMultipleWindows() string { + log.Println("Creating multiple windows...") + + for i := 0; i < 3; i++ { + bgColors := []string{"#ff9a9e,#fecfef", "#a18cd1,#fbc2eb", "#fad0c4,#ffd1ff"} + content := fmt.Sprintf(` + + +Part of multiple windows stress test
+All windows should appear quickly and simultaneously
+Created at: %s
+ + `, i+1, bgColors[i], i+1, time.Now().Format("15:04:05")) + + w.app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ + Title: fmt.Sprintf("Batch Window %d - Stress Test", i+1), + Width: 400, + Height: 300, + X: 250 + (i * 50), + Y: 250 + (i * 50), + HTML: content, + }) + } + + return "Created 3 windows simultaneously" +} + +// CreateEfficiencyModeTestWindow creates a window designed to trigger efficiency mode issues +func (w *WindowTestService) CreateEfficiencyModeTestWindow() string { + log.Println("Creating efficiency mode test window...") + + // Create content that might trigger efficiency mode or WebView2 delays + heavyHTML := ` + + +This window tests the fix for Windows 10 Pro efficiency mode issue #2861
+ +✅ Window container is visible (this text proves it)
+⏳ WebView2 navigation in progress...
+ +This application tests the fixes for Wails v3 issue #2861
Windows 10 Pro Efficiency Mode Fix
Tests window container vs WebView content visibility
Created for testing robust window visibility patterns
", + }) + }) + + app.SetMenu(menu) + + // Create main window + app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ + Title: "Window Visibility Test - Issue #2861", + Width: 800, + Height: 600, + X: 50, + Y: 50, + URL: "/index.html", + }) + + err := app.Run() + if err != nil { + log.Fatal(err) + } +}