[Feat] (trace-replay): test retrace APK on Android

This commit is contained in:
2026-06-16 14:07:33 +08:00
parent 294dad1773
commit 722bddf916
11 changed files with 191 additions and 9 deletions
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22.1)
project(trace_replay_runner)
set(APITRACE_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../../third_party/apitrace")
set(APITRACE_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../../../3rdparty/apitrace")
set(APITRACE_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/apitrace")
set(APITRACE_VERSION "mobilegl-trace")
@@ -28,18 +28,21 @@ jobject MakeResult(JNIEnv* env, const mobilegl_trace::Result& result) {
if (clazz == nullptr) {
return nullptr;
}
jmethodID ctor = env->GetMethodID(clazz, "<init>", "(ZILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
jmethodID ctor = env->GetMethodID(clazz, "<init>",
"(ZILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
if (ctor == nullptr) {
return nullptr;
}
jstring message = env->NewStringUTF(result.message.c_str());
jstring resultPath = env->NewStringUTF(result.resultPath.c_str());
jstring actualPath = env->NewStringUTF(result.actualPath.c_str());
jstring diffPath = env->NewStringUTF(result.diffPath.c_str());
jobject object = env->NewObject(clazz, ctor, result.passed ? JNI_TRUE : JNI_FALSE, result.statusCode, message,
resultPath, actualPath);
resultPath, actualPath, diffPath);
env->DeleteLocalRef(message);
env->DeleteLocalRef(resultPath);
env->DeleteLocalRef(actualPath);
env->DeleteLocalRef(diffPath);
return object;
}
@@ -52,6 +55,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
jstring tracePath,
jstring goldenPath,
jstring outputDir,
jstring diffPath,
jstring backend,
jint targetFrame,
jlong targetCall,
@@ -67,6 +71,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
request.tracePath = ToString(env, tracePath);
request.goldenPath = ToString(env, goldenPath);
request.outputDir = ToString(env, outputDir);
request.diffPath = ToString(env, diffPath);
request.backend = ToString(env, backend);
request.targetFrame = targetFrame;
request.targetCall = targetCall;
@@ -98,6 +98,7 @@ public final class TraceReplayActivity extends Activity {
request.tracePath,
request.goldenPath,
request.outputDir,
request.diffPath,
request.backend,
request.targetFrame,
request.targetCall,
@@ -123,6 +124,7 @@ public final class TraceReplayActivity extends Activity {
String tracePath,
String goldenPath,
String outputDir,
String diffPath,
String backend,
int targetFrame,
long targetCall,
@@ -140,6 +142,7 @@ public final class TraceReplayActivity extends Activity {
final String tracePath;
final String goldenPath;
final String outputDir;
final String diffPath;
final String backend;
final int targetFrame;
final long targetCall;
@@ -156,6 +159,7 @@ public final class TraceReplayActivity extends Activity {
String tracePath,
String goldenPath,
String outputDir,
String diffPath,
String backend,
int targetFrame,
long targetCall,
@@ -171,6 +175,7 @@ public final class TraceReplayActivity extends Activity {
this.tracePath = tracePath;
this.goldenPath = goldenPath;
this.outputDir = outputDir;
this.diffPath = diffPath;
this.backend = backend;
this.targetFrame = targetFrame;
this.targetCall = targetCall;
@@ -186,10 +191,12 @@ public final class TraceReplayActivity extends Activity {
static TraceReplayRequest from(Intent intent, File filesDir, String defaultBackend) {
String outputDir = readString(intent, "output_dir", new File(filesDir, "trace-replay").getAbsolutePath());
String diffPath = readString(intent, "diff_path", "");
return new TraceReplayRequest(
readString(intent, "trace_path", ""),
readString(intent, "golden_path", ""),
outputDir,
diffPath,
readString(intent, "backend", defaultBackend),
intent.getIntExtra("target_frame", -1),
intent.getLongExtra("target_call", -1L),
@@ -216,19 +223,22 @@ public final class TraceReplayActivity extends Activity {
public final String message;
public final String resultPath;
public final String actualPath;
public final String diffPath;
public TraceReplayResult(
boolean passed,
int statusCode,
String message,
String resultPath,
String actualPath
String actualPath,
String diffPath
) {
this.passed = passed;
this.statusCode = statusCode;
this.message = message;
this.resultPath = resultPath;
this.actualPath = actualPath;
this.diffPath = diffPath;
}
@Override
@@ -239,6 +249,7 @@ public final class TraceReplayActivity extends Activity {
", message='" + message + '\'' +
", resultPath='" + resultPath + '\'' +
", actualPath='" + actualPath + '\'' +
", diffPath='" + diffPath + '\'' +
'}';
}
}