Context
When a macOS/Mac Catalyst app crashes, the next launch of the same app can show a blocking window-restoration dialog:
The application "…" quit unexpectedly while trying to restore its windows. Do you want to try to reopen its windows again?
Until someone clicks a button, the app doesn't start — which stalls automated/unattended test runs (locally and potentially on CI bots) after a crashing test.
This is driven by macOS's saved application state (window restoration) mechanism, and is separate from the crash-reporter ("… quit unexpectedly") panel.
Ways to avoid it
- Delete the app's saved state before launching:
rm -rf ~/Library/Saved\ Application\ State/<bundle-id>.savedState
- Disable window keeping / state restore per app:
defaults write <bundle-id> NSQuitAlwaysKeepsWindows -bool false
defaults write <bundle-id> ApplePersistenceIgnoreState -bool YES
- Suppress the crash-reporter panel as well:
defaults write com.apple.CrashReporter DialogType none
For a robust test wrapper, combine deleting the .savedState directory before launch with CrashReporter DialogType none.
Prior art in this repo
We already do exactly this for the simulator:
https://github.com/dotnet/macios/blob/main/tests/dotnet/UnitTests/ProjectTest.cs#L1840
var dirsToBeDeleted = new [] {
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), "Library", "Saved Application State", "com.apple.iphonesimulator.savedState"),
};
Suggested action
Apply the same "delete .savedState before launch" approach (and/or the defaults above) to the macOS/Mac Catalyst test launch paths, so a crashing test doesn't block subsequent runs on an interactive dialog.
🤖 Issue filed by Copilot
Context
When a macOS/Mac Catalyst app crashes, the next launch of the same app can show a blocking window-restoration dialog:
Until someone clicks a button, the app doesn't start — which stalls automated/unattended test runs (locally and potentially on CI bots) after a crashing test.
This is driven by macOS's saved application state (window restoration) mechanism, and is separate from the crash-reporter ("… quit unexpectedly") panel.
Ways to avoid it
For a robust test wrapper, combine deleting the
.savedStatedirectory before launch withCrashReporter DialogType none.Prior art in this repo
We already do exactly this for the simulator:
https://github.com/dotnet/macios/blob/main/tests/dotnet/UnitTests/ProjectTest.cs#L1840
Suggested action
Apply the same "delete
.savedStatebefore launch" approach (and/or thedefaultsabove) to the macOS/Mac Catalyst test launch paths, so a crashing test doesn't block subsequent runs on an interactive dialog.🤖 Issue filed by Copilot