Commit graph

17 commits

Author SHA1 Message Date
f38b9420ac 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>
2026-10-27 03:19:05 +09:00
8cd34a80ff linux: recycle closed textures per engine, closeTexture(recycle:) (Kitedesk B212)
Each session created a new TextureRgba and closeTexture never released it, so
the engine's FlPixelBufferTexture kept its GL texture (one frame of GPU or,
with llvmpipe, process memory per session). Releasing the object is not safe:
FlPixelBufferTexture deletes its GL texture in dispose without selecting a GL
context, so a release from another window deletes that window's texture of
the same name (upstream PR #2 turned the remaining window white).

closeTexture(key, recycle: true) now keeps the texture in a list of the
plugin instance, i.e. of the engine (window) that created it, and the next
createTexture of that engine registers it again. Its GL texture is only ever
touched by that engine's populate in its own context, nothing is released,
and the GL memory is bounded by the number of textures a window had open at
once. When the engine goes away the recycled textures stay referenced for the
same reason. Without recycle (old callers, or a tab that moves to another
window while its session still holds the pointer) a closed texture stays
terminated and is never handed out again.

With no frame waiting, copy_pixels hands out one transparent pixel instead
of no buffer, so a recycled texture cannot show the last frame of its previous
session before the first new frame.

Dart: closeTexture(int key, {bool recycle = false}) sends "recycle"; other
platforms ignore it. Tests: all ten Linux lifecycle tests pass (clang and
gcc, -Wall -Werror, also under ASan/UBSan); Dart 4/4.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 15:38:06 +09:00
21pages
96ed6df4a9 remove switch rgba
Signed-off-by: 21pages <sunboeasy@gmail.com>
2024-11-26 22:02:57 +08:00
Kingtous
bca854ff18 opt: remove len check 2023-03-25 21:34:25 +08:00
Kingtous
785c34f36b bump: 0.0.15 2023-03-23 23:34:09 +08:00
fufesou
8d66a7c55e
Refact/stride align (#8)
* rename row_align_bytes  to stride_align

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* trivail changes

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-03 09:46:33 +08:00
fufesou
873919902e
Feat/row align bytes (#7)
* better bytes alignment

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* debug macos

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* debug linux

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* windows switch_rgba

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* better switch_rgba

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-03 09:30:05 +08:00
Kingtous
8208587b23 refactor: use instance instead 2023-02-28 19:25:22 +08:00
Kingtous
bcd8fad1c0 refactor: change to pixel rgba 2023-02-28 17:00:48 +08:00
Kingtous
c37336cd9b opt: try to fix the memory corrupt issue on Linux 2023-02-28 15:37:20 +08:00
Kingtous
c3297dfd05 opt: move unordered_map to the global 2023-02-28 10:52:59 +08:00
Kingtous
686d6edaa5 fix: linux read on write 2023-02-21 16:39:28 +08:00
Kingtous
4bdb5b430e fix: memory leak on Linux 2023-02-19 14:44:08 +08:00
Kingtous
35e480aa73 fix: may memory issue on linux 2023-02-18 19:17:07 +08:00
Kingtous
3e42db31d1 fix: linux syn 2023-02-18 19:10:08 +08:00
Kingtous
3d549cb70b opt: hardware accleration texture on Linux 2023-02-16 16:30:11 +08:00
Kingtous
b2bd5910e7 feat: init repo 2023-02-16 15:03:12 +08:00