I will provide a detailed explanation of the /Library/Saved Application State/
folder in macOS, covering the following aspects:
I will gather and compile this information and get back to you shortly.
The Saved Application State
folder is where macOS stores per-app UI state data for the system’s “Resume” feature introduced in OS X Lion ( Delete Specific Application Saved States from Mac OS X Resume ). This folder (located in a user’s home Library by default, i.e. ~/Library/Saved Application State/
) contains subdirectories for each application (named <bundle-id>.savedState
). Each such subdirectory holds the app’s last-used state so that when you relaunch the app or reboot your Mac, it can resume with all the windows and data that were last in use ( Delete Specific Application Saved States from Mac OS X Resume ). For sandboxed apps, the saved state is kept in the app’s container (e.g. ~/Library/Containers/<bundle-id>/Data/Library/Saved Application State
) (Archaeology | Saved Application State), but the content and purpose remain the same.
Within each .savedState
folder, macOS maintains a set of files that capture the UI state:
windows.plist
– a binary property list containing metadata for each window (window sizes/positions, titles, etc.) and app-level state info (Archaeology | Saved Application State). Notably it includes an NSDataKey
for each window – an encryption key used to secure that window’s saved data (Archaeology | Saved Application State).data.data
– a binary blob that holds the serialized UI state of the app (such as which documents or text were open, scroll positions, etc.). This file contains a list of records (one per window or UI element) that are saved via NSKeyedArchiver
(essentially a frozen snapshot of Cocoa objects) (Archaeology | Saved Application State). Each record is encrypted with the corresponding window’s NSDataKey
(using AES-128-CBC) before being written, so the UI data isn’t stored in plain text (Archaeology | Saved Application State) (Archaeology | Saved Application State).window_<N>.data
files – these appear for some apps/windows and store a graphical “snapshot” of each window’s last appearance (Archaeology | Saved Application State). They contain a compressed raw image of the window (used to briefly display a window’s last look instantly on app launch, while the real restoration happens in the background) (Archaeology | Saved Application State). These snapshots are also AES-128-CBC encrypted, but using a global key stored in the user’s Keychain (named “Apple Persistent State Encryption”) rather than the per-window key (Archaeology | Saved Application State). This added measure protects window screenshots more securely, since the decryption key is not kept alongside the files on disk.In summary, the Saved Application State folder stores each application’s UI state (windows and session information) so macOS can recreate your working environment. It’s essentially a cache of UI state: window layouts in windows.plist
and the contents/state of those windows in data.data
, often accompanied by visual snapshots. macOS writes to these files whenever an app’s state is saved (e.g. on quit or system restart), and reads them back when the app is launched to restore its previous state.
macOS manages saved application state automatically via the AppKit framework and a background daemon called talagent
(Transparent App Lifecycle Agent) (Archaeology | Saved Application State). Whenever you quit an app (provided the system setting **“Close windows when quitting an app” is disabled, meaning Resume is enabled) or when you restart your Mac with “Reopen windows when logging back in” checked, the system will capture the app’s UI state and write it to the Saved Application State folder (Archaeology | Saved Application State). AppKit/TALAgent create or update the .savedState
files at those moments without user intervention. (Internally, Cocoa applications cooperate by encoding their state via methods like NSResponder#encodeRestorableStateWithCoder:
– the results end up in the data.data
file mentioned above (Archaeology | Saved Application State).)
When an application is launched, AppKit will check for a corresponding saved state and automatically restore the windows and UI to the last recorded state (unless Resume is turned off globally or suppressed for that launch). Each preserved window is reconstructed: the app reads windows.plist
to learn what windows existed and uses the IDs and keys to decrypt the saved data in data.data
, thereby restoring objects, open documents, scroll positions, cursor locations, etc. Standard Cocoa windows/views restore themselves, while apps can also restore custom state as needed (The Core App Design) (The Core App Design). If the savedState files are missing or removed, the app will simply launch as if no previous session existed (no error – the files are treated like cache and will be regenerated on next quit ( Delete Specific Application Saved States from Mac OS X Resume )).
State restoration is typically performed at: login (for apps that were running at logout), app launch (if a saved state exists), or app relaunch after a crash. Users have some control over this process: