wailsapp / wailsapp/wails

Fix/Workaround for silent crash when using OpenDirectoryDialog on Windows

Open
#6,071 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug v2
Dominant language
Go
Stars
36.3k
Forks
1.9k
Avg merge
2d 11h
Merged PRs (30d)
33

Description

Wails version family

v2

Exact Wails version

v2.15.0

Operating System

Windows

Description

I recently encountered a fatal silent crash on Windows when using runtime.OpenDirectoryDialog in Wails v2 without a DefaultDirectory configured.

When calling OpenDirectoryDialog for the very first time without providing a DefaultDirectory, the dialog opens successfully, but Windows attempts to save an invalid or empty state to the Windows Explorer Dialog Registry history (HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CIDOpen / ComDlg32).

When you restart the app and trigger the dialog again, Windows attempts to restore this corrupt view state from the registry into the new process. This instantly causes a fatal memory access violation in the COM thread, bringing down the whole Wails application without any stack trace or panic output in the terminal.

To Reproduce
  1. On a fresh Windows installation or with a clean dialog registry history, call runtime.OpenDirectoryDialog() without providing a DefaultDirectory in the options.
  2. Select a directory and completely close the Wails application.
  3. Restart the Wails application.
  4. Call runtime.OpenDirectoryDialog() again.
  5. The application instantly closes/crashes before the dialog is rendered.
Expected behaviour

The dialog should open successfully on subsequent runs. Wails should either automatically set a safe fallback path internally if DefaultDirectory is empty, or properly handle the corrupt registry read so that it doesn't crash the entire host process.

Screenshots

No response

Attempted Fixes
  • Providing a DefaultDirectory (e.g. C:\) AFTER the crash has already occurred does NOT fix the issue, because Windows still tries to read the corrupt history state first.
  • The ONLY way to fix it is to:
    1. Manually delete the cached registry keys (ComDlg32, CIDOpen, CIDSave under HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\) to clear the corrupt state.
    2. Ensure the code ALWAYS provides a valid DefaultDirectory from the very first run onward to prevent the corrupt state from being written again.
System Details
# Wails
┌───────────────────┐
| Version | v2.15.0 |
└───────────────────┘

# System
┌──────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Windows 10 Enterprise                                                     |
| Version      | 2009 (Build: 26200)                                                       |
| ID           | 25H2                                                                      |
| Branding     | Windows 11 Pro                                                            |
| Go Version   | go1.27.0                                                                  |
| Platform     | windows                                                                   |
| Architecture | 386                                                                       |
| CPU          | Intel(R) Core(TM) Ultra 9 185H                                            |
| GPU 1        | Intel(R) Arc(TM) Pro Graphics (Intel Corporation) - Driver: 32.0.101.8517 |
| GPU 2        | NVIDIA RTX 3000 Ada Generation Laptop GPU (NVIDIA) - Driver: 32.0.15.9658 |
| Memory       | 64GB                                                                      |
└──────────────────────────────────────────────────────────────────────────────────────────┘
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the runtime.OpenDirectoryDialog entry point and follow its Windows implementation, focusing on handling an empty DefaultDirectory before the native dialog is opened. Reproduce the sequence on Windows with a clean dialog history, then restart and open the dialog again. Done means subsequent runs no longer silently crash when DefaultDirectory is omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.