The Anatomy of a macOS Window
A modern macOS application window appears simple, but it's the tip of a deep architectural iceberg. This interactive page dissects that architecture, from high-level AppKit objects down to the GPU, revealing a system designed for performance, stability, and evolution. Let's begin the journey.
The Core Hierarchy
Every app starts with a core set of objects. The NSApplication conducts the app, the NSWindow provides its on-screen presence, and a private NSThemeFrame draws the window's "chrome" around your actual contentView.
Interactive Window Simulator
The NSWindow.styleMask is a set of flags that tells the system how to draw the window's frame. The private NSThemeFrame interprets these flags. Toggle the options below to see how your intent as a developer is translated into the final window chrome.
Style Mask Options
This is the contentView where your application's interface lives.
The GPU Handoff: wantsLayer
A single property, wantsLayer, marks the "continental divide" of rendering. It tells a view to stop drawing with the CPU and instead hand off its content to a CALayer for the GPU-accelerated Core Animation engine to composite.
wantsLayer = false (Default)
The view's drawRect: method is called. The CPU draws content using Core Graphics. This is inefficient for animation.
wantsLayer = true
The view is backed by a CALayer. The GPU composites this layer. Animations are fast and efficient.
Core Animation's Three-Tree Architecture
To achieve fluid, decoupled animations, Core Animation uses three parallel layer trees. This ensures animations run smoothly on the WindowServer process, even if the app's main thread is busy.
Model Tree
App's source of truth. Stores the final state of animations.
Presentation Tree
The "in-flight" values during an animation. Read-only.
Render Tree (Private)
Used by WindowServer for actual GPU rendering commands.
The Full Journey: Click to Pixel
Now let's synthesize everything. Click on each stage of the pipeline below to see a detailed explanation of its role in turning a single user action into rendered pixels on the screen.