[Fix] (trace-replay): stabilize ANGLE retrace cases

This commit is contained in:
2026-07-08 01:07:20 +08:00
parent 292576d2a1
commit 83d475eb02
7 changed files with 92 additions and 12 deletions
@@ -149,6 +149,11 @@ bool LoadMobileGL(const Request& request, std::string& error) {
unsetenv("MOBILEGL_RETRACE_USE_ANGLE");
unsetenv("MOBILEGL_RETRACE_ANGLE_DIR");
}
if (request.avoidAngleLlvmpipeSamplerMipmapMinFilter) {
setenv("MOBILEGL_ANGLE_LLVMPIPE_AVOID_SAMPLER_MIPMAP_MIN_FILTER", "1", 1);
} else {
unsetenv("MOBILEGL_ANGLE_LLVMPIPE_AVOID_SAMPLER_MIPMAP_MIN_FILTER");
}
void* handle = dlopen(request.mobileGlLibrary.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (handle == nullptr) {
@@ -870,6 +875,8 @@ bool WriteResultJson(const Request& request, const Result& result) {
file << " \"ssimThreshold\": " << request.ssimThreshold << ",\n";
file << " \"useAngle\": " << (UseAngleForRequest(request) ? "true" : "false") << ",\n";
file << " \"usePbuffer\": " << (request.usePbuffer ? "true" : "false") << ",\n";
file << " \"avoidAngleLlvmpipeSamplerMipmapMinFilter\": "
<< (request.avoidAngleLlvmpipeSamplerMipmapMinFilter ? "true" : "false") << ",\n";
file << " \"holdMs\": " << request.holdMs << ",\n";
file << " \"mismatchPixels\": " << result.mismatchPixels << "\n";
file << "}\n";
@@ -35,6 +35,7 @@ struct Request {
double ssimThreshold = 0.99;
bool useAngle = false;
bool usePbuffer = true;
bool avoidAngleLlvmpipeSamplerMipmapMinFilter = false;
int holdMs = 0;
};
@@ -100,7 +100,8 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
jint cropHeight,
jstring angleLibraryDir,
jboolean useAngle,
jboolean usePbuffer) {
jboolean usePbuffer,
jboolean avoidAngleLlvmpipeSamplerMipmapMinFilter) {
mobilegl_trace::Request request;
request.tracePath = ToString(env, tracePath);
request.goldenPath = ToString(env, goldenPath);
@@ -123,6 +124,8 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
request.cropHeight = cropHeight;
request.useAngle = useAngle == JNI_TRUE;
request.usePbuffer = usePbuffer == JNI_TRUE;
request.avoidAngleLlvmpipeSamplerMipmapMinFilter =
avoidAngleLlvmpipeSamplerMipmapMinFilter == JNI_TRUE;
ScopedTraceReplayState replayState;
mobilegl_trace_set_requested_size(request.width, request.height);
@@ -113,7 +113,8 @@ public final class TraceReplayActivity extends Activity {
request.cropHeight,
request.angleLibraryDir,
request.useAngle,
request.usePbuffer
request.usePbuffer,
request.avoidAngleLlvmpipeSamplerMipmapMinFilter
);
Log.i(TAG, result.toString());
TraceReplayResult finalResult = result;
@@ -142,7 +143,8 @@ public final class TraceReplayActivity extends Activity {
int cropHeight,
String angleLibraryDir,
boolean useAngle,
boolean usePbuffer
boolean usePbuffer,
boolean avoidAngleLlvmpipeSamplerMipmapMinFilter
);
private static final class TraceReplayRequest {
@@ -164,6 +166,7 @@ public final class TraceReplayActivity extends Activity {
final String angleLibraryDir;
final boolean useAngle;
final boolean usePbuffer;
final boolean avoidAngleLlvmpipeSamplerMipmapMinFilter;
private TraceReplayRequest(
String tracePath,
@@ -183,7 +186,8 @@ public final class TraceReplayActivity extends Activity {
int cropHeight,
String angleLibraryDir,
boolean useAngle,
boolean usePbuffer
boolean usePbuffer,
boolean avoidAngleLlvmpipeSamplerMipmapMinFilter
) {
this.tracePath = tracePath;
this.goldenPath = goldenPath;
@@ -203,6 +207,7 @@ public final class TraceReplayActivity extends Activity {
this.angleLibraryDir = angleLibraryDir;
this.useAngle = useAngle;
this.usePbuffer = usePbuffer;
this.avoidAngleLlvmpipeSamplerMipmapMinFilter = avoidAngleLlvmpipeSamplerMipmapMinFilter;
}
static TraceReplayRequest from(Intent intent, File filesDir, String nativeLibraryDir, String defaultBackend) {
@@ -226,7 +231,8 @@ public final class TraceReplayActivity extends Activity {
intent.getIntExtra("crop_height", 0),
readString(intent, "angle_library_dir", nativeLibraryDir),
intent.getBooleanExtra("use_angle", false),
intent.getBooleanExtra("use_pbuffer", false)
intent.getBooleanExtra("use_pbuffer", false),
intent.getBooleanExtra("avoid_angle_llvmpipe_sampler_mipmap_min_filter", false)
);
}
+36
View File
@@ -18,6 +18,7 @@ Usage:
--trace-file FILE_IN_ARCHIVE \
--golden FILE \
[--alternate-golden FILE] \
[--angle-library-dir DIR] \
--target-call N \
--width N \
--height N \
@@ -27,12 +28,15 @@ Usage:
--crop-width N \
--crop-height N \
[--use-pbuffer] \
[--avoid-angle-llvmpipe-sampler-mipmap-min-filter] \
--timeout-seconds N
Set MOBILEGL_RETRACE_USE_ANGLE=1 to run DirectGLES replay with packaged ANGLE
instead of the device system GLES driver.
Set MOBILEGL_RETRACE_USE_PBUFFER=1 or pass --use-pbuffer to run DirectGLES
against an offscreen EGL pbuffer instead of the Activity surface.
Pass --avoid-angle-llvmpipe-sampler-mipmap-min-filter for DirectGLES traces that
need ANGLE llvmpipe sampler mipmap filters downgraded to avoid driver stalls.
EOF
}
@@ -79,6 +83,7 @@ trace_archive=""
trace_file=""
golden_path=""
alternate_golden_path=""
angle_library_dir=""
target_call=""
width=""
height=""
@@ -88,6 +93,7 @@ crop_y=""
crop_width=""
crop_height=""
use_pbuffer=0
avoid_angle_llvmpipe_sampler_mipmap_min_filter=0
timeout_seconds=""
while [ "$#" -gt 0 ]; do
@@ -110,6 +116,7 @@ while [ "$#" -gt 0 ]; do
shift 2
fi
;;
--angle-library-dir) angle_library_dir="$(next_arg "$@")"; shift 2 ;;
--target-call) target_call="$(next_arg "$@")"; shift 2 ;;
--width) width="$(next_arg "$@")"; shift 2 ;;
--height) height="$(next_arg "$@")"; shift 2 ;;
@@ -119,6 +126,10 @@ while [ "$#" -gt 0 ]; do
--crop-width) crop_width="$(next_arg "$@")"; shift 2 ;;
--crop-height) crop_height="$(next_arg "$@")"; shift 2 ;;
--use-pbuffer) use_pbuffer=1; shift 1 ;;
--avoid-angle-llvmpipe-sampler-mipmap-min-filter)
avoid_angle_llvmpipe_sampler_mipmap_min_filter=1
shift 1
;;
--timeout-seconds) timeout_seconds="$(next_arg "$@")"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) die "unknown argument: $1" ;;
@@ -150,6 +161,10 @@ test -f "${golden_path}" || die "golden image does not exist: ${golden_path}"
if [ -n "${alternate_golden_path}" ]; then
test -f "${alternate_golden_path}" || die "alternate golden image does not exist: ${alternate_golden_path}"
fi
if [ -n "${angle_library_dir}" ]; then
test -f "${angle_library_dir}/libEGL_angle.so" || die "ANGLE override is missing libEGL_angle.so: ${angle_library_dir}"
test -f "${angle_library_dir}/libGLESv2_angle.so" || die "ANGLE override is missing libGLESv2_angle.so: ${angle_library_dir}"
fi
safe_case="$(printf '%s' "${case_name}" | sed 's/[^A-Za-z0-9._-]/_/g')"
app_dir="/data/user/0/${package_name}/files/trace-replay"
@@ -188,10 +203,18 @@ prepare_fixture() {
if [ -n "${alternate_golden_path}" ]; then
adb_device_path push "$(host_path_for_adb "${alternate_golden_path}")" "/data/local/tmp/mobilegl-${safe_case}.alternate-golden.png"
fi
if [ -n "${angle_library_dir}" ]; then
adb_device_path push "$(host_path_for_adb "${angle_library_dir}/libEGL_angle.so")" "/data/local/tmp/mobilegl-${safe_case}.libEGL_angle.so"
adb_device_path push "$(host_path_for_adb "${angle_library_dir}/libGLESv2_angle.so")" "/data/local/tmp/mobilegl-${safe_case}.libGLESv2_angle.so"
fi
adb_device_path shell chmod 0644 "/data/local/tmp/mobilegl-${safe_case}.trace" "/data/local/tmp/mobilegl-${safe_case}.golden.png"
if [ -n "${alternate_golden_path}" ]; then
adb_device_path shell chmod 0644 "/data/local/tmp/mobilegl-${safe_case}.alternate-golden.png"
fi
if [ -n "${angle_library_dir}" ]; then
adb_device_path shell chmod 0644 "/data/local/tmp/mobilegl-${safe_case}.libEGL_angle.so" \
"/data/local/tmp/mobilegl-${safe_case}.libGLESv2_angle.so"
fi
}
copy_fixture_to_app() {
@@ -206,6 +229,13 @@ copy_fixture_to_app() {
if [ -n "${alternate_golden_path}" ]; then
adb_device_path shell run-as "${package_name}" cp "${alternate_golden_tmp}" "${app_dir}/input/alternate-golden.png"
fi
if [ -n "${angle_library_dir}" ]; then
adb_device_path shell run-as "${package_name}" mkdir -p "${app_dir}/angle"
adb_device_path shell run-as "${package_name}" cp "/data/local/tmp/mobilegl-${safe_case}.libEGL_angle.so" \
"${app_dir}/angle/libEGL_angle.so"
adb_device_path shell run-as "${package_name}" cp "/data/local/tmp/mobilegl-${safe_case}.libGLESv2_angle.so" \
"${app_dir}/angle/libGLESv2_angle.so"
fi
}
run_retrace() {
@@ -236,10 +266,16 @@ run_retrace() {
fi
if [ "${use_angle}" -eq 1 ]; then
set -- "$@" --ez use_angle true
if [ -n "${angle_library_dir}" ]; then
set -- "$@" --es angle_library_dir "${app_dir}/angle"
fi
fi
if [ "${use_pbuffer}" -eq 1 ] && [ "${backend}" = "DirectGLES" ]; then
set -- "$@" --ez use_pbuffer true
fi
if [ "${avoid_angle_llvmpipe_sampler_mipmap_min_filter}" -eq 1 ] && [ "${backend}" = "DirectGLES" ]; then
set -- "$@" --ez avoid_angle_llvmpipe_sampler_mipmap_min_filter true
fi
set -- "$@" \
--es output_dir "${app_dir}/output" \
--es diff_path "${app_dir}/output/${safe_case}-diff.png" \