Commit graph

13 commits

Author SHA1 Message Date
2c334da6f9 macos: copy rows of another stride one by one (Kitedesk T-4204)
FlutterRgbaRendererPluginOnRgba gets rows padded to stride_align, and the
pixel buffer has its own bytes per row ((width * 4 + 63) & ~63 on Apple
Silicon). The frame was copied in one memcpy of len bytes, so rows came out
shifted whenever the two differ: Kitedesk sends stride_align 1 for a session
drawn in software, whose "all displays" view still uses textures, and any
width that is not a multiple of 16 then shears (1366, 1001, 1279, 3838). A
stride above the pixel buffer's wrote past its data.

Rows are now copied one by one, width * 4 bytes each, when the strides
differ, and in one memcpy of the rows otherwise. A frame shorter than its
rows promise is dropped instead of being read past its end.

Tests: rows_follow_the_frame_stride and short_frames_are_dropped pass; the
other eight that failed still do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:56:22 +09:00
9a377b6155 macos: add headless texture tests (Kitedesk T-4204)
Standalone Objective-C tests for the macOS texture, built against
FlutterMacOS.framework of the active Flutter SDK by macos/test/run_tests.sh
(optionally with ASan or TSan). The plugin sources are compiled into the
test; the plugin registers through a fake plugin registrar and is driven
through handleMethodCall:result:. The fake engine follows
FlutterTextureRegistrar.mm and FlutterExternalTexture.mm of engine a18df97c:
the texture id is the texture's address, the registrar keeps registered
textures, and copyPixelBuffer is wrapped into a Metal texture whose
CVMetalTexture and pixel buffer are released at once while the Metal texture
stays drawn. Frames come through FlutterRgbaRendererPluginOnRgba on a thread
without an autorelease pool. Memory is the task's phys_footprint, which counts
IOSurfaces, read after the engine's CVMetalTextureCache has let go of what it
wrapped (it keeps that until it makes a texture a second later, measured);
it is not checked under ASan, whose shadow of each new IOSurface mapping
counts in it. No app, window or screen capture.

On 50efc18e ten of the thirteen tests fail (Mac mini M4, macOS 26.5.2):
every frame gets a new IOSurface (60 for 60 frames), the raster thread waits
for the copy (median 0.9 to 1.1 ms in three runs, up to 537 of 600 calls over
1 ms, with 4K frames), frames are announced off the main thread, closed
textures keep their last frame (634 MB more after 20 4K textures) and still
take and announce late frames, a texture closed with recycle is never freed,
and rows of another stride than the pixel buffer's are copied in one piece
(shifted rows for 1366, 1001, 1279 and 3838 pixels wide with stride_align 1,
and 1001 with 256), short frames included. The two tests on frames the engine
was handed pass, as no buffer is ever written twice yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:56:22 +09:00
fufesou
b91e1b2092
fix memory leak on macOS (#9)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-14 12:44:36 +08:00
fufesou
8d66a7c55e
Refact/stride align (#8)
* rename row_align_bytes  to stride_align

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* trivail changes

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-03 09:46:33 +08:00
fufesou
873919902e
Feat/row align bytes (#7)
* better bytes alignment

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* debug macos

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* debug linux

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* windows switch_rgba

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* better switch_rgba

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-03 09:30:05 +08:00
fufesou
044bb260d9
add stride_align for onRgba (#6)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-02 21:38:55 +08:00
Kingtous
4f059a9138 fix: macos ptr access 2023-02-19 23:22:40 -08:00
Kingtous
6fd900c479 feat: texture rgba interface 2023-02-19 19:14:48 -08:00
Kingtous
71e77ef3cf fix: metal issue on macos 2023-02-17 22:23:39 +08:00
Kingtous
0e16af448c opt: add doc for macOS 2023-02-17 01:52:16 -08:00
Kingtous
4221adb1cb feat: initial macos 2023-02-17 01:35:25 -08:00
Kingtous
1f012dffac add: macos impl 2023-02-17 00:55:21 -08:00
Kingtous
b2bd5910e7 feat: init repo 2023-02-16 15:03:12 +08:00