macos: drain an autorelease pool around each frame (Kitedesk T-4204)

FlutterRgbaRendererPluginOnRgba runs on the caller's thread, a Kitedesk
video thread, which has no autorelease pool and lives as long as the
session: an object autoreleased there would stay until the session ends
(pointed out in upstream PR #2). Each frame now runs in an @autoreleasepool.

On macOS 26.5.2 the frame path autoreleases nothing on that thread, before
and after this series (frames_leave_no_autoreleased_objects passes on
50efc18e too), so this is a guard: a probe saw CoreVideo autorelease objects
when a process first made an IOSurface on such a thread, and the engine's
registrar logs with NSLog for a frame announced to it after its engine is
gone, which the old code did on the video thread.

Tests: 13 of 13 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yunchan 2026-11-15 09:52:53 +09:00
parent 6c3425539f
commit b87d45fd09

View file

@ -4,6 +4,9 @@
// //
// Created by kingtous on 2023/2/19. // Created by kingtous on 2023/2/19.
// //
// Modified by the Kitedesk fork (2026, T-4204): an autorelease pool around
// each frame.
//
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "texture_rgba_renderer/texture_rgba_renderer-Swift.h" #import "texture_rgba_renderer/texture_rgba_renderer-Swift.h"
@ -14,9 +17,13 @@ extern "C" {
/// Keep the same name with Windows. /// Keep the same name with Windows.
void FlutterRgbaRendererPluginOnRgba(void* texture_rgba_ptr, const uint8_t* buffer, int len, int width, int height, int stride_align) { void FlutterRgbaRendererPluginOnRgba(void* texture_rgba_ptr, const uint8_t* buffer, int len, int width, int height, int stride_align) {
// The caller's thread, a session's video thread, has no autorelease pool and
// lives as long as the session.
@autoreleasepool {
TextRgba* texture_rgba = (__bridge TextRgba *)(texture_rgba_ptr); TextRgba* texture_rgba = (__bridge TextRgba *)(texture_rgba_ptr);
[texture_rgba markFrameAvaliableRawWithBuffer:buffer len:len width:width height:height stride_align: stride_align]; [texture_rgba markFrameAvaliableRawWithBuffer:buffer len:len width:width height:height stride_align: stride_align];
} }
}
#if __cplusplus #if __cplusplus
} //Extern C } //Extern C