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