closeTexture marked the texture terminated but kept the frame last handed to
the engine and any frame still waiting, and TextureRgba had no finalize, so
each closed session kept one or two frame-sized buffers forever (2 x
width x height x 4 bytes measured per 1080p session).
terminate now frees both buffers under the texture mutex: the texture is
already unregistered and OnRgba stops copying once terminated is set. A
finalize frees them as well. GObject and GL lifetime are unchanged here.
Tests: close_frees_frame_buffers, closed_texture_ignores_late_frames,
finalize_frees_frame_buffers and frames_racing_close pass (also under ASan);
the four recycling tests still fail.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Standalone C++ tests for the Linux texture, built against the engine of the
active Flutter SDK by linux/test/run_tests.sh (optionally with ASan/UBSan).
The plugin source is compiled into the test and driven through a real
FlMethodChannel on fake engine objects (binary messenger, texture registrar
with the reference rules of engine a18df97c, plugin registrar); frame
buffers copied with new[] are counted.
On 42797e0f eight of the ten tests fail: closing a texture keeps both frame
buffers, the GObject has no finalize, and closed textures are never reused,
so every session leaves a frame buffer and an engine GL texture behind.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>