G26: keep Windows textures alive through asynchronous unregister

Retain closed raw-pointer identities for late frames, release frame buffers
after engine completion, and serialize termination with decoded frame writes.
Add native regression controls for held raster buffers, inline completion,
failed raster posts, missing registrations, teardown and concurrent closure.

B252; Apache-2.0 dependency license and upstream history preserved.
This commit is contained in:
yunchan 2026-10-29 12:13:44 +09:00
parent 8cd34a80ff
commit 50efc18ec5
10 changed files with 1268 additions and 14 deletions

58
windows/test/run_tests.sh Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Kitedesk fork, 2026: builds windows/test/texture_rgba_renderer_plugin_test.cc
# on Linux with the plugin sources and the C++ client wrapper of the Flutter
# Windows engine, and runs each test in its own process. The engine files come
# from FLUTTER_WINDOWS_ENGINE, by default the windows-x64 engine artifacts of the
# Flutter SDK on PATH (or FLUTTER_ROOT) as `flutter precache --windows` leaves
# them: the C headers and cpp_client_wrapper/. No display, GPU or Windows needed.
# run_tests.sh -Wall -Werror build
# run_tests.sh --asan the same with AddressSanitizer and UBSan
# run_tests.sh --tsan the same with ThreadSanitizer
# OUT_DIR (default: a new temporary directory) receives the test binary.
set -euo pipefail
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
if [ -z "${FLUTTER_WINDOWS_ENGINE:-}" ]; then
root=${FLUTTER_ROOT:-$(dirname "$(dirname "$(readlink -f "$(command -v flutter)")")")}
FLUTTER_WINDOWS_ENGINE=$root/bin/cache/artifacts/engine/windows-x64
fi
engine=$FLUTTER_WINDOWS_ENGINE
wrapper=$engine/cpp_client_wrapper
[ -f "$engine/flutter_texture_registrar.h" ] && [ -f "$wrapper/core_implementations.cc" ] || {
echo "no Flutter Windows engine headers and client wrapper in $engine" \
"(flutter precache --windows, or set FLUTTER_WINDOWS_ENGINE)" >&2
exit 2
}
out=${OUT_DIR:-$(mktemp -d)}
mkdir -p "$out"
# The client wrapper headers expect <cstdint> to come with the standard headers,
# as MSVC's do; libstdc++'s do not.
flags=(-std=c++17 -Wall -Werror -O1 -g -pthread -include cstdint -DFLUTTER_PLUGIN_IMPL '-D__declspec(x)=')
case "${1:-}" in
"") ;;
--asan) flags+=('-fsanitize=address,undefined' -fno-omit-frame-pointer -fno-sanitize-recover=undefined) ;;
--tsan)
flags+=(-fsanitize=thread)
export TSAN_OPTIONS=${TSAN_OPTIONS:-halt_on_error=1}
;;
*) echo "usage: $0 [--asan | --tsan]" >&2; exit 2 ;;
esac
bin=$out/texture_rgba_renderer_plugin_test
"${CXX:-clang++}" "${flags[@]}" -I"$here/shim" -I"$wrapper/include" -I"$engine" \
"$here/texture_rgba_renderer_plugin_test.cc" \
"$here/../texture_rgba.cpp" "$here/../texture_rgba_renderer_plugin.cpp" \
"$here/../texture_rgba_renderer_plugin_c_api.cpp" \
"$wrapper/core_implementations.cc" "$wrapper/plugin_registrar.cc" "$wrapper/standard_codec.cc" \
-o "$bin"
count=0
failed=0
for test in $("$bin" --list); do
count=$((count + 1))
if "$bin" "$test"; then
echo "PASS $test"
else
echo "FAIL $test"
failed=$((failed + 1))
fi
done
echo "$count tests, $((count - failed)) passed, $failed failed"
[ "$failed" -eq 0 ]