Skip to content

[v3] window.Show(), window.Focus() causes error when window was previous hidden #4890

@farhan687

Description

@farhan687

Description

When handling the macOS dock icon click using
wailsEvents.Mac.ApplicationShouldHandleReopen, an error occurs if the main window was previously hidden via WindowClosing.

This makes it impossible to implement the common macOS behavior:

Close window → app stays running → clicking dock icon restores window

To Reproduce

code:

MainWindow.OnWindowEvent(wailsEvents.Common.WindowClosing, func(e *application.WindowEvent) {
	e.Cancel()
	MainWindow.Hide()
})

app.Event.OnApplicationEvent(
	wailsEvents.Mac.ApplicationShouldHandleReopen,
	func(e *application.ApplicationEvent) {
		fmt.Println("Dock icon clicked")

		if MainWindow != nil {
			MainWindow.Show()
			MainWindow.Focus()
		}
	},
)

I have also prepared sample app repo to reproduce the error.

  1. Clone https://github.com/farhan687/wailsapp
  2. Run command: wails3 dev
  3. Close the app
  4. Click on dock app icon
  5. repeat step 3-4 for few times and you should see the error
    error:
SIGSEGV: segmentation violation
PC=0x18f7f5820 m=0 sigcode=2 addr=0x3e5383a1b81a50
signal arrived during cgo execution

[error.log](https://github.com/user-attachments/files/24766616/error.log)

Expected behaviour

A supported pattern for:

  • Preventing app exit
  • Hiding main window
  • Restoring window on dock click (macOS behavior)

Screenshots

No response

Attempted Fixes

No response

System Details

Wails (v3.0.0-alpha.61)  Wails Doctor 
                                                                                                                                                     
# System 

┌──────────────────────────────────────────────────┐
| Name          | MacOS                            |
| Version       | 26.2                             |
| ID            | 25C56                            |
| Branding      | MacOS 26.2                       |
| Platform      | darwin                           |
| Architecture  | arm64                            |
| Apple Silicon | true                             |
| CPU           | Apple M1 Pro                     |
| CPU 1         | Apple M1 Pro                     |
| CPU 2         | Apple M1 Pro                     |
| GPU           | 16 cores, Metal Support: Metal 4 |
| Memory        | 16 GB                            |
└──────────────────────────────────────────────────┘

# Build Environment 

┌───────────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-alpha.61                                |
| Go Version   | go1.25.5                                       |
| -buildmode   | exe                                            |
| -compiler    | gc                                             |
| CGO_CFLAGS   |                                                |
| CGO_CPPFLAGS | -I/opt/homebrew/Cellar/openssl@3/3.4.0/include |
| CGO_CXXFLAGS |                                                |
| CGO_ENABLED  | 1                                              |
| CGO_LDFLAGS  | -L/opt/homebrew/Cellar/openssl@3/3.4.0/lib     |
| GOARCH       | arm64                                          |
| GOARM64      | v8.0                                           |
| GOOS         | darwin                                         |
└───────────────────────────────────────────────────────────────┘

# Dependencies 

┌───────────────────────────────────────────────────────────────────────────────────┐
| *NSIS           | Not Installed. Install with `brew install makensis`.            |
| Xcode cli tools | 2416                                                            |
| npm             | 10.8.2                                                          |
| docker          | *Docker version 24.0.6, build ed223bc (cross-compilation ready) |
|                                                                                   |
└───────────────────────────── * - Optional Dependency ─────────────────────────────┘

# Checking for issues 

 SUCCESS  No issues found

# Diagnosis 

 SUCCESS  Your system is ready for Wails development!

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions