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:
parent
8cd34a80ff
commit
50efc18ec5
10 changed files with 1268 additions and 14 deletions
58
windows/test/run_tests.sh
Executable file
58
windows/test/run_tests.sh
Executable 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 ]
|
||||
3
windows/test/shim/VersionHelpers.h
Normal file
3
windows/test/shim/VersionHelpers.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// Kitedesk fork, 2026: test-only stand-in for <VersionHelpers.h> (windows/test).
|
||||
// The plugin includes it but uses nothing from it. Licensed under the Apache
|
||||
// License, Version 2.0, like the rest of this package.
|
||||
63
windows/test/shim/flutter_windows.h
Normal file
63
windows/test/shim/flutter_windows.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// Kitedesk fork, 2026: test-only stand-in for flutter_windows.h of the Flutter
|
||||
// Windows engine (a18df97c) with the declarations that the client wrapper's
|
||||
// plugin_registrar_windows.h and flutter_view.h use; windows/test defines them.
|
||||
// Licensed under the Apache License, Version 2.0, like the rest of this
|
||||
// package.
|
||||
|
||||
#ifndef KD_TEST_SHIM_FLUTTER_WINDOWS_H_
|
||||
#define KD_TEST_SHIM_FLUTTER_WINDOWS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "flutter_export.h"
|
||||
#include "flutter_messenger.h"
|
||||
#include "flutter_plugin_registrar.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct IDXGIAdapter;
|
||||
|
||||
struct FlutterDesktopView;
|
||||
typedef struct FlutterDesktopView* FlutterDesktopViewRef;
|
||||
|
||||
typedef int64_t FlutterDesktopViewId;
|
||||
|
||||
typedef bool (*FlutterDesktopWindowProcCallback)(HWND /* hwnd */,
|
||||
UINT /* uMsg */,
|
||||
WPARAM /*wParam*/,
|
||||
LPARAM /* lParam*/,
|
||||
void* /* user data */,
|
||||
LRESULT* result);
|
||||
|
||||
FLUTTER_EXPORT HWND FlutterDesktopViewGetHWND(FlutterDesktopViewRef view);
|
||||
|
||||
FLUTTER_EXPORT struct IDXGIAdapter* FlutterDesktopViewGetGraphicsAdapter(
|
||||
FlutterDesktopViewRef view);
|
||||
|
||||
FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(
|
||||
FlutterDesktopPluginRegistrarRef registrar);
|
||||
|
||||
FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetViewById(
|
||||
FlutterDesktopPluginRegistrarRef registrar,
|
||||
FlutterDesktopViewId view_id);
|
||||
|
||||
FLUTTER_EXPORT void
|
||||
FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate(
|
||||
FlutterDesktopPluginRegistrarRef registrar,
|
||||
FlutterDesktopWindowProcCallback delegate,
|
||||
void* user_data);
|
||||
|
||||
FLUTTER_EXPORT void
|
||||
FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate(
|
||||
FlutterDesktopPluginRegistrarRef registrar,
|
||||
FlutterDesktopWindowProcCallback delegate);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // KD_TEST_SHIM_FLUTTER_WINDOWS_H_
|
||||
17
windows/test/shim/windows.h
Normal file
17
windows/test/shim/windows.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Kitedesk fork, 2026: test-only stand-in for <windows.h>, so that the plugin
|
||||
// and the engine's C++ client wrapper build on Linux for windows/test. It has
|
||||
// only the types those headers use. Licensed under the Apache License,
|
||||
// Version 2.0, like the rest of this package.
|
||||
|
||||
#ifndef KD_TEST_SHIM_WINDOWS_H_
|
||||
#define KD_TEST_SHIM_WINDOWS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct HWND__* HWND;
|
||||
typedef unsigned int UINT;
|
||||
typedef uintptr_t WPARAM;
|
||||
typedef intptr_t LPARAM;
|
||||
typedef intptr_t LRESULT;
|
||||
|
||||
#endif // KD_TEST_SHIM_WINDOWS_H_
|
||||
1002
windows/test/texture_rgba_renderer_plugin_test.cc
Normal file
1002
windows/test/texture_rgba_renderer_plugin_test.cc
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue