[Fix] (trace-replay): pass ANGLE path to APK retrace

This commit is contained in:
2026-06-22 12:30:10 +08:00
parent 565dc90bf0
commit 252e59334d
6 changed files with 47 additions and 6 deletions
+2 -1
View File
@@ -39,6 +39,7 @@ crop_y optional compare crop y
crop_width optional compare crop width
crop_height optional compare crop height
use_angle optional boolean; DirectGLES uses packaged ANGLE when true
angle_library_dir optional directory containing libEGL_angle.so and libGLESv2_angle.so; defaults to the APK native library directory
```
Implementation notes:
@@ -49,7 +50,7 @@ Implementation notes:
- `DirectGLES` replays on an EGL pbuffer by default, avoiding Android `SurfaceView` lifetime coupling. `DirectVulkan` still uses the Activity surface because it needs a native window-backed Vulkan swapchain.
- Golden comparison is implemented in native C++ with libpng RGBA decode. The Java Activity only passes arguments and displays the native result, so the replay/compare core is not tied to Android UI or Bitmap APIs and can be ported to Linux.
- The plugin profile still excludes `libtrace_replay_runner.so`; normal plugin APK behavior is preserved.
- Set `MOBILEGL_RETRACE_USE_ANGLE=1` when running `trace-replay-ci.sh` to pass `use_angle=true` for DirectGLES. The APK must include `libEGL_angle.so` and `libGLESv2_angle.so` under its x86_64 native libraries.
- Set `MOBILEGL_RETRACE_USE_ANGLE=1` when running `trace-replay-ci.sh` to pass `use_angle=true` for DirectGLES. The APK must include `libEGL_angle.so` and `libGLESv2_angle.so` under its x86_64 native libraries. The Activity passes Android's `nativeLibraryDir` to native code as `MOBILEGL_RETRACE_ANGLE_DIR`.
Example core-profile trace smoke command for a debug trace APK:
@@ -129,6 +129,12 @@ bool LoadMobileGL(const Request& request, std::string& error) {
setenv("MOBILEGL_TRACE_SKIP_AUTODESTROY", "1", 1);
if (UseAngleForRequest(request)) {
setenv("MOBILEGL_RETRACE_USE_ANGLE", "1", 1);
if (!request.angleLibraryDir.empty()) {
setenv("MOBILEGL_RETRACE_ANGLE_DIR", request.angleLibraryDir.c_str(), 1);
}
} else {
unsetenv("MOBILEGL_RETRACE_USE_ANGLE");
unsetenv("MOBILEGL_RETRACE_ANGLE_DIR");
}
void* handle = dlopen(request.mobileGlLibrary.c_str(), RTLD_NOW | RTLD_GLOBAL);
@@ -738,6 +744,7 @@ bool WriteResultJson(const Request& request, const Result& result) {
file << " \"actualPath\": \"" << JsonEscape(result.actualPath) << "\",\n";
file << " \"diffPath\": \"" << JsonEscape(result.diffPath) << "\",\n";
file << " \"backend\": \"" << JsonEscape(request.backend) << "\",\n";
file << " \"angleLibraryDir\": \"" << JsonEscape(request.angleLibraryDir) << "\",\n";
file << " \"targetFrame\": " << request.targetFrame << ",\n";
file << " \"targetCall\": " << request.targetCall << ",\n";
file << " \"width\": " << request.width << ",\n";
@@ -23,6 +23,7 @@ struct Request {
std::string diffPath;
std::string backend;
std::string mobileGlLibrary = "libMobileGL.so";
std::string angleLibraryDir;
int targetFrame = -1;
long long targetCall = -1;
int width = 0;
@@ -99,6 +99,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
jint cropWidth,
jint cropHeight,
jint fuzzPercent,
jstring angleLibraryDir,
jboolean useAngle) {
mobilegl_trace::Request request;
request.tracePath = ToString(env, tracePath);
@@ -110,6 +111,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
request.outputDir = ToString(env, outputDir);
request.diffPath = ToString(env, diffPath);
request.backend = ToString(env, backend);
request.angleLibraryDir = ToString(env, angleLibraryDir);
request.targetFrame = targetFrame;
request.targetCall = targetCall;
request.width = width;
@@ -44,6 +44,7 @@ public final class TraceReplayActivity extends Activity {
request = TraceReplayRequest.from(
intent,
getFilesDir(),
getApplicationInfo().nativeLibraryDir,
getString(top.mobilegl.plugin.R.string.mobilegl_default_backend)
);
statusView = new TextView(this);
@@ -111,6 +112,7 @@ public final class TraceReplayActivity extends Activity {
request.cropWidth,
request.cropHeight,
request.fuzzPercent,
request.angleLibraryDir,
request.useAngle
);
Log.i(TAG, result.toString());
@@ -139,6 +141,7 @@ public final class TraceReplayActivity extends Activity {
int cropWidth,
int cropHeight,
int fuzzPercent,
String angleLibraryDir,
boolean useAngle
);
@@ -159,6 +162,7 @@ public final class TraceReplayActivity extends Activity {
final int cropWidth;
final int cropHeight;
final int fuzzPercent;
final String angleLibraryDir;
final boolean useAngle;
private TraceReplayRequest(
@@ -178,6 +182,7 @@ public final class TraceReplayActivity extends Activity {
int cropWidth,
int cropHeight,
int fuzzPercent,
String angleLibraryDir,
boolean useAngle
) {
this.tracePath = tracePath;
@@ -196,10 +201,11 @@ public final class TraceReplayActivity extends Activity {
this.cropWidth = cropWidth;
this.cropHeight = cropHeight;
this.fuzzPercent = fuzzPercent;
this.angleLibraryDir = angleLibraryDir;
this.useAngle = useAngle;
}
static TraceReplayRequest from(Intent intent, File filesDir, String defaultBackend) {
static TraceReplayRequest from(Intent intent, File filesDir, String nativeLibraryDir, String defaultBackend) {
String outputDir = readString(intent, "output_dir", new File(filesDir, "trace-replay").getAbsolutePath());
String diffPath = readString(intent, "diff_path", "");
return new TraceReplayRequest(
@@ -219,6 +225,7 @@ public final class TraceReplayActivity extends Activity {
intent.getIntExtra("crop_width", 0),
intent.getIntExtra("crop_height", 0),
intent.getIntExtra("fuzz_percent", 20),
readString(intent, "angle_library_dir", nativeLibraryDir),
intent.getBooleanExtra("use_angle", false)
);
}