flutter_texture_rgba_renderer/macos/Classes
yunchan 7af0d01118 macos: take frame buffers from a pool, keep the two last handed (Kitedesk T-4204)
Every frame made a new IOSurface-backed CVPixelBuffer (33 MB at 4K), and
the engine let it go soon after. R T-4201 measured 2.2 to 7.8 ms per 4K
frame alone, up to 110 ms, and a 6.5 ms median at 60 fps; upstream #16922
saw 37% of the CPU and memory swings of 1.85 to 2.43 GB.

Frames now go into the buffers of a CVPixelBufferPool with IOSurface
properties, made again when the frame size changes. A pool hands a buffer
out again as soon as nobody holds it, even while its IOSurface backs a live
Metal texture (measured), and engine a18df97c lets go of the pixel buffer and
of its CVMetalTexture as soon as it has the Metal texture, which Skia then
draws until the next frame. So the texture keeps the buffers it last handed
to the engine: the one drawn, and the one drawn before it, which GPU work
queued meanwhile may still read (the plugin cannot see when the GPU is done,
flutter#157379; inferred). With the newest frame and the one being written, a
texture uses three buffers while the engine keeps up and four when it falls
behind.

Tests: pool_reuses_buffers passes (60 IOSurfaces for 60 frames of a size,
now at most 4). drawn_frame_is_not_overwritten fails when no handed buffer
is kept, frame_drawn_before_is_not_overwritten when one is; both pass with
two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:56:22 +09:00
..
TextRgba.swift macos: take frame buffers from a pool, keep the two last handed (Kitedesk T-4204) 2026-11-15 09:56:22 +09:00
TextureRgbaApi.m fix memory leak on macOS (#9) 2023-03-14 12:44:36 +08:00
TextureRgbaRendererPlugin.swift Refact/stride align (#8) 2023-03-03 09:46:33 +08:00