B252: keep closed textures valid until the engine is done with them
Windows: closeTexture hands the texture to UnregisterTexture's callback and frees its frame buffers there; frames pushed after close are dropped. Without "recycle" the object is kept for the process lifetime (the session may still hold its pointer); an engine that shuts down keeps its open textures the same way. A duplicate createTexture key gets -1, getTexturePtr of an unknown key 0. macOS: closeTexture drops the frame and closes the texture to later frames; only "recycle" removes it from the plugin. Linux: the frame handed to the engine last is freed at that engine's next copy_pixels or once the engine has shut down, not at close: from Flutter 3.32 the raster thread can still be uploading it. Tests: windows/test/run_tests.sh (plain, --asan, --tsan) and linux/test/run_tests.sh (plain, --asan). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8cd34a80ff
commit
f38b9420ac
15 changed files with 1388 additions and 31 deletions
|
|
@ -4,6 +4,9 @@
|
|||
//
|
||||
// Created by kingtous on 2023/2/17.
|
||||
//
|
||||
// Modified by the Kitedesk fork (2026, B252): close() drops the frame and
|
||||
// every frame pushed afterwards.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import FlutterMacOS
|
||||
|
|
@ -15,6 +18,7 @@ import CoreVideo
|
|||
private var data: CVPixelBuffer?
|
||||
private var width: Int = 0
|
||||
private var height: Int = 0
|
||||
private var closed = false
|
||||
private let queue = DispatchQueue(label: "text_rgba_sync_queue")
|
||||
|
||||
public static func new(registry: FlutterTextureRegistry?) -> TextRgba {
|
||||
|
|
@ -33,7 +37,19 @@ import CoreVideo
|
|||
}
|
||||
}
|
||||
|
||||
// Called by closeTexture. The session may keep pushing frames to the
|
||||
// pointer from getTexturePtr; they are dropped.
|
||||
func close() {
|
||||
queue.sync {
|
||||
closed = true
|
||||
data = nil
|
||||
}
|
||||
}
|
||||
|
||||
private func _markFrameAvaliable(buffer: UnsafePointer<UInt8>, len: Int, width: Int, height: Int, stride_align: Int) -> Bool {
|
||||
if closed {
|
||||
return false
|
||||
}
|
||||
var pixelBufferCopy: CVPixelBuffer?
|
||||
// macOS only support 32BGRA currently.
|
||||
let dict: [String: Any] = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue