Skip to content
CefSwift
Esc
↑↓navigate↵open⌘Jpreview
On this page

Beside other browsers

The Browser example measured against Chrome for Testing and Helium: launch, memory, idle CPU and the GPU process, and what still trails.

Scripts/bench/bench.py

A CefSwift browser beside other browsers

Measured on 2026-11-29 with Scripts/bench/bench.py on an Apple M2 MacBook Air (Mac14,2) with 8 GB of memory, macOS 27.2.1, on AC power with Low Power Mode off, CEF 158.0.6 (Chromium 158.0.8127.89). Every measured JSON record is in Scripts/bench/results/2026-11-29-m2-8gb.json. The Browser example was bundled in release with the Command Line Tools 27.2 against the macOS 26.5 SDK (those tools have no SwiftUI macro plugin for the 27.2 SDK), every locale pack included, signed ad hoc.

Method. One browser at a time, each on the same sixteen pages (Scripts/bench/pages.py): generated documents of about 100 KB that build about 2,000 elements, keep about 2 MB of data in the JavaScript heap and draw a canvas, then stay idle. Each is on a site of its own (p1.localhost … p16.localhost), so each tab gets a renderer, and the script serves them itself, so the network plays no part.

  • Every Chromium browser is a new instance (open -n) on a temporary profile (--user-data-dir, -cacheDirectory for the Browser example, --use-mock-keychain), so copies the user has open are not touched. Before each run the profile’s Sessions are removed, so no run restores the one before.
  • A browser’s processes are the ones it started and the ones macOS counts it responsible for. Memory is the sum of their physical footprint (what Activity Monitor shows; 1 MiB = 2^20 bytes), read 20 s after every page has loaded, median of three readings. Idle CPU is their user and system time over the next 30 s, in percent of one core.
  • Launch is from open to the page’s own first contentful paint: “first” on a new empty profile, “relaunch” on one profile after a warm-up. The file cache is warm in both (clearing it needs root).
  • With 10 and 16 tabs, every tab but the front one is then discarded and the footprint read again 20 s later: through chrome://discards over the DevTools protocol, for the Browser example too (see below).
  • Chrome and Helium load a background tab opened from the command line only once it is shown, so the script shows each tab once over the DevTools protocol, then the first again. A run in which not every page loaded is kept apart and run again; those runs are left out of the medians (Chrome: 5, Helium: 6, the Browser example: none).
  • Each figure is the median of three runs (five for launch), with the range. The machine was shared with other work for part of the session; the Browser example and Chrome were measured again once it was quiet (one-minute load average 1.4 to 3.3 at the start of every run), and those are the figures given; Helium and the process-policy runs were measured while it was quiet too.
CefSwift Browser example Chrome for Testing 158.0.8127.88 Helium 0.22.5.1
App size (du) 356 MiB 377 MiB (Google Chrome 158.0.8127.89, universal: 754 MiB) 354 MiB
First launch to first paint 604 ms (513–645) 568 ms (558–592) 590 ms (570–612)
Relaunch to first paint 595 ms (511–628) 560 ms (541–566) 588 ms (572–626)
1 tab 292 MiB, 9 processes 282 MiB, 12 processes 374 MiB, 10 processes
10 tabs 843 MiB (817–845), 18 processes 864 MiB (863–864), 29 processes 856 MiB (832–903), 19 processes
10 tabs, background tabs discarded 355 MiB (352–359) 736 MiB (736–737) 443 MiB (440–518)
16 tabs 1,076 MiB (1,069–1,076), 24 processes 992 MiB (989–1,081), 37 processes 1,081 MiB (1,037–1,124), 25 processes
16 tabs, background tabs discarded 371 MiB (371–375) 862 MiB (842–919) 467 MiB
Idle CPU, 16 tabs 5.4 % (5.3–5.7) 1.2 % (1.2–1.3) 2.2 % (1.9–2.5)

Median footprint by process with 16 tabs, in MiB:

Renderers GPU process Browser process Network and storage
CefSwift Browser example 602 (19) 297 165 21
Chrome for Testing 731 (30) 98 151 27
Helium 614 (18) 278 172 21

Not measured. Safari has no separate profile: launched on this account it restores the user’s pinned tabs and tab groups, and in two tries none of the test pages reached the local server within 120 s, so it is left out; measuring it cleanly needs a macOS user account of its own. Arc on an empty profile showed no page within 120 s (it asks to sign in first) and its own profile is the user’s. Dia is not installed. Google Chrome itself was not run, because its first launch installs Google’s updater as a launch agent; Chrome for Testing is the same Chromium version without it.

Where the Browser example lost, in this run (the next section has what was done about each, and the figures since):

  • Idle CPU with many tabs: 5.4 % of a core with 16 tabs, against 1.2 % for Chrome and 2.2 % for Helium. With one tab it is 1.6 %.
  • Its GPU process grows with tabs: 112 MiB with 1 tab, 290 MiB with 10, 297 MiB with 16, against Chrome’s 60, 177 and 98. Discarding the background tabs brings it back to about 117 MiB, so the memory belongs to the background tabs. Helium shows the same growth (155, 270, 278).
  • 16 tabs: 1,076 MiB against Chrome’s 992 MiB, though with 13 fewer processes. With 10 tabs it is 21 MiB below Chrome.
  • Discarding through CefKit did not reach these tabs. In a CefChromeWindow, CefKit reported a background tab’s lifecycle as .passive or .active, and CefPage.discard() refused it with .blocked([.visible]), though Chromium lists the same tab as hidden. The discarded figures above come from Chromium’s own discarding (chrome://discards). CefChromium now tells CefKit which tab its tab strip shows, and discard() frees every background tab.
  • Launch: 595 ms to first paint on relaunch against Chrome’s 560 ms; within the spread of Helium’s.

Where it wins. With its background tabs discarded it keeps 355 MiB at 10 tabs and 371 MiB at 16, against Chrome’s 736 and 862 MiB (Chrome discarded the same tabs but kept most of their memory 20 s later) and Helium’s 443 and 467 MiB. It runs fewer processes than Chrome at every tab count, and its app is the smallest of the three Chromium apps by a few MiB.

Process policy, the Browser example with 1 and 10 tabs (relaunch, median of three):

processPolicy Processes, 1 tab 1 tab 10 tabs 10, discarded
.automatic (the .chrome preset) 9 292 MiB 843 MiB 355 MiB
.onDemand 8 281 MiB 805 MiB 339 MiB
.minimal 7 272 MiB 798 MiB 332 MiB

The spare renderer .automatic keeps is 11 MiB here, and .minimal’s network service in the app’s process another 9 MiB. Launch time did not change measurably (relaunch 609 and 582 ms, against 595 ms).

Idle CPU and the GPU process, measured again

Measured later the same day on the same Mac by the same method, the Browser example alone (Chrome and Helium were not changed, so their figures above stand), bundled with the Command Line Tools 27.2 against the macOS 27.2 SDK; raw JSON in Scripts/bench/results/2026-11-29-m2-8gb-idle.json. Before is the build with background tabs of a CefChromeWindow reported hidden (so discard(), not chrome://discards, frees them); after adds the four changes below. bench.py now also records each process’s CPU time.

Before After Chrome for Testing
Idle CPU, 1 tab 1.3 % 0.7 % 0.4 %
Idle CPU, 16 tabs 5.3 % (4.9–5.5) 4.6 % (4.1–4.8) 1.2 %
… of it the browser process 0.98 % 0.65 %
… of it renderers 4.11 % 3.85 %
GPU process, 10 tabs 290 MiB 199 MiB 177 MiB
GPU process, 16 tabs 298 MiB 207 MiB 98 MiB
10 tabs 843 MiB 756 MiB (751–761) 864 MiB
10 tabs, background tabs discarded 376 MiB 359 MiB (357–383) 736 MiB
16 tabs 1,072 MiB 986 MiB (976–1,004) 992 MiB
16 tabs, background tabs discarded 397 MiB 374 MiB (373–401) 862 MiB

What changed, each measured on its own first:

  • Chromium’s main-thread loop ran 30 times a second, always. CEF’s external message pump reports work that other threads and processes post, but not the timers Chromium’s main thread sets for itself (in an idle browser, on_schedule_message_pump_work came 0.4 to 6 times a second, never with a delay), so CefMessagePump looked for due work every 1/30 s whatever Chromium was doing, as cefclient does; each look runs CEF’s loop, which keeps going for up to 10 ms while a task is due within that time. It now looks 30 times a second for 10 s after start and for a quarter of a second after each request, and otherwise every EnergyPolicy.idleMessageLoopInterval (250 ms; nil restores 30 a second): the browser process’s idle CPU went from 0.9 to 0.4 % with 1 tab.
  • Chromium’s sampling profiler ran. Builds without Google Chrome’s branding start the ThreadProfiler for metrics CEF never uploads; Chrome for Testing turns it off. With 16 tabs, 6 of the 24 processes ran it (--start-stack-profiler), and a 25 s trace had 140 ms of sampling in renderers, about half a percent of a core. Every configuration now passes --disable-stack-profiler.
  • Hidden tabs kept their tiles. Each hidden tab whose last frame Chromium keeps for a fast switch back holds the tiles its renderer drew: 18.5 MiB each in a 1200 × 1029 window (four 2,400 × 475 GPU raster tiles, cc/tile_memory in the renderer, IOSurfaces in the GPU process). Chromium keeps up to 10 frames while memory is plentiful (ScalableFrameEviction), so 9 hidden tabs held 166 MiB; Chrome for Testing’s evictor held 5, mostly small WebUI popups, and one hidden tab’s tiles. Configuration.savedFrames = .limited, the default, turns the scaling off: 5 frames, 4 hidden tabs’ tiles. The GPU process went from 298 to 207 MiB with 16 tabs; .automatic restores Chromium’s choice.
  • The chrome://discards service host outlived the tabs it freed. discard() and discardBlockers() kept its renderer, 17 MiB, for the service hosts’ 30 s idle timeout; it now closes 3 s after the last call: 16 discarded tabs went from 397 to 374 MiB.

Checked and found as Chrome has it: background tabs are hidden in Chromium (document.visibilityState, chrome://discards), their renderers run at background priority, and their views are detached from the window; the GPU process’s swap chain is the same 56.5 MiB as Chrome’s; CefKit’s own main-thread work outside Chromium’s loop (window layout, observers) is a few milliseconds a minute.

Still behind Chrome after these four: renderers’ idle CPU with many tabs (3.9 of the 4.6 %), the GPU process with 1 tab (111 against 60 MiB) and launch (627 against 560 ms). The next section takes each.

Renderers, the GPU process, launch and timers

Measured later the same day, same Mac and method; raw JSON in Scripts/bench/results/2026-11-29-m2-8gb-round2.json.

Before After Chrome for Testing
Idle CPU, 1 tab 0.7 % 0.5 % 0.4 %
Idle CPU, 10 tabs 3.2 % 0.6 % 0.9 %
Idle CPU, 16 tabs 4.6 % (4.1–4.8) 0.9 % (0.8–0.9) 1.2 %
… of it renderers 3.85 % 0.10 %
10 tabs 756 MiB 691 MiB (686–714) 864 MiB
16 tabs 986 MiB 919 MiB (918–937) 992 MiB
16 tabs, background tabs discarded 374 MiB 376 MiB (372–376) 862 MiB
Relaunch to first paint 625 ms 617 ms (515–641) 560 ms
  • Renderers ran V8’s memory reducer half a minute into idle. A trace of each renderer (disabled-by-default-v8.gc, tasks’ posting locations) showed the same sequence in both browsers: hidden, then backgrounded, Heap::ActivateMemoryReducerIfNeeded, then a memory-reducing mark-compact. Chrome for Testing ran it 8 s after load, the Browser example 30 s after: Chrome for Testing’s renderers used LimitBasedMemoryReducer (its timer task posted with an 8 s delay), the Browser example’s the classic MemoryReducer (30 s, V8’s gc_memory_reducer_start_delay_ms). The flag (--memory-reducer-limit-based, off in V8) comes from Chrome for Testing’s field-trial configuration as the feature V8Flag_memory_reducer_limit_based. Not the cause: the off-screen window a new tab of a CefChromeWindow starts in (tabs Chromium makes itself through Target.createTarget did the same), the order in which tabs load (Chrome for Testing, given the same tabs the same way, still collected at 8 s), renderer priority (ps: background in both), and the isolate-priority features IsolatesPriorityUseProcessPriority and IsolatesPriorityBestEffortWhenHidden. Every configuration now turns the feature on: renderers’ CPU in the measured 30 s went from 3.85 to 0.10 %, and as the heaps are collected while the pages are fresh, renderers hold 539 instead of 600 MiB with 16 tabs.

  • The GPU process with 1 tab holds the same shared images as Chrome for Testing’s (86 MiB: the window’s swap chain, 56.5 MiB; the tab’s tiles; Chromium’s own UI). footprint counts the swap chain against Chrome for Testing’s GPU process only in part, because Chrome presents through the remote Core Animation API and CefKit turns it off (RemoteCoreAnimationAPI, see Presenting pages). Turned on again with CEF 158, SelfTest’s visibility checks still fail on every windowed path (8 of 26: the windows show their background), so the difference stays; it is in where the memory is counted, not in how much there is. (Those checks’ pictures were what failed, not the screen: see Launch and the GPU process.)

  • Launch. Marks from main to the first page’s load in the Browser example (median of 4 relaunches, ms after open): main 217, the application object 274, cef_initialize done 343, SwiftUI’s launch done 436, the window asked of Chromium 449, its browser created 493, the page’s load started 599, first paint 633. The service hosts that start meanwhile (bookmarks at 515, tab-strip internals at 598, extensions at 783) were held until the first page had loaded in an experiment: first paint did not move (626 and 628 ms against 626 and 659), so they stay as they are. What remains is before main and in SwiftUI’s own launch, which the Browser example waits for before it opens a window.

  • Timers (bench.py --timers: every page keeps a 50 ms interval that changes its title, a 1 s timeout chain and an animation-frame loop), 16 tabs, median of three: 43.0 % (42.3–44.9) of a core in the Browser example, 36.6 % in Chrome for Testing. Renderers took 2.2 % against Chrome’s 10.1 %, and the GPU process 5.3 % against 10.9 %; the browser process took 35.4 % against 15.4 %. Every title change (20 a second in the visible tab, one a second in each hidden one) makes Chromium update its tab strip under the app’s views and SwiftUI lay out the tab rail’s hosting view again. The address field also redrew, with every feature’s toolbar items in it, on each title change of the visible page; it now reads a page’s title only for an internal page, which took the browser process from 38.6 to 35.4 % (45.6 to 43.0 % in all). The rest is SwiftUI’s layout of the window’s top bar (NSHostingView transactions, about a third of the main thread) and Chromium’s own work, about another third. IntensiveWakeUpThrottling, Chromium’s one-wake-up-a-minute limit, applies only to pages hidden for 5 minutes, so this measurement does not show it; neither browser changes Chromium’s default for it.

    Measured again (2026-11-29, one run each), most of the browser process’s time is neither SwiftUI nor Chromium’s own work but CEF’s external message pump waiting. cef_do_message_loop_work runs Chromium’s tasks for up to 10 ms and does not return while a task is due within that time: it polls. A title change in a Chromium-drawn window repaints its tab strip, and the frame that follows keeps tasks coming (the display link, raster tasks finishing, the frame’s deadline), so each change costs one slice of exactly 10 ms. Timing every call: about 28 such slices a second, 1.4 s of every 5 s, with 16 timer tabs; one tab changing its title 20 times a second alone makes 20 to 27 a second. A Chromium trace of that one tab shows 0.28 s of tasks in 6 s (tab strip paint and layout, one frame per change): the rest of the slices is the polling. An Alloy page changing its title as often (the Minimal example) makes none, as nothing of Chromium’s redraws. With Chrome’s own UI shown and the app’s top bar left out the process took 32.1 %, against 35.9 % with it, so the top bar is about 4 points. Not running a slice within 100 ms of one that polled to its end (an experiment, not kept: it delays Chromium’s main thread) took the browser process to 18.1 %. Getting under Chrome needs Chromium’s own message loop (cef_run_message_loop, which waits in the run loop as Chrome does) rather than the external pump: see Chromium’s own message loop. Two smaller changes stay. CefKit applies titles and icons at most once a frame for all pages together (CefDisplayUpdates). The Browser example’s tab title and tooltip are views of their own, so a title change updates its text, not the tab’s body. Neither moves this measurement, because the 10 ms slices already batch what arrives within them. Chromium’s tab icon is not animating on its own here: in the trace, TabIcon::UpdateThrobber runs only in the paint after each title change, and no tab reports loading.

Chromium’s own message loop

Measured on 2026-11-29 with CEF 158 on the same M2 (8 GB, macOS 27.2), the Browser example, three runs each, median and range unless noted; the loop was then an option (-messageLoop chromium). It is now the default, in Chrome’s arrangement: see Chrome’s arrangement in SwiftUI.

Where the polling is. cef_do_message_loop_work runs RunLoop::RunUntilIdle on CEF’s MessagePumpExternal (libcef/browser/browser_message_loop.cc), made with a time slice of 0.01 s. Its Run calls DoWork in a loop and leaves only once the next task’s run time is more than 10 ms after the slice began. A delayed task due inside that window is waited for by calling DoWork again and again, and with no task queued at all the loop runs out the full 10 ms. Chromium’s own pumps (MessagePumpCFRunLoopBase, MessagePumpNSApplication) take no part while the external pump is in use, and the 10 ms is CEF’s constant, not Chromium’s. A frame of a Chrome-style window posts tasks a few milliseconds apart (begin frame, deadline, raster replies), so each title change keeps a slice polling to its end.

An embedder decides only when a slice starts. Honouring delay_ms exactly, coalescing requests to the display’s refresh, or ignoring the requests made during a slice shorten no slice: the waiting happens inside the call, for tasks posted during it. Starting fewer slices does (18.1 % in the experiment above) by running Chromium’s tasks late. The external pump is therefore unchanged.

Chromium’s loop. CefRuntime.Configuration.messageLoop = .chromium runs cef_run_message_loop() inside the app’s run loop (architecture). Chromium then wakes the main thread through a run loop source and a timer set for its next task, as in Chrome. bench.py --timers, 16 tabs:

CPU, % of a core External pump Chromium’s loop Chrome for Testing
Browser process 37.7 (34.9–39.8) 22.7 (22.0–24.2) 15.4
GPU process 5.2 (5.0–5.5) 9.3 (9.2–10.0) 10.9
Renderers 2.3 (1.9–2.5) 3.8 (3.1–4.1) 10.1
All processes 45.3 (42.9–46.9) 36.3 (34.5–38.2) 36.6

The GPU process and the renderers do more because frames are no longer held up behind the polling: each title change’s frame of Chromium’s window is drawn when it is due. The browser process stays above Chrome’s. A 10 s sample of its main thread with Chromium’s loop found it waiting 58 % of the time; of the rest, about half was Chromium’s tasks and over a third SwiftUI’s hosting-view transactions for the tab rail (resolving and drawing the changed titles, then laying out the rail’s scroll view), at 20 changes a second in the visible tab and one a second in each other. Chrome draws one tab strip; the Browser example draws its own and keeps Chromium’s, under its views, drawing too.

Nothing else measured got worse:

  • Input to paint (SelfTest -benchmark frames -frameTiming "chromium timer", an offscreen page at 60 Hz, 40 mouse moves to the frame that shows each, two launches of two runs): median 16.1 to 19.0 ms, 90th percentile 22.2 to 26.1 ms, against 15.3 to 19.4 ms and 22.5 to 25.7 ms with the external pump.
  • A round trip to a renderer (-benchmark evaluate, 2000 evaluateJavaScript calls returning an integer, two runs): 0.063 to 0.072 ms each, against 0.068 to 0.090 ms.
  • Launch (bench.py, first launch and relaunch to first contentful paint, 12 of each, the two loops alternating): 624 and 593 ms, against 606 and 595 ms. Sixteen tabs loaded in 5.0 to 5.3 s, against 5.7 to 7.0 s.
  • Idle CPU, 16 tabs without timers, the two loops alternating: 1.5 % (0.7–1.6) of a core in all, the browser process 0.8 %, against 1.8 % (1.3–2.0) and 1.2 %. Another app kept the load average between 4.5 and 6 meanwhile, so both are above the 0.9 % measured on a quiet Mac earlier.
  • SelfTest: the whole suite run with Chromium’s loop passed 1390 of 1391 checks; the one failure was a probe crashing as it quit, a probe that runs with the external pump and failed the same way in another run of the unchanged suite. The lifecycle group now starts a probe with Chromium’s loop and checks that pages load, titles arrive, and that Chromium has shut down when willTerminate arrives.

It was not the default then. Started from inside the app’s run loop, the app’s own -[NSApplication run] stayed below Chromium’s loop for the rest of the process, so -[NSApplication stop:] no longer ended it. Ending the loop also makes Chromium post NSApplicationWillTerminateNotification itself, which CefKit drops by swapping NSNotificationCenter’s post method for the duration of cef_quit_message_loop().

What the CPU and memory changes cost a person

Each change above that lowers CPU or memory was measured again for what someone using the app would notice: frame pacing, timers, a click’s latency, a title’s latency, switching to a page that was hidden, and a page’s edges while SwiftUI resizes it. Measured on 2026-11-29 on the same M2 (8 GB, macOS 27.2.1, a 60 Hz display, so 120 Hz is not measured), CEF 158.0.6, with SelfTest’s -benchmark ux: a windowed page in SelfTest’s window; 180 animation frames; forty 10 ms timeouts; fifteen clicks and fifteen title changes, each after a quiet second, so the message loop has slowed to its idle interval; eight pages shown one at a time, each time the one hidden longest, timed to its first animation frame and to its colour on screen in pictures of the window; and five springs of resizeEdges. One run of each setting, settings switched through the environment (SELFTEST_SAVED_FRAMES, SELFTEST_DISABLE_FEATURES, SELFTEST_ENERGY); the default ran twice. Chrome for Testing 158.0.8127.88 ran the same pages (raf, timeouts, eight tabs activated over the DevTools protocol’s HTTP endpoint) twice.

Default (two runs) savedFrames = .automatic Limit-based memory reducer off EnergyPolicy.disabled Chrome for Testing (two runs)
Animation frame interval, median 16.7 ms 16.7 ms 16.7 ms 16.7 ms 16.7 ms
Frames over 25 ms in 3 s 1, 0 of 180 1 1 1 0, 0 of 181
10 ms timeout lateness, median 2.6, 5.0 ms 3.0 ms 4.0 ms 4.9 ms 3.2, 5.0 ms
Click to its handler, median (max) 1.3 (6.0), 0.3 (1.9) ms 1.4 (3.3) ms 1.3 (3.8) ms 0.4 (2.1) ms
Title to CefPage.title, median, the script’s round trip included 1.1, 1.5 ms 1.1 ms 1.6 ms 0.4 ms
Page hidden longest of 8, shown: first animation frame, median 2.1, 0.6 ms 1.7 ms 0.7 ms 0.4 ms 4.9, 2.3 ms (from the activation request)
… on screen, median (max) 10.5 (26.8), 4.7 (11.1) ms 11.4 (17.1) ms 5.7 (15.6) ms 5.1 (21.3) ms
… pictures without the page first 0, 0 0 2 0
Spring resize: pictures with a white bar 0 of 455, 0 of 466 0 of 457 0 of 463 0 of 465

The spread between the two default runs is as large as any difference between settings, so none of these settings shows a cost here. Verdicts:

Change What it could cost Measured Verdict
Idle message-loop interval, 250 ms (EnergyPolicy.idleMessageLoopInterval) A timer Chromium’s main thread sets for itself runs up to 250 ms late Clicks, titles, page switches, frames and resize edges within the default runs’ spread of .disabled’s Kept. Timers of Chromium’s own UI (tooltips, hover cards) are not measured here; the loop is being reworked separately
--disable-stack-profiler Nothing a person sees: the profiler samples call stacks for metrics CEF never uploads No path to frames or input; Chrome for Testing passes it too Kept
savedFrames = .limited A page hidden longer than the four last hidden draws again before it shows 8 pages: on screen as fast as with .automatic, no picture without the page in either Kept
chrome://discards host closes 3 s after its last call The next discard() after 3 s starts the host again Not on a path a person waits on (no frame, input or navigation) Kept
V8’s limit-based memory reducer Collections of hidden pages’ heaps 8 s after load rather than 30 s Frames, timers and clicks of the visible page as with it off; Chrome for Testing runs the same flag Kept
Titles and icons applied once a frame (CefDisplayUpdates) A second title within a frame waits for the next 1 to 2 ms from document.title to CefPage.title Kept
The Browser example’s address field reads titles of internal pages only Nothing: it shows other pages’ addresses — Kept
Background tabs of a CefChromeWindow reported hidden Nothing: Chromium already treated them as hidden — Kept

What did show a cost was older than these changes: a windowed page growing under an animation showed white bars along its trailing and bottom edges on a quarter of the pictures, with every setting above alike, fixed in CefWindowedPageView (Presenting pages). Offscreen pages under EnergyPolicy draw at 30 frames a second in Low Power Mode or under thermal pressure, a reduction made before these changes and documented with the policy.

Chrome’s arrangement in SwiftUI

Measured on 2026-11-29 with CEF 158.0.6 on the same M2 (8 GB, macOS 27.2.1), against Chrome for Testing 158.0.8127.88, while other work kept the load average between 3 and 5. Scripts/bench/ux.py: a measuring page in front, changing its title every 50 ms, and 15 of bench.py’s timer pages behind it, as bench.py --timers with 16 tabs; three runs of each browser, alternating, median.

Chromium’s loop below the app’s. Chrome calls -[NSApplication run] from inside Chromium’s message loop (MessagePumpNSApplication::DoRun finds NSApp not running). CefKit now does the same: -[CefApplication run] runs cef_run_message_loop(), which calls run again, and the override runs AppKit’s loop (architecture). A sample of the Browser example’s main thread shows Chrome’s stack under SwiftUI’s App.main(). stop: ends both loops and run() returns, as without Chromium; a later run() starts both again. SelfTest’s lifecycle group checks both: a nested run() ended by stop:, and (probe stopRun) the outermost one, run again from main, with pages answering after each. With stop: working, Chromium’s loop became the default in the library and in the Browser example; .external stays for an app that starts the runtime after its run loop or does not want that loop wrapped. The whole SelfTest suite with it as the default passed 1445 of 1453 checks; the eight failures were the systemPrompts group’s watch, which counted any call with Chromium’s frames below it, and so AppKit’s own NSUserNotificationCenter call as the app finishes launching. With that call left out, the group passes.

Where the browser process’s time went. A 10 s sample of the main thread in each, share of samples:

Main thread Chromium’s loop, before After Chrome for Testing
Waiting 66 % 75 % 85 %
Chromium’s tasks 13 % 13 % 11 %
AppKit’s display cycle (layout, drawing, Core Animation commit) 7 % 7 % 1 %
SwiftUI transactions (NSHostingView) 10 % 1 % –

Chromium’s own work costs about what it costs in Chrome. The rest was the Browser example’s tab rail: each title change of a page, 20 a second in front and one a second in each tab behind it, was a SwiftUI transaction of the window’s top bar, laid out in the next display cycle. The rail now draws a tab’s title with an AppKit view of its own (TabTitle, an NSViewRepresentable that follows the title with Observation, outside SwiftUI, with a fixed height so a new title never lays the rail out again); its tooltip and VoiceOver label follow a title that keeps changing at most once a second, all tabs’ together on one deadline (SettledTitle). A title shown with SwiftUI’s Text and a change applied once per display frame (CefDisplayUpdates) was not enough: each frame with a change was still a transaction. What is left of the display cycle is mostly AppKit’s own work for the window title Chromium sets on each change (-[NSWindow _dosetTitle:], which Chrome pays too) and drawing the titles. CefChromium also stopped saving the session file when only a title changed (it did once a second here).

Results, ux.py, three runs each (range in brackets):

CEF’s external pump (before) Chromium’s loop, after Chrome for Testing
Browser process CPU, % of a core 35.3 (34.1–37.3) 21.6 (20.6–21.7) 16.8 (16.7–16.9)
All processes CPU, % 41.6 (40.7–43.3) 34.0 (32.6–34.1) 34.6 (33.7–35.0)
Browser process wake-ups a second 19 47 (39–51) 32
Frames dropped: page in front (5 s), scrolling, resizing 0, 0, 0 0, 0, 0 0, 0, 0
Frame interval, 99th percentile, ms 18.7 18.5 16.8
setTimeout(16) late, median / 95th percentile, ms 2.0 / 2.6 2.0 / 2.2 2.1 / 2.2
Key press round trip (Input.dispatchKeyEvent), median / 95th, ms 0.8 / 2.6 1.4 / 4.6 1.6 / 4.6
Key press to the frame showing it, median / 95th, ms 0.5 / 0.9 1.1 / 1.9 1.0 / 1.7

An earlier round, with the tooltips’ once-a-second deadline kept per tab, gave 20.1 % against Chrome’s 14.3 % for the browser process and 32.1 % against 31.3 % for all. Chromium’s loop with the old rail took the browser process to 23.6 % (22.5–24.6, two runs) and all processes to 33.7 %. The input figures go through the DevTools protocol and so through the browser’s main thread; the external pump answers fastest because it polls, which is what costs it the CPU. Frame intervals are the same in every CefSwift configuration, 18.2 to 18.7 ms at the 99th percentile against Chrome’s 16.8, with no frame dropped under load in either: a difference in when frames start, not in how many, and not from the message loop. The browser process wakes more often than Chrome’s under this load, though its CPU time is lower than before; which of its threads wake was not measured (it needs powermetrics, which needs root).

Idle, ux.py --quiet (the measuring page alone, nothing changing), two runs each, 30 s:

CEF’s external pump (before) Chromium’s loop, after Chrome for Testing
Browser process CPU, % 0.74 0.43 0.62
All processes CPU, % 0.83 0.53 1.29
Browser process wake-ups a second 6.9 1.7 4.0

Idle, nothing ticks: the external pump’s quarter-second look is gone, and the browser process wakes less than Chrome’s.

Chromium’s own timers. SelfTest -benchmark chromiumTimers: a timer posted from inside a Chromium main-thread task, as Chromium’s code sets them, after 400 ms of quiet:

Delay Chromium’s loop, late: median / 95th, ms External pump
1 ms 0.6 / 15.3 0.2 / 0.5
16 ms 0.7 / 7.7 5.7 / 27.5
50 ms 7.7 / 8.9 0.5 / 21.5
100 ms 7.0 / 9.4 0.7 / 15.2
250 ms 7.1 / 9.0 0.2 / 5.6

Twenty timers of each delay, one run each. With Chromium’s loop, longer timers run about 7 ms late, the same with --disable-features=AlignWakeUps. That came from how the benchmark was started, not from Chromium: see Closing the gaps to Chrome. The external pump is closer to the time in the median because it keeps looking 30 times a second for a quarter of a second after each request, which is what it spends its CPU on, and later in the tail.

Still above Chrome. Under this load the browser process stays about 5 points above Chrome’s, all processes level. What that was, and what closed most of it, is in the next section.

Closing the gaps to Chrome

Measured on 2026-11-29 with CEF 158.0.6 on the same M2 (8 GB, macOS 27.2.1), against Chrome for Testing 158.0.8127.88, ux.py as above. Four gaps were left: the browser process’s CPU, its wake-ups, frame intervals at the 99th percentile, and Chromium’s main-thread timers. Per-thread CPU came from proc_pidinfo (PROC_PIDTHREADINFO), wake-ups from proc_pid_rusage, and where the time went from sample; without root there is no per-thread wake-up count, so each suspect was taken out in turn and the wake-ups measured again.

Chromium’s tab strip cannot be left out. CEF’s headers have no setting for it: get_chrome_toolbar_type and CEF_SHOW_STATE_* apply to a CefWindow, whose Chromium window is a popup with no tabs. In Chromium (read on main), View::SchedulePaintInRectImpl stops at a hidden view, but the tab strip’s views have no NSView and nothing outside Chromium can hide them; occlusion is per window (kNotifyCompositorOfWindowOcclusionOnMacOs, off by default), and the page is in the same window. Collapsed vertical tabs (vertical_tabs.collapsed_state) give a title no size, but a zero-size view still asks for a commit, and the strip would move the page. Chrome paints its own strip too, so this is equal work, not extra: the browser’s raster thread (CompositorTileWorker1) took 2.2 % against Chrome’s 2.1 %.

The app’s own drawing. Taking parts out of the Browser example one at a time, one run each, browser process:

Taken out CPU, % Wake-ups / s
Nothing 22.2 42.6
Chromium’s setTitle: of the window 20.6 45.8
Redrawing the tab titles 19.7 32.8
Tooltip and VoiceOver label updates 21.9 40.8
All three 18.5 31.5

Every change of a title on screen cost the main thread a wake-up of its own, whoever drew it: with the title drawn by a CATextLayer instead of an NSView the CPU fell and the wake-ups did not. On macOS 26 and later a change to a layer waits for the next display frame (UC::DriverCore in the samples) and wakes the main thread for it. A transaction of the label’s own (CATransaction.begin() and commit()), alone in its pass of the run loop, goes to the screen at once, while the thread is awake: 36 and 39 wake-ups a second against 42 to 54 without it (CATransaction.flush() gave 32 to 41). With other changes pending it waits for them, so nothing reaches the screen half done. Drawn this way, the title also skips AppKit’s display cycle: layout, the window’s drag regions, which ask every view in the title bar, SwiftUI’s hosting views included, and drawRect:.

Chromium sets the window’s title on every change of the active tab’s (-[NSWindow setTitle:]): AppKit then lays out the title bar, works out the drag regions again and runs a display cycle, for a title the window does not show. CefChromium applies it at once after a quiet second and at most once a second while it keeps changing, the last one always (SelfTest tabs). The window’s title is its name in the Window menu, Mission Control and VoiceOver, none of which follows a title changing 20 times a second.

CefDisplayUpdates asked for the next pass of the run loop with asyncAfter(deadline: .now()), a timer; it uses async when there is nothing to wait for. Not measurable alone.

Frame intervals. Chrome’s GPU process has no CVDisplayLink thread; CefSwift’s had one. Chromium’s CADisplayLinkInGpu (off by default in Chromium’s code) takes the display’s refresh from a CADisplayLink on the compositor thread; turned on in CefSwift, its GPU process has the threads Chrome for Testing’s has (no CVDisplayLink, a WindowServerEventPumpThread), so Chrome runs with it. With CVDisplayLink, a frame’s time was now and then up to 2 ms off the refresh (intervals of 14.7 and 18.7 ms in pairs), whatever the main thread did; with CADisplayLink every interval was 16.6 to 16.8 ms. It is not on by default: with it, windowed pages showed white bars along the growing edges during SelfTest resizeEdges’ springs (16 of 269 and 13 of 273 pictures, bars up to 82 px), which the frame sized ahead and the cover of the growth cover (CefWindowedGrowthCover) keep at 0 with CVDisplayLink. Sizing ahead by 250 ms widened the bars (to 201 px) and a 250 ms cover left 7 of 273, so frames at a new size come back later with it than the cover can wait for. An app without animated windowed pages can list it in enabledFeatures.

Chromium’s main-thread timers. The 7 ms was macOS’s timer coalescing for a process that was not launched as an app: SelfTest run from a shell. A run loop timer of SelfTest’s own, without tolerance, was as late (-benchmark chromiumTimers now measures one beside Chromium’s). --enable-features=AddTaskLeeway:leeway/0ms changed nothing, and Chromium asks the run loop for a delayed task’s exact time (MessagePump::AdjustDelayedRunTime snaps it only with AlignWakeUps; CFRunLoopTimerSetTolerance is called only with TimerSlackMac, both off). Launched with open, as a person launches it, three runs, late by (median of the runs’ medians / 95th percentiles):

Delay Chromium’s timer, launched, ms The app’s run loop timer, launched, ms Chromium’s timer, started from a shell, ms
1 ms 0.20 / 1.18 0.36 / 1.53 0.66 / 3.79
4 ms 0.16 / 1.09 1.04 / 1.10 2.05 / 2.14
16 ms 0.35 / 2.09 1.02 / 4.31 1.09 / 7.42
50 ms 0.50 / 2.24 1.92 / 3.17 6.69 / 10.02
100 ms 0.18 / 2.15 1.99 / 2.37 3.52 / 9.31
250 ms 0.39 / 2.26 2.07 / 3.12 4.72 / 8.91

Chromium’s main-thread timers run within half a millisecond of their time in the median, closer than a plain run loop timer of the app’s. Nothing in CefSwift needed changing. The shell column is one run; the earlier table in this section was measured the same way.

Results, ux.py, three runs of each, alternating, median. ux.py shows Chrome’s background tabs again when some have not loaded; even so Chrome loaded 11, 14 and 3 of the 15 in the three runs (another app took the load average to 12 in the third), and a page that has not loaded runs no timers, so Chrome’s CPU figures are low. CefSwift loaded all 15 each time.

Before (Chromium’s loop, previous section) After Chrome for Testing
Browser process CPU, % of a core 22.4 (18.6–22.5) 20.5 (18.2–21.0) 16.3 (16.1–16.9)
All processes CPU, % 35.4 34.0 33.7
Browser process wake-ups a second 40.2 (36.9–41.0) 27.6 (22.6–27.9) 32.1 (27.5–38.4)
Frames dropped: page in front (5 s), scrolling, resizing 0, 0, 0 0 (one in one run), 0, 0 0 (one in one run), 0, 0
Frame interval, 99th percentile: page, scrolling, resizing, ms 18.6, 18.7, 17.7 16.8, 16.8, 16.8 16.8, 16.8, 16.8
setTimeout(16) late, median / 95th, ms 2.1 / 2.4 2.1 / 2.7 2.1 / 2.6
setTimeout(100) late, median / 95th, ms 2.3 / 2.9 2.3 / 2.9 2.4 / 2.9
Key press round trip, median / 95th, ms 1.5 / 5.9 1.5 / 4.2 1.6 / 3.9
Key press to the frame showing it, median / 95th, ms 0.7 / 1.2 0.6 / 1.1 0.7 / 1.1

The After column ran with CADisplayLinkInGpu on; as shipped it is off, and frame intervals at the 99th percentile are as Before. An earlier set of three runs, before ux.py showed Chrome’s tabs again, gave the same picture: browser process 20.0, 20.7 and 15.9 %; wake-ups 43.4, 27.1 and 33.6; frame intervals at the 99th percentile 18.6, 16.8 and 16.8 ms.

What is left. The browser process still takes more CPU than Chrome’s under this load. A sample at 10 ms intervals, 15 s each, all 15 pages loaded in both, had its main thread busy in 129 samples against Chrome’s 100: Chromium’s own tasks about the same (84 against 77, ours including the app’s), the rest drawing the app’s tab titles (20) and AppKit’s display cycle. Chromium’s hidden tab strip draws every title as Chrome’s does, and the app draws it again; leaving either out would change what a person sees. Taking the tooltips’ once-a-second update out did not move the CPU measurably.

Launch and the GPU process, like with like

Measured on 2026-11-29 on the same M2 (8 GB, macOS 27.2.1), CEF 158.0.6, against Chrome for Testing 158.0.8127.88, with Chromium’s own message loop the default; raw JSON in Scripts/bench/results/2026-11-29-m2-8gb-launch-gpu.json. Other work kept the one-minute load average between 1.9 and 9 during these runs; each figure says what it ran beside.

The launch figures had a cost of the script’s own. bench.py started the Browser example with open --stdin <FIFO> --stdout <file> --stderr <file>, which its discard command needs, and the other browsers with a plain open -n -a. Handing standard input and output to an app through open moves everything after it later. The same build, both ways, ten relaunches each, alternating with Chrome for Testing (load average 5.9 to 9.0):

Milliseconds after open, median Through a FIFO Plain open Chrome for Testing
GPU process starts 237 194 189
First renderer starts 461 436 325
Navigation starts (performance.timeOrigin) 451 427 343
Request sent 504 472 479
First contentful paint 589 564 583

bench.py now starts every browser with a plain open -n -a for launch runs and quits the Browser example by its pid, as the others; the FIFO stays for the tab runs, which send commands. Launch by bench.py, two rounds of five each, the browsers one after the other (load average 3.0 to 6.4 for the Browser example, 3.4 to 3.8 for Chrome for Testing):

Before (the FIFO, above) Now Chrome for Testing
First launch to first paint 624 ms 565 ms (491–643) 570 ms (542–645)
Relaunch to first paint 593 ms 506 ms (453–600) 587 ms (559–654)

Where the time goes. In the first table: Chrome for Testing navigates 84 ms sooner, then waits about 135 ms for its request; the Browser example sends its request 45 ms after navigating, and its first paint follows its response sooner. Marks inside the Browser example (a timestamp written at each step, an experiment not kept; median of five relaunches, ms after open): main 118, cef_initialize called 189, returned 258, applicationWillFinishLaunching 261, applicationDidFinishLaunching 344, the window asked of Chromium 379, its browser created 417, navigation 424. A 1 ms sample of the first second puts most of the 83 ms between the two launch notifications in SwiftUI building the main menu from the scene’s commands (AppKitMainMenuItem.updateMainMenu, which also loads the Writing Tools framework for the Edit menu’s text items) and AppKit showing the menu bar. Chrome for Testing navigates before NSApplication finishes launching (applicationWillFinishLaunching at 387 ms, after its navigation at 352 ms).

Tried and not kept:

  • Opening the first window before SwiftUI’s launch, right after cef_initialize, with cef_browser_host_create_browser_sync (an asynchronous create runs only once the run loop does, after SwiftUI’s launch): navigation at 362 against 402 ms and first paint 30 ms sooner after cef_initialize (median of eight), but the window shows with Chromium’s own tab strip and toolbar before the app’s views are over them. The same at applicationWillFinishLaunching gained nothing measurable: creating the browser synchronously takes about 90 ms of the main thread there.
  • Linking the framework at launch is not what makes launch slow. A C program in an app bundle, launched with open, reaches main in 17 ms; linked to the framework, in 42 ms; loading it with dlopen in main, as Chrome does, costs 33 ms there. The Browser example’s executable reaches main 46 to 67 ms after open when it stops there (eight runs). Its main process and Chrome for Testing’s load about the same images (1,163 and 1,209). In full launches the time before main varied from 45 to 190 ms; with arguments after --args it was the longer in 13 of 14 runs, against 0 of 11 without, but applicationDidFinishLaunching came no later (357 to 480 ms, against 270 to 650), so the time moved rather than added up, which points at LaunchServices finishing the launch, not at the executable. Chrome for Testing’s GPU process started 165 to 216 ms after open, the Browser example’s 135 to 330 ms.

The GPU process. With one tab, footprint counts 112 MiB against Chrome for Testing’s 64 MiB. Region by region (footprint -v, one run each, 20 s after load):

GPU process, MiB Swap chain (three 2400 × 2058 IOSurfaces) Other IOSurfaces (tiles, Chromium’s UI) PartitionAlloc and Metal (App-Specific Tag 14) Total
Browser example, 1 tab 56.5 29.5 12 112
Chrome for Testing, 1 tab 0 of 56.5 30 21 65
Browser example, 10 tabs 56.5 105.5 17 200
Chrome for Testing, 10 tabs 0 of 56.5 118 19 158

Both have the same three swap-chain surfaces, the window’s size at 2×. Chrome for Testing’s are mapped in its GPU process but not resident there (vmmap: 86.1 MiB of IOSurface mapped, 29.5 MiB resident), because it presents through the remote Core Animation API, which CefKit turned off; the same surfaces then counted against the GPU process. Everything else is the same or smaller in the Browser example: its tiles and Chromium’s UI take 12 MiB less with 10 tabs.

The remote Core Animation API works. CefKit had turned it off because pictures of the app’s own windows showed no page with it on. A picture a process takes of its own window leaves out what another process draws into it; screencapture -l of the same window, from a process of its own, shows the page, as it does for Chrome for Testing (Presenting pages). With SelfTest’s visibility group looking through ScreenCaptureKit, all 18 checks pass with the feature on and with it off. Stamping the executables with the SDK they were built against (cef bundle records the deployment target in its place, as SwiftPM’s Swift Build backend links them; swiftc alone records the SDK) changed nothing here, so cef bundle is unchanged. CefKit now leaves the feature at Chromium’s default, on. With one tab the Browser example’s GPU process then counts 53 MiB, against Chrome for Testing’s 63.

ux.py, three runs of each, alternating, load average 2.4 to 4.7 (the same build; off passes --disable-features=RemoteCoreAnimationAPI):

On Off Chrome for Testing
Browser process CPU, % of a core 22.1 (21.9–22.4) 22.5 (22.3–23.0) 16.7 (16.3–16.8)
All processes CPU, % 34.4 (34.4–35.1) 35.5 (35.3–35.9) 34.2 (33.6–34.6)
Browser process wake-ups a second 49.7 (49.0–55.8) 39.9 (38.9–41.6) 29.6 (27.6–36.0)
Frame interval, 99th percentile: page, scrolling, resizing, ms 18.6, 18.7, 18.6 18.5, 18.7, 18.3 16.8, 16.8, 16.8
Frames dropped (5 s, scrolling, resizing) 0, 0, 0 0, 0, 0 0, 0, 0
setTimeout(16) late, median, ms 2.1 2.0 2.1
Key press round trip, median / 95th, ms 1.6 / 5.6 1.4 / 4.3 1.3 / 3.9
Key press to the frame showing it, median / 95th, ms 0.7 / 1.2 0.6 / 1.1 0.6 / 1.1

Frames are paced the same either way, so the 99th percentile’s 1.8 ms above Chrome’s does not come from presenting through the browser process. The browser process wakes about 10 times a second more with the feature on, for less CPU; the key press’s 95th percentile is within the runs’ spread (4.9 to 8.2 ms on, 4.3 to 5.2 off).

Memory by bench.py, median and range of two runs (load average 1.7 to 6.5): the Browser example with the remote Core Animation API off (as before) and on (now). In one of Chrome for Testing’s two 10-tab runs only 6 tabs loaded after three tries, so its 10-tab figures are the one complete run and, in brackets, the footprint -v run above:

Browser example, off Browser example, on Chrome for Testing
1 tab 288 MiB (288–291), GPU process 111 MiB 228 MiB, GPU process 53 MiB 283 MiB (278–288), GPU process 63 MiB
10 tabs 701 MiB (700–702), GPU process 200 MiB 627 MiB (624–629), GPU process 140 MiB 833 MiB (709), GPU process 143 MiB (158)
10 tabs, background tabs discarded 324 MiB (310–337) 255 MiB (251–259) 701 MiB
16 tabs 922 MiB (903–941), GPU process 207 MiB 842 MiB (841–843), GPU process 148 MiB 1,096 MiB (1,073–1,118), GPU process 170 MiB (154–186)
16 tabs, background tabs discarded 357 MiB (354–360) 282 MiB (272–292) 921 MiB (919–922)

Launch above was measured with the feature off, and not again with it on.

Was this page helpful?