From 2a36975b628b043090b5373aed5987f7329ad48c Mon Sep 17 00:00:00 2001 From: yunchan Date: Sun, 15 Nov 2026 09:47:57 +0900 Subject: [PATCH] macos: announce frames on the main queue (Kitedesk T-4204) textureFrameAvailable was called on the thread that pushed the frame, a Kitedesk video thread. The engine wants it on the platform thread (Shell::OnPlatformViewMarkTextureFrameAvailable checks it, engine a18df97c), as it wants registerTexture and unregisterTexture, which already run there; Kitedesk's own GPU texture (KdMatoyaTexture.swift) posts its notices the same way. The notice is now posted to the main queue; the registry is only used on the main thread. Tests: frames_are_announced_on_the_main_thread passes. Co-Authored-By: Claude Opus 5.5 --- macos/Classes/TextRgba.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/macos/Classes/TextRgba.swift b/macos/Classes/TextRgba.swift index 9737716..ba405be 100644 --- a/macos/Classes/TextRgba.swift +++ b/macos/Classes/TextRgba.swift @@ -8,7 +8,7 @@ // IOSurface-backed buffers of a pool, which does not hand out again the // buffers last handed to the engine, and are copied outside the queue the // raster thread waits on; rows are copied one by one when their stride -// differs from the pixel buffer's. +// differs from the pixel buffer's; frames are announced on the main queue. // import Foundation @@ -17,6 +17,7 @@ import CoreVideo @objc public class TextRgba: NSObject, FlutterTexture { public var textureId: Int64 = -1 + // Main thread only. private var registry: FlutterTextureRegistry? private var data: CVPixelBuffer? private var width: Int = 0 @@ -80,7 +81,10 @@ import CoreVideo self.data = pixelBufferCopy } if textureId != -1 { - registry?.textureFrameAvailable(textureId) + // On the platform (main) thread, which the engine checks. + DispatchQueue.main.async { + self.registry?.textureFrameAvailable(self.textureId) + } return true } else { return false